diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2011-09-10 00:02:34 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2011-09-10 00:02:34 +0000 |
commit | a626d645d5f6ddd1f8c5ed3b6664af17e559ee5f (patch) | |
tree | f0c44e827249462c35738109a0a3d255d6186144 /clang/lib/AST/Stmt.cpp | |
parent | 1bbf030b8e927c62678d62097d8bd652809a1e2d (diff) | |
download | bcm5719-llvm-a626d645d5f6ddd1f8c5ed3b6664af17e559ee5f.tar.gz bcm5719-llvm-a626d645d5f6ddd1f8c5ed3b6664af17e559ee5f.zip |
Extend the Stmt AST to make it easier to look through label, default,
and case statements. Use this to make the logic in the CFG builder more
robust at finding the actual statements within a compound statement,
even when there are many layers of labels obscuring it.
Also extend the test cases for a large chunk of PR10063. Still more work
to do here though.
llvm-svn: 139437
Diffstat (limited to 'clang/lib/AST/Stmt.cpp')
-rw-r--r-- | clang/lib/AST/Stmt.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp index 9e4be940110..e7b87e4db67 100644 --- a/clang/lib/AST/Stmt.cpp +++ b/clang/lib/AST/Stmt.cpp @@ -97,6 +97,22 @@ Stmt *Stmt::IgnoreImplicit() { return s; } +/// \brief Strip off all label-like statements. +/// +/// This will strip off label statements, case statements, and default +/// statements recursively. +const Stmt *Stmt::stripLabelLikeStatements() const { + const Stmt *S = this; + while (true) { + if (const LabelStmt *LS = dyn_cast<LabelStmt>(S)) + S = LS->getSubStmt(); + else if (const SwitchCase *SC = dyn_cast<SwitchCase>(S)) + S = SC->getSubStmt(); + else + return S; + } +} + namespace { struct good {}; struct bad {}; |