aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Core
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2013-04-12 18:40:21 +0000
committerAnna Zaks <ganna@apple.com>2013-04-12 18:40:21 +0000
commit9e2f5977a180ae927d05e844c65b8a7873be48a4 (patch)
tree96fa8bd1b0f074f3870cbe140c2c9a9e8a23b528 /lib/StaticAnalyzer/Core
parent333ac6ed908bd70b879243a1d8541c27f142b40a (diff)
[analyzer]Print field region even when the base region is not printable
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179395 91177308-0d34-0410-b5e6-96231b3b80d8
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;
}
//===----------------------------------------------------------------------===//