From 5a8e1ad062420ef74707bf093889403d07664b17 Mon Sep 17 00:00:00 2001 From: Anna Zaks Date: Fri, 17 May 2013 20:51:16 +0000 Subject: [PATCH] [analyzer] Address Jordan's review comments for r182058 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182156 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/StaticAnalyzer/Core/PathDiagnostic.cpp | 9 ++++++--- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp | 2 +- .../diagnostics/report-issues-within-main-file.cpp | 8 ++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/StaticAnalyzer/Core/PathDiagnostic.cpp b/lib/StaticAnalyzer/Core/PathDiagnostic.cpp index e580dc8321..4b7b6628f3 100644 --- a/lib/StaticAnalyzer/Core/PathDiagnostic.cpp +++ b/lib/StaticAnalyzer/Core/PathDiagnostic.cpp @@ -130,9 +130,12 @@ getFirstStackedCallToHeaderFile(PathDiagnosticCallPiece *CP, if (!SMgr.isFromMainFile(CP->callEnterWithin.asLocation())) return CP; + const PathPieces &Path = CP->path; + if (Path.empty()) + return 0; + // Check if the last piece in the callee path is a call to a function outside // of the main file. - const PathPieces &Path = CP->path; if (PathDiagnosticCallPiece *CPInner = dyn_cast(Path.back())) { return getFirstStackedCallToHeaderFile(CPInner, SMgr); @@ -147,8 +150,8 @@ void PathDiagnostic::resetDiagnosticLocationToMainFile() { return; PathDiagnosticPiece *LastP = path.back().getPtr(); - const SourceManager &SMgr = LastP->getLocation().getManager(); assert(LastP); + const SourceManager &SMgr = LastP->getLocation().getManager(); // We only need to check if the report ends inside headers, if the last piece // is a call piece. @@ -163,7 +166,7 @@ void PathDiagnostic::resetDiagnosticLocationToMainFile() { if (ND) { SmallString<200> buf; llvm::raw_svector_ostream os(buf); - os << " (within a call to " << ND->getDeclName().getAsString() << ")"; + os << " (within a call to '" << ND->getDeclName() << "')"; appendToDesc(os.str()); } diff --git a/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp b/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp index f1a5135c66..087ab5a8a2 100644 --- a/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp +++ b/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp @@ -224,7 +224,7 @@ static void ReportEvent(raw_ostream &o, const PathDiagnosticPiece& P, Indent(o, indent) << "kindevent\n"; if (isKeyEvent) { - Indent(o, indent) << "key_eventYES\n"; + Indent(o, indent) << "key_event\n"; } // Output the location. diff --git a/test/Analysis/diagnostics/report-issues-within-main-file.cpp b/test/Analysis/diagnostics/report-issues-within-main-file.cpp index 82705651cf..b0aac09c93 100644 --- a/test/Analysis/diagnostics/report-issues-within-main-file.cpp +++ b/test/Analysis/diagnostics/report-issues-within-main-file.cpp @@ -181,7 +181,7 @@ void mainPlustHeaderCallAndReturnPlusMain() { // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindevent -// CHECK-NEXT: key_eventYES +// CHECK-NEXT: key_event // CHECK-NEXT: location // CHECK-NEXT: // CHECK-NEXT: line7 @@ -272,7 +272,7 @@ void mainPlustHeaderCallAndReturnPlusMain() { // CHECK-NEXT: Memory allocated by 'new[]' should be deallocated by 'delete[]', not 'delete' // CHECK-NEXT: // CHECK-NEXT: -// CHECK-NEXT: descriptionMemory allocated by 'new[]' should be deallocated by 'delete[]', not 'delete' (within a call to ~auto_ptr) +// CHECK-NEXT: descriptionMemory allocated by 'new[]' should be deallocated by 'delete[]', not 'delete' (within a call to '~auto_ptr') // CHECK-NEXT: categoryMemory Error // CHECK-NEXT: typeBad deallocator // CHECK-NEXT: issue_context_kindfunction @@ -435,7 +435,7 @@ void mainPlustHeaderCallAndReturnPlusMain() { // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindevent -// CHECK-NEXT: key_eventYES +// CHECK-NEXT: key_event // CHECK-NEXT: location // CHECK-NEXT: // CHECK-NEXT: line12 @@ -604,7 +604,7 @@ void mainPlustHeaderCallAndReturnPlusMain() { // CHECK-NEXT: Division by zero // CHECK-NEXT: // CHECK-NEXT: -// CHECK-NEXT: descriptionDivision by zero (within a call to cause_div_by_zero_in_header) +// CHECK-NEXT: descriptionDivision by zero (within a call to 'cause_div_by_zero_in_header') // CHECK-NEXT: categoryLogic error // CHECK-NEXT: typeDivision by zero // CHECK-NEXT: issue_context_kindfunction -- 2.40.0