aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Core
diff options
context:
space:
mode:
Diffstat (limited to 'lib/StaticAnalyzer/Core')
-rw-r--r--lib/StaticAnalyzer/Core/BugReporterVisitors.cpp18
-rw-r--r--lib/StaticAnalyzer/Core/MemRegion.cpp34
2 files changed, 34 insertions, 18 deletions
diff --git a/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
index 9b5f6b2a8c..92159de168 100644
--- a/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ b/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -307,9 +307,9 @@ public:
if (LValue) {
if (const MemRegion *MR = LValue->getAsRegion()) {
if (MR->canPrintPretty()) {
- Out << " (reference to '";
+ Out << " (reference to ";
MR->printPretty(Out);
- Out << "')";
+ Out << ")";
}
}
} else {
@@ -545,13 +545,9 @@ PathDiagnosticPiece *FindLastStoreBRVisitor::VisitNode(const ExplodedNode *Succ,
}
if (action) {
- if (!R)
- return 0;
-
- os << '\'';
R->printPretty(os);
- os << "' ";
-
+ os << " ";
+
if (V.getAs<loc::ConcreteInt>()) {
bool b = false;
if (R->isBoundable()) {
@@ -606,10 +602,8 @@ PathDiagnosticPiece *FindLastStoreBRVisitor::VisitNode(const ExplodedNode *Succ,
// Printed parameter indexes are 1-based, not 0-based.
unsigned Idx = Param->getFunctionScopeIndex() + 1;
- os << " via " << Idx << llvm::getOrdinalSuffix(Idx) << " parameter '";
-
+ os << " via " << Idx << llvm::getOrdinalSuffix(Idx) << " parameter ";
R->printPretty(os);
- os << '\'';
}
}
@@ -637,9 +631,7 @@ PathDiagnosticPiece *FindLastStoreBRVisitor::VisitNode(const ExplodedNode *Succ,
else
os << "Value assigned to ";
- os << '\'';
R->printPretty(os);
- os << '\'';
}
// Construct a new PathDiagnosticPiece.
diff --git a/lib/StaticAnalyzer/Core/MemRegion.cpp b/lib/StaticAnalyzer/Core/MemRegion.cpp
index b3a1e65b19..e244d31afa 100644
--- a/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ b/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -559,6 +559,15 @@ bool MemRegion::canPrintPretty() const {
}
void MemRegion::printPretty(raw_ostream &os) const {
+ assert(canPrintPretty() && "This region cannot be printed pretty.");
+ os << "'";
+ printPrettyNoQuotes(os);
+ os << "'";
+ return;
+}
+
+void MemRegion::printPrettyNoQuotes(raw_ostream &os) const {
+ assert(canPrintPretty() && "This region cannot be printed pretty.");
return;
}
@@ -566,7 +575,7 @@ bool VarRegion::canPrintPretty() const {
return true;
}
-void VarRegion::printPretty(raw_ostream &os) const {
+void VarRegion::printPrettyNoQuotes(raw_ostream &os) const {
os << getDecl()->getName();
}
@@ -574,17 +583,32 @@ bool ObjCIvarRegion::canPrintPretty() const {
return true;
}
-void ObjCIvarRegion::printPretty(raw_ostream &os) const {
+void ObjCIvarRegion::printPrettyNoQuotes(raw_ostream &os) const {
os << getDecl()->getName();
}
bool FieldRegion::canPrintPretty() const {
- return superRegion->canPrintPretty();
+ return true;
+}
+
+void FieldRegion::printPrettyNoQuotes(raw_ostream &os) const {
+ if (superRegion->canPrintPretty()) {
+ superRegion->printPrettyNoQuotes(os);
+ os << "." << getDecl()->getName();
+ } else {
+ os << "field " << "\'" << getDecl()->getName() << "'";
+ }
}
void FieldRegion::printPretty(raw_ostream &os) const {
- superRegion->printPretty(os);
- os << "." << getDecl()->getName();
+ if (superRegion->canPrintPretty()) {
+ os << "\'";
+ printPrettyNoQuotes(os);
+ os << "'";
+ } else {
+ printPrettyNoQuotes(os);
+ }
+ return;
}
//===----------------------------------------------------------------------===//