summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/cfg.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2013-08-19 16:27:28 +0000
committerJordan Rose <jordan_rose@apple.com>2013-08-19 16:27:28 +0000
commit5374c07ab92e2c78ccf43186383fc5e33835ebb8 (patch)
treef6a8bd1a7cf6167901f4c16101a13d66b0ebaf0b /clang/test/Analysis/cfg.cpp
parentab458a13b0c6ef8cc558e8c1975c399de1220444 (diff)
downloadbcm5719-llvm-5374c07ab92e2c78ccf43186383fc5e33835ebb8.tar.gz
bcm5719-llvm-5374c07ab92e2c78ccf43186383fc5e33835ebb8.zip
Omit arguments of __builtin_object_size from the CFG.
This builtin does not actually evaluate its arguments for side effects, so we shouldn't include them in the CFG. In the analyzer, rely on the constant expression evaluator to get the proper semantics, at least for now. (In the future, we could get ambitious and try to provide path- sensitive size values.) In theory, this does pose a problem for liveness analysis: a variable can be used within the __builtin_object_size argument expression but not show up as live. However, it is very unlikely that such a value would be used to compute the object size and not used to access the object in some way. <rdar://problem/14760817> llvm-svn: 188679
Diffstat (limited to 'clang/test/Analysis/cfg.cpp')
-rw-r--r--clang/test/Analysis/cfg.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/test/Analysis/cfg.cpp b/clang/test/Analysis/cfg.cpp
index c2ec2e9bec2..26e12dcde98 100644
--- a/clang/test/Analysis/cfg.cpp
+++ b/clang/test/Analysis/cfg.cpp
@@ -82,3 +82,19 @@ enum EmptyE {};
void F(EmptyE e) {
switch (e) {}
}
+
+// CHECK: ENTRY
+// CHECK-NEXT: Succs (1): B1
+// CHECK: [B1]
+// CHECK-NEXT: 1: __builtin_object_size
+// CHECK-NEXT: 2: [B1.1] (ImplicitCastExpr, BuiltinFnToFnPtr, unsigned long (*)(const void *, int))
+// CHECK-NEXT: 3: [B1.2](dummy(), 0)
+// CHECK-NEXT: 4: (void)[B1.3] (CStyleCastExpr, ToVoid, void)
+// CHECK-NEXT: Preds (1): B2
+// CHECK-NEXT: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK-NEXT: Preds (1): B1
+void testBuiltinSize() {
+ extern int *dummy();
+ (void)__builtin_object_size(dummy(), 0);
+}
OpenPOWER on IntegriCloud