diff options
author | Alexander Kornienko <alexfh@google.com> | 2013-01-25 15:49:34 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2013-01-25 15:49:34 +0000 |
commit | 5548879324813b8fa74d1c67e08a2e00ead7785f (patch) | |
tree | 4306b8fc350c624696e264e26a7c76c4a83e9f2b /clang/lib/Sema | |
parent | 7a31af140b3a7beada378700a4795e38dd886188 (diff) | |
download | bcm5719-llvm-5548879324813b8fa74d1c67e08a2e00ead7785f.tar.gz bcm5719-llvm-5548879324813b8fa74d1c67e08a2e00ead7785f.zip |
Don't suggest to insert [[clang::fallthrough]] before empty cases. Fix for multiple case labels.
llvm-svn: 173458
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/AnalysisBasedWarnings.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp index d5fa959bf44..78864ec2852 100644 --- a/clang/lib/Sema/AnalysisBasedWarnings.cpp +++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp @@ -846,13 +846,13 @@ static void DiagnoseSwitchLabelsFallthrough(Sema &S, AnalysisDeclContext &AC, int AnnotatedCnt; for (CFG::reverse_iterator I = Cfg->rbegin(), E = Cfg->rend(); I != E; ++I) { - const CFGBlock &B = **I; - const Stmt *Label = B.getLabel(); + const CFGBlock *B = *I; + const Stmt *Label = B->getLabel(); if (!Label || !isa<SwitchCase>(Label)) continue; - if (!FM.checkFallThroughIntoBlock(B, AnnotatedCnt)) + if (!FM.checkFallThroughIntoBlock(*B, AnnotatedCnt)) continue; S.Diag(Label->getLocStart(), @@ -864,8 +864,13 @@ static void DiagnoseSwitchLabelsFallthrough(Sema &S, AnalysisDeclContext &AC, if (L.isMacroID()) continue; if (S.getLangOpts().CPlusPlus11) { - const Stmt *Term = B.getTerminator(); - if (!(B.empty() && Term && isa<BreakStmt>(Term))) { + const Stmt *Term = B->getTerminator(); + // Skip empty cases. + while (B->empty() && !Term && B->succ_size() == 1) { + B = *B->succ_begin(); + Term = B->getTerminator(); + } + if (!(B->empty() && Term && isa<BreakStmt>(Term))) { Preprocessor &PP = S.getPreprocessor(); TokenValue Tokens[] = { tok::l_square, tok::l_square, PP.getIdentifierInfo("clang"), |