]> granicus.if.org Git - clang/commitdiff
[analyzer] Address Jordan's review comments for r182058
authorAnna Zaks <ganna@apple.com>
Fri, 17 May 2013 20:51:16 +0000 (20:51 +0000)
committerAnna Zaks <ganna@apple.com>
Fri, 17 May 2013 20:51:16 +0000 (20:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182156 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/PathDiagnostic.cpp
lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
test/Analysis/diagnostics/report-issues-within-main-file.cpp

index e580dc83210a172da6082f8d78618e7f28de5fec..4b7b6628f314eb02862c5c51071dd4f232ebf140 100644 (file)
@@ -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<PathDiagnosticCallPiece>(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());
       }
 
index f1a5135c66def39853fb8f11ab976abe1174fc1d..087ab5a8a22a6a0a18fac71826c907a33aeb52c9 100644 (file)
@@ -224,7 +224,7 @@ static void ReportEvent(raw_ostream &o, const PathDiagnosticPiece& P,
   Indent(o, indent) << "<key>kind</key><string>event</string>\n";
 
   if (isKeyEvent) {
-    Indent(o, indent) << "<key>key_event</key><string>YES</string>\n";
+    Indent(o, indent) << "<key>key_event</key><true/>\n";
   }
 
   // Output the location.
index 82705651cf6540036513e718089cf2b592725501..b0aac09c93866a144d360c1dab8c2a59d6317a87 100644 (file)
@@ -181,7 +181,7 @@ void mainPlustHeaderCallAndReturnPlusMain() {
 // CHECK-NEXT:     </dict>
 // CHECK-NEXT:     <dict>
 // CHECK-NEXT:      <key>kind</key><string>event</string>
-// CHECK-NEXT:      <key>key_event</key><string>YES</string>
+// CHECK-NEXT:      <key>key_event</key><true/>
 // CHECK-NEXT:      <key>location</key>
 // CHECK-NEXT:      <dict>
 // CHECK-NEXT:       <key>line</key><integer>7</integer>
@@ -272,7 +272,7 @@ void mainPlustHeaderCallAndReturnPlusMain() {
 // CHECK-NEXT:      <string>Memory allocated by &apos;new[]&apos; should be deallocated by &apos;delete[]&apos;, not &apos;delete&apos;</string>
 // CHECK-NEXT:     </dict>
 // CHECK-NEXT:    </array>
-// CHECK-NEXT:    <key>description</key><string>Memory allocated by &apos;new[]&apos; should be deallocated by &apos;delete[]&apos;, not &apos;delete&apos; (within a call to ~auto_ptr)</string>
+// CHECK-NEXT:    <key>description</key><string>Memory allocated by &apos;new[]&apos; should be deallocated by &apos;delete[]&apos;, not &apos;delete&apos; (within a call to &apos;~auto_ptr&apos;)</string>
 // CHECK-NEXT:    <key>category</key><string>Memory Error</string>
 // CHECK-NEXT:    <key>type</key><string>Bad deallocator</string>
 // CHECK-NEXT:   <key>issue_context_kind</key><string>function</string>
@@ -435,7 +435,7 @@ void mainPlustHeaderCallAndReturnPlusMain() {
 // CHECK-NEXT:     </dict>
 // CHECK-NEXT:     <dict>
 // CHECK-NEXT:      <key>kind</key><string>event</string>
-// CHECK-NEXT:      <key>key_event</key><string>YES</string>
+// CHECK-NEXT:      <key>key_event</key><true/>
 // CHECK-NEXT:      <key>location</key>
 // CHECK-NEXT:      <dict>
 // CHECK-NEXT:       <key>line</key><integer>12</integer>
@@ -604,7 +604,7 @@ void mainPlustHeaderCallAndReturnPlusMain() {
 // CHECK-NEXT:      <string>Division by zero</string>
 // CHECK-NEXT:     </dict>
 // CHECK-NEXT:    </array>
-// CHECK-NEXT:    <key>description</key><string>Division by zero (within a call to cause_div_by_zero_in_header)</string>
+// CHECK-NEXT:    <key>description</key><string>Division by zero (within a call to &apos;cause_div_by_zero_in_header&apos;)</string>
 // CHECK-NEXT:    <key>category</key><string>Logic error</string>
 // CHECK-NEXT:    <key>type</key><string>Division by zero</string>
 // CHECK-NEXT:   <key>issue_context_kind</key><string>function</string>