summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2017-09-20 06:22:51 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2017-09-20 06:22:51 +0000
commitfc587e6a570796ca321aa981866359c3ae13e21e (patch)
treef99180094d880f13e2267ac280df889296bae3db /clang/test/Sema
parentc8aea66627095ecff057958e06c43b4225b5bf95 (diff)
downloadbcm5719-llvm-fc587e6a570796ca321aa981866359c3ae13e21e.tar.gz
bcm5719-llvm-fc587e6a570796ca321aa981866359c3ae13e21e.zip
Add support for attribute 'noescape'.
The attribute informs the compiler that the annotated pointer parameter of a function cannot escape and enables IRGen to attach attribute 'nocapture' to parameters that are annotated with the attribute. That is the only optimization that currently takes advantage of 'noescape', but there are other optimizations that will be added later that improves IRGen for ObjC blocks. rdar://problem/19886775 Differential Revision: https://reviews.llvm.org/D32520 llvm-svn: 313720
Diffstat (limited to 'clang/test/Sema')
-rw-r--r--clang/test/Sema/noescape.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/clang/test/Sema/noescape.c b/clang/test/Sema/noescape.c
new file mode 100644
index 00000000000..39f3f6f542a
--- /dev/null
+++ b/clang/test/Sema/noescape.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void escapefunc(int *);
+void noescapefunc(__attribute__((noescape)) int *);
+void (*escapefuncptr)(int *);
+void (*noescapefuncptr)(__attribute__((noescape)) int *);
+
+void func_ne(__attribute__((noescape)) int *, int *);
+void func_en(int *, __attribute__((noescape)) int *);
+
+void (*funcptr_ee)(int *, int *);
+void (*funcptr_nn)(__attribute__((noescape)) int *, __attribute__((noescape)) int *);
+
+void test0(int c) {
+ escapefuncptr = &escapefunc;
+ escapefuncptr = &noescapefunc;
+ noescapefuncptr = &escapefunc; // expected-warning {{incompatible function pointer types assigning to 'void (*)(__attribute__((noescape)) int *)' from 'void (*)(int *)'}}
+ noescapefuncptr = &noescapefunc;
+
+ escapefuncptr = c ? &escapefunc : &noescapefunc;
+ noescapefuncptr = c ? &escapefunc : &noescapefunc; // expected-warning {{incompatible function pointer types assigning to 'void (*)(__attribute__((noescape)) int *)' from 'void (*)(int *)'}}
+
+ funcptr_ee = c ? &func_ne : &func_en;
+ funcptr_nn = c ? &func_ne : &func_en; // expected-warning {{incompatible function pointer types assigning to 'void (*)(__attribute__((noescape)) int *, __attribute__((noescape)) int *)' from 'void (*)(int *, int *)'}}
+}
OpenPOWER on IntegriCloud