[cfe-commits] r66291 - in /cfe/trunk: include/clang/Analysis/PathDiagnostic.h lib/Analysis/PathDiagnostic.cpp
Ted Kremenek
kremenek at apple.com
Fri Mar 6 14:10:50 PST 2009
Author: kremenek
Date: Fri Mar 6 16:10:49 2009
New Revision: 66291
URL: http://llvm.org/viewvc/llvm-project?rev=66291&view=rev
Log:
Start work on subclassing PathDiagnosticPiece to distinguish more between control-flow pieces, events, etc.
Modified:
cfe/trunk/include/clang/Analysis/PathDiagnostic.h
cfe/trunk/lib/Analysis/PathDiagnostic.cpp
Modified: cfe/trunk/include/clang/Analysis/PathDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathDiagnostic.h?rev=66291&r1=66290&r2=66291&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathDiagnostic.h (original)
+++ cfe/trunk/include/clang/Analysis/PathDiagnostic.h Fri Mar 6 16:10:49 2009
@@ -26,7 +26,7 @@
class PathDiagnosticPiece {
public:
- enum Kind { ControlFlow, Event };
+ enum Kind { ControlFlow, Event, Macro };
enum DisplayHint { Above, Below };
private:
@@ -36,6 +36,7 @@
const Kind kind;
const DisplayHint Hint;
std::vector<SourceRange> ranges;
+ std::vector<PathDiagnosticPiece*> SubPieces;
// Do not implement:
PathDiagnosticPiece();
@@ -44,15 +45,17 @@
public:
PathDiagnosticPiece(FullSourceLoc pos, const std::string& s,
- Kind k = Event,
- DisplayHint hint = Above);
+ Kind k = Event, DisplayHint hint = Below);
PathDiagnosticPiece(FullSourceLoc pos, const char* s,
- Kind k = Event,
- DisplayHint hint = Above);
+ Kind k = Event, DisplayHint hint = Below);
+
+ virtual ~PathDiagnosticPiece();
const std::string& getString() const { return str; }
-
+
+ /// getDisplayHint - Return a hint indicating where the diagnostic should
+ /// be displayed by the PathDiagnosticClient.
DisplayHint getDisplayHint() const { return Hint; }
Kind getKind() const { return kind; }
@@ -95,6 +98,24 @@
FullSourceLoc getLocation() const { return Pos; }
};
+class PathDiagnosticMacroPiece : public PathDiagnosticPiece {
+ std::vector<PathDiagnosticPiece*> SubPieces;
+public:
+ PathDiagnosticMacroPiece(FullSourceLoc pos, const std::string& s)
+ : PathDiagnosticPiece(pos, s, Macro) {}
+
+ PathDiagnosticMacroPiece(FullSourceLoc pos, const char* s)
+ : PathDiagnosticPiece(pos, s, Macro) {}
+
+ ~PathDiagnosticMacroPiece();
+
+ void push_back(PathDiagnosticPiece* P) { SubPieces.push_back(P); }
+
+ typedef std::vector<PathDiagnosticPiece*>::iterator iterator;
+ iterator begin() { return SubPieces.begin(); }
+ iterator end() { return SubPieces.end(); }
+};
+
class PathDiagnostic {
std::list<PathDiagnosticPiece*> path;
unsigned Size;
Modified: cfe/trunk/lib/Analysis/PathDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/PathDiagnostic.cpp?rev=66291&r1=66290&r2=66291&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/PathDiagnostic.cpp (original)
+++ cfe/trunk/lib/Analysis/PathDiagnostic.cpp Fri Mar 6 16:10:49 2009
@@ -49,6 +49,12 @@
"PathDiagnosticPiece's must have a valid location.");
}
+PathDiagnosticPiece::~PathDiagnosticPiece() {}
+
+PathDiagnosticMacroPiece::~PathDiagnosticMacroPiece() {
+ for (iterator I = begin(), E = end(); I != E; ++I) delete *I;
+}
+
PathDiagnostic::PathDiagnostic() : Size(0) {}
PathDiagnostic::~PathDiagnostic() {
More information about the cfe-commits
mailing list