[CFG] NFC: Remove implicit conversion from CFGTerminator to Stmt *.
Turn it into a variant class instead. This conversion does indeed save some code
but there's a plan to add support for more kinds of terminators that aren't
necessarily based on statements, and with those in mind it becomes more and more
confusing to have CFGTerminators implicitly convertible to a Stmt *.
Differential Revision: https://reviews.llvm.org/D61814
llvm-svn: 361586
diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp
index 6c95b60..bac407b 100644
--- a/clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -398,7 +398,8 @@
for (const auto *B : *cfg) {
if (!live[B->getBlockID()]) {
if (B->pred_begin() == B->pred_end()) {
- if (B->getTerminator() && isa<CXXTryStmt>(B->getTerminator()))
+ const Stmt *Term = B->getTerminatorStmt();
+ if (Term && isa<CXXTryStmt>(Term))
// When not adding EH edges from calls, catch clauses
// can otherwise seem dead. Avoid noting them as dead.
count += reachable_code::ScanReachableFromBlock(B, live);
@@ -446,7 +447,8 @@
// No more CFGElements in the block?
if (ri == re) {
- if (B.getTerminator() && isa<CXXTryStmt>(B.getTerminator())) {
+ const Stmt *Term = B.getTerminatorStmt();
+ if (Term && isa<CXXTryStmt>(Term)) {
HasAbnormalEdge = true;
continue;
}
@@ -1077,7 +1079,7 @@
BlockQueue.pop_front();
if (!P) continue;
- const Stmt *Term = P->getTerminator();
+ const Stmt *Term = P->getTerminatorStmt();
if (Term && isa<SwitchStmt>(Term))
continue; // Switch statement, good.
@@ -1175,7 +1177,7 @@
}
static const Stmt *getLastStmt(const CFGBlock &B) {
- if (const Stmt *Term = B.getTerminator())
+ if (const Stmt *Term = B.getTerminatorStmt())
return Term;
for (CFGBlock::const_reverse_iterator ElemIt = B.rbegin(),
ElemEnd = B.rend();
@@ -1281,11 +1283,11 @@
if (L.isMacroID())
continue;
if (S.getLangOpts().CPlusPlus11) {
- const Stmt *Term = B->getTerminator();
+ const Stmt *Term = B->getTerminatorStmt();
// Skip empty cases.
while (B->empty() && !Term && B->succ_size() == 1) {
B = *B->succ_begin();
- Term = B->getTerminator();
+ Term = B->getTerminatorStmt();
}
if (!(B->empty() && Term && isa<BreakStmt>(Term))) {
Preprocessor &PP = S.getPreprocessor();