[compiler-rt] bed8882 - [scudo][test] Disable -Wfree-nonheap-object
Leonard Chan via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 26 11:15:24 PST 2021
Author: Leonard Chan
Date: 2021-02-26T11:14:50-08:00
New Revision: bed888242662c2327b32b91a03635e079ad5667e
URL: https://github.com/llvm/llvm-project/commit/bed888242662c2327b32b91a03635e079ad5667e
DIFF: https://github.com/llvm/llvm-project/commit/bed888242662c2327b32b91a03635e079ad5667e.diff
LOG: [scudo][test] Disable -Wfree-nonheap-object
As of 4f395db86b5cc11bb56853323d3cb1d4b6db5a0b which contains updates to
-Wfree-nonheap-object, a line in this test will trigger the warning. This
particular line is ok though since it's meant to test a free on a bad pointer.
Differential Revision: https://reviews.llvm.org/D97516
Added:
Modified:
compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp b/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
index e01ac38cd806..e8872a154fc1 100644
--- a/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
@@ -42,8 +42,19 @@ TEST(ScudoWrappersCTest, Malloc) {
EXPECT_NE(P, nullptr);
EXPECT_LE(Size, malloc_usable_size(P));
EXPECT_EQ(reinterpret_cast<uintptr_t>(P) % FIRST_32_SECOND_64(8U, 16U), 0U);
+
+ // An update to this warning in Clang now triggers in this line, but it's ok
+ // because the check is expecting a bad pointer and should fail.
+#if defined(__has_warning) && __has_warning("-Wfree-nonheap-object")
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wfree-nonheap-object"
+#endif
EXPECT_DEATH(
free(reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(P) | 1U)), "");
+#if defined(__has_warning) && __has_warning("-Wfree-nonheap-object")
+#pragma GCC diagnostic pop
+#endif
+
free(P);
EXPECT_DEATH(free(P), "");
More information about the llvm-commits
mailing list