summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/attr-no-sanitize.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2015-05-15 18:33:32 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2015-05-15 18:33:32 +0000
commit915df9968b6524d1858884ae5694812b6831a1ac (patch)
treeb7e541fa454fbea85db502afff25cb5d2533bd43 /clang/test/SemaCXX/attr-no-sanitize.cpp
parent25e2500ac866365beaf747e2b0c926b9db4f721b (diff)
downloadbcm5719-llvm-915df9968b6524d1858884ae5694812b6831a1ac.tar.gz
bcm5719-llvm-915df9968b6524d1858884ae5694812b6831a1ac.zip
Implement no_sanitize attribute.
Differential Revision: http://reviews.llvm.org/D9631 llvm-svn: 237463
Diffstat (limited to 'clang/test/SemaCXX/attr-no-sanitize.cpp')
-rw-r--r--clang/test/SemaCXX/attr-no-sanitize.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/attr-no-sanitize.cpp b/clang/test/SemaCXX/attr-no-sanitize.cpp
new file mode 100644
index 00000000000..120fa64587d
--- /dev/null
+++ b/clang/test/SemaCXX/attr-no-sanitize.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// RUN: not %clang_cc1 -std=c++11 -ast-dump %s 2>&1 | FileCheck --check-prefix=DUMP %s
+// RUN: not %clang_cc1 -std=c++11 -ast-print %s 2>&1 | FileCheck --check-prefix=PRINT %s
+
+int v1 __attribute__((no_sanitize("address"))); // expected-error{{'no_sanitize' attribute only applies to functions and methods}}
+
+int f1() __attribute__((no_sanitize)); // expected-error{{'no_sanitize' attribute takes at least 1 argument}}
+
+int f2() __attribute__((no_sanitize(1))); // expected-error{{'no_sanitize' attribute requires a string}}
+
+// DUMP-LABEL: FunctionDecl {{.*}} f3
+// DUMP: NoSanitizeAttr {{.*}} address
+// PRINT: int f3() __attribute__((no_sanitize("address")))
+int f3() __attribute__((no_sanitize("address")));
+
+// DUMP-LABEL: FunctionDecl {{.*}} f4
+// DUMP: NoSanitizeAttr {{.*}} thread
+// PRINT: int f4() {{\[\[}}clang::no_sanitize("thread")]]
+[[clang::no_sanitize("thread")]] int f4();
+
+// DUMP-LABEL: FunctionDecl {{.*}} f5
+// DUMP: NoSanitizeAttr {{.*}} address thread
+// PRINT: int f5() __attribute__((no_sanitize("address", "thread")))
+int f5() __attribute__((no_sanitize("address", "thread")));
+
+// DUMP-LABEL: FunctionDecl {{.*}} f6
+// DUMP: NoSanitizeAttr {{.*}} unknown
+// PRINT: int f6() __attribute__((no_sanitize("unknown")))
+int f6() __attribute__((no_sanitize("unknown"))); // expected-warning{{unknown sanitizer 'unknown' ignored}}
OpenPOWER on IntegriCloud