diff options
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/BugReporter.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/BugReporter.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index 6bb9ffcea92..1940fa79fda 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -1629,6 +1629,10 @@ static const Stmt *getTerminatorCondition(const CFGBlock *B) { static const char StrEnteringLoop[] = "Entering loop body"; static const char StrLoopBodyZero[] = "Loop body executed 0 times"; +static const char StrLoopRangeEmpty[] = + "Loop body skipped when range is empty"; +static const char StrLoopCollectionEmpty[] = + "Loop body skipped when collection is empty"; static bool GenerateAlternateExtensivePathDiagnostic(PathDiagnostic& PD, @@ -1827,7 +1831,13 @@ GenerateAlternateExtensivePathDiagnostic(PathDiagnostic& PD, if (isJumpToFalseBranch(&*BE)) { if (!IsInLoopBody) { - str = StrLoopBodyZero; + if (isa<ObjCForCollectionStmt>(Term)) { + str = StrLoopCollectionEmpty; + } else if (isa<CXXForRangeStmt>(Term)) { + str = StrLoopRangeEmpty; + } else { + str = StrLoopBodyZero; + } } } else { str = StrEnteringLoop; @@ -2072,7 +2082,8 @@ static void simplifySimpleBranches(PathPieces &pieces) { PathDiagnosticEventPiece *EV = dyn_cast<PathDiagnosticEventPiece>(*NextI); if (EV) { StringRef S = EV->getString(); - if (S == StrEnteringLoop || S == StrLoopBodyZero) { + if (S == StrEnteringLoop || S == StrLoopBodyZero || + S == StrLoopCollectionEmpty || S == StrLoopRangeEmpty) { ++NextI; continue; } |