From: Ted Kremenek Date: Mon, 23 Feb 2009 23:13:51 +0000 (+0000) Subject: Tidy up 'ExecutionContinues' to distinguish between jumping to the end of a 'method... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b479dadea93b93d3f0a335c3518b703f140b3f50;p=clang Tidy up 'ExecutionContinues' to distinguish between jumping to the end of a 'method' or 'funciton'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65346 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp index 09a4f2b45b..a89542d4c1 100644 --- a/lib/Analysis/BugReporter.cpp +++ b/lib/Analysis/BugReporter.cpp @@ -83,25 +83,22 @@ static inline Stmt* GetCurrentOrNextStmt(const ExplodedNode* N) { //===----------------------------------------------------------------------===// // Diagnostics for 'execution continues on line XXX'. //===----------------------------------------------------------------------===// - -static void ExecutionContinues(llvm::raw_string_ostream& os, - SourceManager& SMgr, - const Stmt* S) { + +static inline void ExecutionContinues(llvm::raw_string_ostream& os, + SourceManager& SMgr, + const ExplodedNode* N, + const Decl& D) { + // Slow, but probably doesn't matter. if (os.str().empty()) os << ' '; - if (S) + if (Stmt *S = GetNextStmt(N)) os << "Execution continues on line " - << SMgr.getInstantiationLineNumber(S->getLocStart()) << '.'; + << SMgr.getInstantiationLineNumber(S->getLocStart()) << '.'; else - os << "Execution jumps to the end of the function."; -} - -static inline void ExecutionContinues(llvm::raw_string_ostream& os, - SourceManager& SMgr, - const ExplodedNode* N) { - ExecutionContinues(os, SMgr, GetNextStmt(N)); + os << "Execution jumps to the end of the " + << (isa(D) ? "method" : "function") << '.'; } //===----------------------------------------------------------------------===// @@ -704,7 +701,7 @@ void GRBugReporter::GeneratePathDiagnostic(PathDiagnostic& PD, } else { os << "'Default' branch taken. "; - ExecutionContinues(os, SMgr, N); + ExecutionContinues(os, SMgr, N, getStateManager().getCodeDecl()); } PD.push_front(new PathDiagnosticPiece(L, os.str())); @@ -715,7 +712,7 @@ void GRBugReporter::GeneratePathDiagnostic(PathDiagnostic& PD, case Stmt::ContinueStmtClass: { std::string sbuf; llvm::raw_string_ostream os(sbuf); - ExecutionContinues(os, SMgr, N); + ExecutionContinues(os, SMgr, N, getStateManager().getCodeDecl()); PD.push_front(new PathDiagnosticPiece(L, os.str())); break; } @@ -741,7 +738,7 @@ void GRBugReporter::GeneratePathDiagnostic(PathDiagnostic& PD, llvm::raw_string_ostream os(sbuf); os << "Loop condition is true. "; - ExecutionContinues(os, SMgr, N); + ExecutionContinues(os, SMgr, N, getStateManager().getCodeDecl()); PD.push_front(new PathDiagnosticPiece(L, os.str())); } @@ -760,7 +757,7 @@ void GRBugReporter::GeneratePathDiagnostic(PathDiagnostic& PD, llvm::raw_string_ostream os(sbuf); os << "Loop condition is false. "; - ExecutionContinues(os, SMgr, N); + ExecutionContinues(os, SMgr, N, getStateManager().getCodeDecl()); PD.push_front(new PathDiagnosticPiece(L, os.str())); }