summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/lambda-expressions.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-08-07 04:16:51 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-08-07 04:16:51 +0000
commit0421ce7b225fbc4e2b9610453090835125580055 (patch)
tree8975b012343bbec8508ff51265a6e643f2b0ed0d /clang/test/CodeGenCXX/lambda-expressions.cpp
parent9c2efe39c0a643ae648dffd0a6e928f2a3c57f54 (diff)
downloadbcm5719-llvm-0421ce7b225fbc4e2b9610453090835125580055.tar.gz
bcm5719-llvm-0421ce7b225fbc4e2b9610453090835125580055.zip
Teach Expr::HasSideEffects about all the Expr types, and fix a bug where it
was mistakenly classifying dynamic_casts which might throw as having no side effects. Switch it from a visitor to a switch, so it is kept up-to-date as future Expr nodes are added. Move it from ExprConstant.cpp to Expr.cpp, since it's not really related to constant expression evaluation. Since we use HasSideEffect to determine whether to emit an unused global with internal linkage, this has the effect of suppressing emission of globals in some cases. I've left many of the Objective-C cases conservatively assuming that the expression has side-effects. I'll leave it to someone with better knowledge of Objective-C than mine to improve them. llvm-svn: 161388
Diffstat (limited to 'clang/test/CodeGenCXX/lambda-expressions.cpp')
-rw-r--r--clang/test/CodeGenCXX/lambda-expressions.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/test/CodeGenCXX/lambda-expressions.cpp b/clang/test/CodeGenCXX/lambda-expressions.cpp
index 797cbf43a78..e872cc494bc 100644
--- a/clang/test/CodeGenCXX/lambda-expressions.cpp
+++ b/clang/test/CodeGenCXX/lambda-expressions.cpp
@@ -1,7 +1,11 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 | FileCheck %s
-// CHECK: @var = internal global
-auto var = [](int i) { return i+1; };
+// CHECK-NOT: @unused
+auto unused = [](int i) { return i+1; };
+
+// CHECK: @used = internal global
+auto used = [](int i) { return i+1; };
+void *use = &used;
// CHECK: @cvar = global
extern "C" auto cvar = []{};
OpenPOWER on IntegriCloud