diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-03-06 22:10:49 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-03-06 22:10:49 +0000 |
commit | 4e06387c2d6d00c7a30167d4c2206756992dde38 (patch) | |
tree | b4396a19c5b947cbda75a3aef3a937b4c6065fdb | |
parent | 9540717470121f8912c72f6d8ae4ab40a6e45c94 (diff) |
Start work on subclassing PathDiagnosticPiece to distinguish more between control-flow pieces, events, etc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66291 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Analysis/PathDiagnostic.h | 33 | ||||
-rw-r--r-- | lib/Analysis/PathDiagnostic.cpp | 6 |
2 files changed, 33 insertions, 6 deletions
diff --git a/include/clang/Analysis/PathDiagnostic.h b/include/clang/Analysis/PathDiagnostic.h index 3096859203..731bb74422 100644 --- a/include/clang/Analysis/PathDiagnostic.h +++ b/include/clang/Analysis/PathDiagnostic.h @@ -26,7 +26,7 @@ namespace clang { class PathDiagnosticPiece { public: - enum Kind { ControlFlow, Event }; + enum Kind { ControlFlow, Event, Macro }; enum DisplayHint { Above, Below }; private: @@ -36,6 +36,7 @@ private: const Kind kind; const DisplayHint Hint; std::vector<SourceRange> ranges; + std::vector<PathDiagnosticPiece*> SubPieces; // Do not implement: PathDiagnosticPiece(); @@ -44,15 +45,17 @@ private: 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 @@ public: 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; diff --git a/lib/Analysis/PathDiagnostic.cpp b/lib/Analysis/PathDiagnostic.cpp index 468b6c89f2..49af34dc1c 100644 --- a/lib/Analysis/PathDiagnostic.cpp +++ b/lib/Analysis/PathDiagnostic.cpp @@ -49,6 +49,12 @@ PathDiagnosticPiece::PathDiagnosticPiece(FullSourceLoc pos, "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() { |