summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2011-09-20 01:51:40 +0000
committerAnna Zaks <ganna@apple.com>2011-09-20 01:51:40 +0000
commitb490c4bb01a5a3a86947851fa66823dda32ed012 (patch)
tree6c4e7cf1dbbd8ca367de18e331567e354570b1a7 /include
parent1531bb0c69d9afff6a6434e4cadf345eb628b287 (diff)
downloadclang-b490c4bb01a5a3a86947851fa66823dda32ed012.tar.gz
[analyzer] Refactor PathDiagnosticLocation: Pre-compute Range and Location with gen methods on object creation instead of computing on demand. This would allow to remove dependency on the other members which help with construction and might not even be valid at later stages (to be removed later on).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140131 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h39
1 files changed, 30 insertions, 9 deletions
diff --git a/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h b/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
index 1b16ec50a0..0e6b75278b 100644
--- a/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
+++ b/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
@@ -27,6 +27,7 @@ class BinaryOperator;
class CompoundStmt;
class Decl;
class LocationContext;
+class ParentMap;
class ProgramPoint;
class SourceManager;
class Stmt;
@@ -79,10 +80,12 @@ protected:
class PathDiagnosticRange : public SourceRange {
public:
- const bool isPoint;
+ bool isPoint;
PathDiagnosticRange(const SourceRange &R, bool isP = false)
: SourceRange(R), isPoint(isP) {}
+
+ PathDiagnosticRange() : isPoint(false) {}
};
class PathDiagnosticLocation {
@@ -93,24 +96,36 @@ private:
const Decl *D;
const SourceManager *SM;
const LocationContext *LC;
+ FullSourceLoc Loc;
+ PathDiagnosticRange Range;
+
+ FullSourceLoc genLocation(const ParentMap *PM=0) const;
+ PathDiagnosticRange genRange(const ParentMap *PM=0) const;
+
public:
PathDiagnosticLocation()
- : K(SingleLocK), S(0), D(0), SM(0), LC(0) {}
+ : K(SingleLocK), S(0), D(0), SM(0), LC(0) {
+ }
PathDiagnosticLocation(FullSourceLoc L)
- : K(SingleLocK), R(L, L), S(0), D(0), SM(&L.getManager()), LC(0) {}
+ : K(SingleLocK), R(L, L), S(0), D(0), SM(&L.getManager()), LC(0),
+ Loc(genLocation()), Range(genRange()) {
+ }
PathDiagnosticLocation(SourceLocation L, const SourceManager &sm,
Kind kind = SingleLocK)
- : K(kind), R(L, L), S(0), D(0), SM(&sm), LC(0) {}
+ : K(kind), R(L, L), S(0), D(0), SM(&sm), LC(0),
+ Loc(genLocation()), Range(genRange()) {
+ }
PathDiagnosticLocation(const Stmt *s,
const SourceManager &sm,
- const LocationContext *lc)
- : K(StmtK), S(s), D(0), SM(&sm), LC(lc) {}
+ const LocationContext *lc);
PathDiagnosticLocation(const Decl *d, const SourceManager &sm)
- : K(DeclK), S(0), D(d), SM(&sm), LC(0) {}
+ : K(DeclK), S(0), D(d), SM(&sm), LC(0),
+ Loc(genLocation()), Range(genRange()) {
+ }
// Create a location for the beginning of the statement.
static PathDiagnosticLocation createBeginStmt(const Stmt *S,
@@ -167,8 +182,14 @@ public:
return SM != 0;
}
- FullSourceLoc asLocation() const;
- PathDiagnosticRange asRange() const;
+ FullSourceLoc asLocation() const {
+ return Loc;
+ }
+
+ PathDiagnosticRange asRange() const {
+ return Range;
+ }
+
const Stmt *asStmt() const { assert(isValid()); return S; }
const Decl *asDecl() const { assert(isValid()); return D; }