Revert^3 "Use DoNotOptimize rather than rely on a volatile."
This reverts commit aad7abbd31a93a43da3163331d5ceb02d7c09fcb.
Reason for revert: DroidMonitor: Potential culprit for http://b/370545152 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted
Change-Id: Id35ba5d9c986d83357d4acff9dc17ce67049439a
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'}));