summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Stmt.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-10-28 08:53:48 +0000
committerJohn McCall <rjmccall@apple.com>2010-10-28 08:53:48 +0000
commit9de9160d553240d16b1825827d833021ada66598 (patch)
treeb101dec0b984b745ce8af1f62cdcb290bec4b0ae /clang/lib/AST/Stmt.cpp
parent080d86feccc1fff744131c72f3980651b3d683e6 (diff)
downloadbcm5719-llvm-9de9160d553240d16b1825827d833021ada66598.tar.gz
bcm5719-llvm-9de9160d553240d16b1825827d833021ada66598.zip
Implement an indirect-goto optimization for goto *&&lbl and respect this
in the scope checker. With that done, turn an indirect goto into a protected scope into a hard error; otherwise IR generation has to start worrying about declarations not dominating their scopes, as exemplified in PR8473. If this really affects anyone, I can probably adjust this to only hard-error on possible indirect gotos into VLA scopes rather than arbitrary scopes. But we'll see how people cope with the aggressive change on the marginal feature. llvm-svn: 117539
Diffstat (limited to 'clang/lib/AST/Stmt.cpp')
-rw-r--r--clang/lib/AST/Stmt.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp
index 4f46b350408..09d889e9234 100644
--- a/clang/lib/AST/Stmt.cpp
+++ b/clang/lib/AST/Stmt.cpp
@@ -669,8 +669,12 @@ Stmt::child_iterator GotoStmt::child_begin() { return child_iterator(); }
Stmt::child_iterator GotoStmt::child_end() { return child_iterator(); }
// IndirectGotoStmt
-Expr* IndirectGotoStmt::getTarget() { return cast<Expr>(Target); }
-const Expr* IndirectGotoStmt::getTarget() const { return cast<Expr>(Target); }
+LabelStmt *IndirectGotoStmt::getConstantTarget() {
+ if (AddrLabelExpr *E =
+ dyn_cast<AddrLabelExpr>(getTarget()->IgnoreParenImpCasts()))
+ return E->getLabel();
+ return 0;
+}
Stmt::child_iterator IndirectGotoStmt::child_begin() { return &Target; }
Stmt::child_iterator IndirectGotoStmt::child_end() { return &Target+1; }
OpenPOWER on IntegriCloud