From 5374c07ab92e2c78ccf43186383fc5e33835ebb8 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Mon, 19 Aug 2013 16:27:28 +0000 Subject: 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. llvm-svn: 188679 --- clang/test/Analysis/cfg.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'clang/test/Analysis/cfg.cpp') 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); +} -- cgit v1.2.1