Revert "Use DoNotOptimize rather than rely on a volatile."
This reverts commit ea0b7fc2f1e533f392ea0f20e383315c974e641b.
Reason for revert: Droidmonitor created revert due to b/370105691. Will be verifying through ABTD before submission.
Change-Id: I6355ed0b9dbd0169f73ad607244fd713b261aecb
diff --git a/tests/clang_fortify_tests.cpp b/tests/clang_fortify_tests.cpp
index ea111c9..105c261 100644
--- a/tests/clang_fortify_tests.cpp
+++ b/tests/clang_fortify_tests.cpp
@@ -95,8 +95,6 @@
#include <android-base/silent_death_test.h>
#include <gtest/gtest.h>
-#include "DoNotOptimize.h"
-
#define CONCAT2(x, y) x##y
#define CONCAT(x, y) CONCAT2(x, y)
#define FORTIFY_TEST_NAME CONCAT(CONCAT(clang_fortify_test_, _FORTIFY_SOURCE), _DeathTest)
@@ -148,7 +146,8 @@
for (char& c : contents) {
c ^= always_zero;
}
- DoNotOptimize(strlen(&contents.front()));
+ // Store in a volatile, so the strlen itself cannot be optimized out.
+ volatile size_t _strlen_result = strlen(&contents.front());
};
EXPECT_NO_DEATH(run_strlen_with_contents({'f', 'o', '\0'}));