summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX/attr-no-sanitize-memory.cpp
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2013-02-26 06:58:27 +0000
committerKostya Serebryany <kcc@google.com>2013-02-26 06:58:27 +0000
commit85aee96c62a99069ea60cb47d5ae69150ca44746 (patch)
treed78fbe8410a3b62f08f768d04fc983ffbf86bcb3 /test/SemaCXX/attr-no-sanitize-memory.cpp
parentd8be0abf30003766f0eb02c87496f29b178146fb (diff)
Unify clang/llvm attributes for asan/tsan/msan (Clang part)
These are two related changes (one in llvm, one in clang). LLVM: - rename address_safety => sanitize_address (the enum value is the same, so we preserve binary compatibility with old bitcode) - rename thread_safety => sanitize_thread - rename no_uninitialized_checks -> sanitize_memory CLANG: - add __attribute__((no_sanitize_address)) as a synonym for __attribute__((no_address_safety_analysis)) - add __attribute__((no_sanitize_thread)) - add __attribute__((no_sanitize_memory)) for S in address thread memory If -fsanitize=S is present and __attribute__((no_sanitize_S)) is not set llvm attribute sanitize_S git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176076 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/attr-no-sanitize-memory.cpp')
-rw-r--r--test/SemaCXX/attr-no-sanitize-memory.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/SemaCXX/attr-no-sanitize-memory.cpp b/test/SemaCXX/attr-no-sanitize-memory.cpp
new file mode 100644
index 0000000000..84acdaca83
--- /dev/null
+++ b/test/SemaCXX/attr-no-sanitize-memory.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#define NO_SANITIZE_MEMORY __attribute__((no_sanitize_memory))
+
+#if !__has_attribute(no_sanitize_memory)
+#error "Should support no_sanitize_memory"
+#endif
+
+void noanal_fun() NO_SANITIZE_MEMORY;
+
+void noanal_fun_args() __attribute__((no_sanitize_memory(1))); // \
+ // expected-error {{attribute takes no arguments}}
+
+int noanal_testfn(int y) NO_SANITIZE_MEMORY;
+
+int noanal_testfn(int y) {
+ int x NO_SANITIZE_MEMORY = y; // \
+ // expected-error {{'no_sanitize_memory' attribute only applies to functions and methods}}
+ return x;
+}
+
+int noanal_test_var NO_SANITIZE_MEMORY; // \
+ // expected-error {{'no_sanitize_memory' attribute only applies to functions and methods}}
+
+class NoanalFoo {
+ private:
+ int test_field NO_SANITIZE_MEMORY; // \
+ // expected-error {{'no_sanitize_memory' attribute only applies to functions and methods}}
+ void test_method() NO_SANITIZE_MEMORY;
+};
+
+class NO_SANITIZE_MEMORY NoanalTestClass { // \
+ // expected-error {{'no_sanitize_memory' attribute only applies to functions and methods}}
+};
+
+void noanal_fun_params(int lvar NO_SANITIZE_MEMORY); // \
+ // expected-error {{'no_sanitize_memory' attribute only applies to functions and methods}}