[cfe-commits] r66304 - /cfe/trunk/include/clang/Analysis/PathDiagnostic.h
Ted Kremenek
kremenek at apple.com
Fri Mar 6 15:21:37 PST 2009
Author: kremenek
Date: Fri Mar 6 17:21:37 2009
New Revision: 66304
URL: http://llvm.org/viewvc/llvm-project?rev=66304&view=rev
Log:
Re-order contents of file. No functionality change.
Modified:
cfe/trunk/include/clang/Analysis/PathDiagnostic.h
Modified: cfe/trunk/include/clang/Analysis/PathDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathDiagnostic.h?rev=66304&r1=66303&r2=66304&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathDiagnostic.h (original)
+++ cfe/trunk/include/clang/Analysis/PathDiagnostic.h Fri Mar 6 17:21:37 2009
@@ -24,98 +24,30 @@
namespace clang {
-class PathDiagnosticPiece {
-public:
- enum Kind { ControlFlow, Event, Macro };
- enum DisplayHint { Above, Below };
+//===----------------------------------------------------------------------===//
+// High-level interface for handlers of path-sensitive diagnostics.
+//===----------------------------------------------------------------------===//
-private:
- const FullSourceLoc Pos;
- const std::string str;
- std::vector<CodeModificationHint> CodeModificationHints;
- const Kind kind;
- const DisplayHint Hint;
- std::vector<SourceRange> ranges;
- std::vector<PathDiagnosticPiece*> SubPieces;
- // Do not implement:
- PathDiagnosticPiece();
- PathDiagnosticPiece(const PathDiagnosticPiece &P);
- PathDiagnosticPiece& operator=(const PathDiagnosticPiece &P);
+class PathDiagnostic;
+class PathDiagnosticClient : public DiagnosticClient {
public:
- PathDiagnosticPiece(FullSourceLoc pos, const std::string& s,
- Kind k = Event, DisplayHint hint = Below);
-
- PathDiagnosticPiece(FullSourceLoc pos, const char* s,
- 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; }
-
- void addRange(SourceRange R) { ranges.push_back(R); }
+ PathDiagnosticClient() {}
+ virtual ~PathDiagnosticClient() {}
- void addRange(SourceLocation B, SourceLocation E) {
- ranges.push_back(SourceRange(B,E));
- }
+ virtual void HandleDiagnostic(Diagnostic::Level DiagLevel,
+ const DiagnosticInfo &Info);
- void addCodeModificationHint(const CodeModificationHint& Hint) {
- CodeModificationHints.push_back(Hint);
- }
-
- typedef const SourceRange* range_iterator;
+ virtual void HandlePathDiagnostic(const PathDiagnostic* D) = 0;
+};
- range_iterator ranges_begin() const {
- return ranges.empty() ? NULL : &ranges[0];
- }
+//===----------------------------------------------------------------------===//
+// Path-sensitive diagnostics.
+//===----------------------------------------------------------------------===//
- range_iterator ranges_end() const {
- return ranges_begin() + ranges.size();
- }
+class PathDiagnosticPiece;
- typedef const CodeModificationHint *code_modifications_iterator;
-
- code_modifications_iterator code_modifications_begin() const {
- return CodeModificationHints.empty()? 0 : &CodeModificationHints[0];
- }
-
- code_modifications_iterator code_modifications_end() const {
- return CodeModificationHints.empty()? 0
- : &CodeModificationHints[0] + CodeModificationHints.size();
- }
-
- const SourceManager& getSourceManager() const {
- return Pos.getManager();
- }
-
- 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;
@@ -131,9 +63,9 @@
PathDiagnostic(const std::string& bugtype, const std::string& desc,
const std::string& category);
-
+
~PathDiagnostic();
-
+
const std::string& getDescription() const { return Desc; }
const std::string& getBugType() const { return BugType; }
const std::string& getCategory() const { return Category; }
@@ -203,7 +135,7 @@
private:
ImplTy I;
-
+
public:
const_iterator(const ImplTy& i) : I(i) {}
@@ -216,13 +148,13 @@
const_iterator& operator++() { ++I; return *this; }
const_iterator& operator--() { --I; return *this; }
};
-
+
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
-
-
+
+
// forward iterator creation methods.
-
+
iterator begin() { return path.begin(); }
iterator end() { return path.end(); }
@@ -235,16 +167,101 @@
reverse_iterator rend() { return reverse_iterator(begin()); }
const_reverse_iterator rend() const { return const_reverse_iterator(begin());}
};
+
+//===----------------------------------------------------------------------===//
+// Path "pieces" for path-sensitive diagnostics.
+//===----------------------------------------------------------------------===//
+
+class PathDiagnosticPiece {
+public:
+ enum Kind { ControlFlow, Event, Macro };
+ enum DisplayHint { Above, Below };
+
+private:
+ const FullSourceLoc Pos;
+ const std::string str;
+ std::vector<CodeModificationHint> CodeModificationHints;
+ const Kind kind;
+ const DisplayHint Hint;
+ std::vector<SourceRange> ranges;
+ std::vector<PathDiagnosticPiece*> SubPieces;
+
+ // Do not implement:
+ PathDiagnosticPiece();
+ PathDiagnosticPiece(const PathDiagnosticPiece &P);
+ PathDiagnosticPiece& operator=(const PathDiagnosticPiece &P);
-class PathDiagnosticClient : public DiagnosticClient {
public:
- PathDiagnosticClient() {}
- virtual ~PathDiagnosticClient() {}
-
- virtual void HandleDiagnostic(Diagnostic::Level DiagLevel,
- const DiagnosticInfo &Info);
+ PathDiagnosticPiece(FullSourceLoc pos, const std::string& s,
+ Kind k = Event, DisplayHint hint = Below);
+
+ PathDiagnosticPiece(FullSourceLoc pos, const char* s,
+ 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; }
+
+ void addRange(SourceRange R) { ranges.push_back(R); }
+
+ void addRange(SourceLocation B, SourceLocation E) {
+ ranges.push_back(SourceRange(B,E));
+ }
+
+ void addCodeModificationHint(const CodeModificationHint& Hint) {
+ CodeModificationHints.push_back(Hint);
+ }
+
+ typedef const SourceRange* range_iterator;
+
+ range_iterator ranges_begin() const {
+ return ranges.empty() ? NULL : &ranges[0];
+ }
+
+ range_iterator ranges_end() const {
+ return ranges_begin() + ranges.size();
+ }
+
+ typedef const CodeModificationHint *code_modifications_iterator;
+
+ code_modifications_iterator code_modifications_begin() const {
+ return CodeModificationHints.empty()? 0 : &CodeModificationHints[0];
+ }
+
+ code_modifications_iterator code_modifications_end() const {
+ return CodeModificationHints.empty()? 0
+ : &CodeModificationHints[0] + CodeModificationHints.size();
+ }
+
+ const SourceManager& getSourceManager() const {
+ return Pos.getManager();
+ }
- virtual void HandlePathDiagnostic(const PathDiagnostic* D) = 0;
+ 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(); }
};
} //end clang namespace
More information about the cfe-commits
mailing list