aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h28
-rw-r--r--lib/StaticAnalyzer/Core/BugReporterVisitors.cpp16
-rw-r--r--lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp2
-rw-r--r--lib/StaticAnalyzer/Core/PathDiagnostic.cpp2
-rw-r--r--lib/StaticAnalyzer/Core/PlistDiagnostics.cpp4
5 files changed, 41 insertions, 11 deletions
diff --git a/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h b/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
index 30b133200f..9516fcea83 100644
--- a/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
+++ b/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
@@ -261,7 +261,7 @@ public:
class PathDiagnosticPiece {
public:
- enum Kind { ControlFlow, Event, Macro };
+ enum Kind { ControlFlow, Event, Macro, CallEnter, CallExit };
enum DisplayHint { Above, Below };
private:
@@ -356,6 +356,32 @@ public:
return P->getKind() == Event;
}
};
+
+class PathDiagnosticCallEnterPiece : public PathDiagnosticSpotPiece {
+public:
+ PathDiagnosticCallEnterPiece(const PathDiagnosticLocation &pos,
+ StringRef s)
+ : PathDiagnosticSpotPiece(pos, s, CallEnter, false) {}
+
+ ~PathDiagnosticCallEnterPiece();
+
+ static inline bool classof(const PathDiagnosticPiece *P) {
+ return P->getKind() == CallEnter;
+ }
+};
+
+class PathDiagnosticCallExitPiece : public PathDiagnosticSpotPiece {
+public:
+ PathDiagnosticCallExitPiece(const PathDiagnosticLocation &pos,
+ StringRef s)
+ : PathDiagnosticSpotPiece(pos, s, CallExit, false) {}
+
+ ~PathDiagnosticCallExitPiece();
+
+ static inline bool classof(const PathDiagnosticPiece *P) {
+ return P->getKind() == CallExit;
+ }
+};
class PathDiagnosticControlFlowPiece : public PathDiagnosticPiece {
std::vector<PathDiagnosticLocationPair> LPairs;
diff --git a/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
index c0804e7340..3ea08cde00 100644
--- a/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ b/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -758,6 +758,10 @@ CallEnterExitBRVisitor::VisitNode(const ExplodedNode *N,
Out << "Entering call to block";
else if (const NamedDecl *ND = dyn_cast<NamedDecl>(callee))
Out << "Entering call to '" << ND->getNameAsString() << "'";
+ StringRef msg = Out.str();
+ if (msg.empty())
+ return 0;
+ return new PathDiagnosticCallEnterPiece(pos, msg);
}
else if (const CallExit *CExit = dyn_cast<CallExit>(&PP)) {
const Decl *caller = CExit->getLocationContext()->getParent()->getDecl();
@@ -765,15 +769,9 @@ CallEnterExitBRVisitor::VisitNode(const ExplodedNode *N,
if (const NamedDecl *ND = dyn_cast<NamedDecl>(caller))
Out << "Returning to '" << ND->getNameAsString() << "'";
else
- Out << "Returning to caller";
+ Out << "Returning to caller";
+ return new PathDiagnosticCallExitPiece(pos, Out.str());
}
-
- if (!pos.isValid())
- return 0;
-
- StringRef msg = Out.str();
- if (msg.empty())
- return 0;
- return new PathDiagnosticEventPiece(pos, msg);
+ return 0;
}
diff --git a/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp b/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
index 933e15c0de..2b3dcdc5c8 100644
--- a/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ b/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -334,6 +334,8 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID,
const char *Kind = 0;
switch (P.getKind()) {
+ case PathDiagnosticPiece::CallEnter:
+ case PathDiagnosticPiece::CallExit:
case PathDiagnosticPiece::Event: Kind = "Event"; break;
case PathDiagnosticPiece::ControlFlow: Kind = "Control"; break;
// Setting Kind to "Control" is intentional.
diff --git a/lib/StaticAnalyzer/Core/PathDiagnostic.cpp b/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
index c0bb180c82..0d2c2e82d9 100644
--- a/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ b/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -52,6 +52,8 @@ PathDiagnosticPiece::PathDiagnosticPiece(Kind k, DisplayHint hint)
PathDiagnosticPiece::~PathDiagnosticPiece() {}
PathDiagnosticEventPiece::~PathDiagnosticEventPiece() {}
+PathDiagnosticCallEnterPiece::~PathDiagnosticCallEnterPiece() {}
+PathDiagnosticCallExitPiece::~PathDiagnosticCallExitPiece() {}
PathDiagnosticControlFlowPiece::~PathDiagnosticControlFlowPiece() {}
PathDiagnosticMacroPiece::~PathDiagnosticMacroPiece() {
diff --git a/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp b/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
index cc8c315c4e..89b44c1ca0 100644
--- a/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ b/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -275,8 +275,10 @@ static void ReportDiag(raw_ostream &o, const PathDiagnosticPiece& P,
ReportControlFlow(o, cast<PathDiagnosticControlFlowPiece>(P), FM, SM,
LangOpts, indent);
break;
+ case PathDiagnosticPiece::CallEnter:
+ case PathDiagnosticPiece::CallExit:
case PathDiagnosticPiece::Event:
- ReportEvent(o, cast<PathDiagnosticEventPiece>(P), FM, SM, LangOpts,
+ ReportEvent(o, cast<PathDiagnosticSpotPiece>(P), FM, SM, LangOpts,
indent);
break;
case PathDiagnosticPiece::Macro: