r179571 - [analyzer] Add more specialized error messages for corner cases as per Jordan's code review for r179396
Anna Zaks
ganna at apple.com
Mon Apr 15 15:37:54 PDT 2013
Author: zaks
Date: Mon Apr 15 17:37:53 2013
New Revision: 179571
URL: http://llvm.org/viewvc/llvm-project?rev=179571&view=rev
Log:
[analyzer] Add more specialized error messages for corner cases as per Jordan's code review for r179396
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/test/Analysis/inlining/path-notes.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=179571&r1=179570&r2=179571&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Mon Apr 15 17:37:53 2013
@@ -526,7 +526,7 @@ PathDiagnosticPiece *FindLastStoreBRVisi
"Initializing to ";
} else if (isa<BlockExpr>(S)) {
action = R->canPrintPretty() ? "captured by block as " :
- "Capturing by block as ";
+ "Captured by block as ";
if (VR) {
// See if we can get the BlockVarRegion.
ProgramStateRef State = StoreSite->getState();
@@ -580,7 +580,7 @@ PathDiagnosticPiece *FindLastStoreBRVisi
}
}
else {
- os << (R->canPrintPretty() ? "initialized" : "Initializing")
+ os << (R->canPrintPretty() ? "initialized" : "Initialized")
<< " here";
}
}
@@ -626,19 +626,33 @@ PathDiagnosticPiece *FindLastStoreBRVisi
}
}
}
+ if (!b) {
+ if (R->canPrintPretty())
+ os << "Null pointer value stored";
+ else
+ os << "Storing null pointer value";
+ }
+
+ } else if (V.isUndef()) {
+ if (R->canPrintPretty())
+ os << "Uninitialized value stored";
+ else
+ os << "Storing uninitialized value";
- if (!b)
- os << "Null pointer value stored";
- }
- else if (V.isUndef()) {
- os << "Uninitialized value stored";
} else if (Optional<nonloc::ConcreteInt> CV =
V.getAs<nonloc::ConcreteInt>()) {
- os << "The value " << CV->getValue() << " is assigned";
+ if (R->canPrintPretty())
+ os << "The value " << CV->getValue() << " is assigned";
+ else
+ os << "Assigning " << CV->getValue();
+
+ } else {
+ if (R->canPrintPretty())
+ os << "Value assigned";
+ else
+ os << "Assigning value";
}
- else
- os << "Value assigned";
-
+
if (R->canPrintPretty()) {
os << " to ";
R->printPretty(os);
Modified: cfe/trunk/test/Analysis/inlining/path-notes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/inlining/path-notes.cpp?rev=179571&r1=179570&r2=179571&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/inlining/path-notes.cpp (original)
+++ cfe/trunk/test/Analysis/inlining/path-notes.cpp Mon Apr 15 17:37:53 2013
@@ -208,7 +208,7 @@ void testPathNoteOnInitializer() {
int testNonPrintableAssignment(int **p) {
int *&y = *p; // expected-note {{'y' initialized here}}
- y = 0; // expected-note {{Null pointer value stored}}
+ y = 0; // expected-note {{Storing null pointer value}}
return *y; // expected-warning {{Dereference of null pointer (loaded from variable 'y')}}
// expected-note at -1 {{Dereference of null pointer (loaded from variable 'y')}}
}
@@ -3704,9 +3704,9 @@ int testNonPrintableAssignment(int **p)
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>depth</key><integer>0</integer>
// CHECK-NEXT: <key>extended_message</key>
-// CHECK-NEXT: <string>Null pointer value stored</string>
+// CHECK-NEXT: <string>Storing null pointer value</string>
// CHECK-NEXT: <key>message</key>
-// CHECK-NEXT: <string>Null pointer value stored</string>
+// CHECK-NEXT: <string>Storing null pointer value</string>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>kind</key><string>control</string>
More information about the cfe-commits
mailing list