[cfe-commits] r140206 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h lib/StaticAnalyzer/Core/PathDiagnostic.cpp
Anna Zaks
ganna at apple.com
Tue Sep 20 16:27:32 PDT 2011
Author: zaks
Date: Tue Sep 20 18:27:32 2011
New Revision: 140206
URL: http://llvm.org/viewvc/llvm-project?rev=140206&view=rev
Log:
[analyzer] Refactor PathDiagnosticLocation: Remove SourceRange member from PathDiagnosticLocation - FullSourceLoc Loc and PathDiagnosticRange Range are sufficient.
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h?rev=140206&r1=140205&r2=140206&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h Tue Sep 20 18:27:32 2011
@@ -95,7 +95,6 @@
class PathDiagnosticLocation {
private:
enum Kind { RangeK, SingleLocK, StmtK, DeclK } K;
- SourceRange R;
const Stmt *S;
const Decl *D;
const SourceManager *SM;
@@ -104,14 +103,16 @@
PathDiagnosticLocation(SourceLocation L, const SourceManager &sm,
Kind kind)
- : K(kind), R(L, L), S(0), D(0), SM(&sm),
- Loc(genLocation()), Range(genRange()) {
- }
+ : K(kind), S(0), D(0), SM(&sm),
+ Loc(genLocation(L)), Range(genRange(L)) {}
FullSourceLoc
- genLocation(LocationOrAnalysisContext LAC = (AnalysisContext*)0) const;
+ genLocation(SourceLocation L = SourceLocation(),
+ LocationOrAnalysisContext LAC = (AnalysisContext*)0) const;
+
PathDiagnosticRange
- genRange(LocationOrAnalysisContext LAC = (AnalysisContext*)0) const;
+ genRange(SourceLocation L = SourceLocation(),
+ LocationOrAnalysisContext LAC = (AnalysisContext*)0) const;
public:
/// Create an invalid location.
@@ -124,7 +125,8 @@
const SourceManager &sm,
LocationOrAnalysisContext lac)
: K(StmtK), S(s), D(0), SM(&sm),
- Loc(genLocation(lac)), Range(genRange(lac)) {}
+ Loc(genLocation(SourceLocation(), lac)),
+ Range(genRange(SourceLocation(), lac)) {}
/// Create a location corresponding to the given declaration.
@@ -192,7 +194,7 @@
const PathDiagnosticLocation &PDL);
bool operator==(const PathDiagnosticLocation &X) const {
- return K == X.K && R == X.R && S == X.S && D == X.D;
+ return K == X.K && Loc == X.Loc && Range == X.Range;
}
bool operator!=(const PathDiagnosticLocation &X) const {
Modified: cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp?rev=140206&r1=140205&r2=140206&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp Tue Sep 20 18:27:32 2011
@@ -228,7 +228,7 @@
}
FullSourceLoc
- PathDiagnosticLocation::genLocation(LocationOrAnalysisContext LAC) const {
+ PathDiagnosticLocation::genLocation(SourceLocation L, LocationOrAnalysisContext LAC) const {
assert(isValid());
// Note that we want a 'switch' here so that the compiler can warn us in
// case we add more cases.
@@ -243,17 +243,17 @@
return FullSourceLoc(D->getLocation(), const_cast<SourceManager&>(*SM));
}
- return FullSourceLoc(R.getBegin(), const_cast<SourceManager&>(*SM));
+ return FullSourceLoc(L, const_cast<SourceManager&>(*SM));
}
PathDiagnosticRange
- PathDiagnosticLocation::genRange(LocationOrAnalysisContext LAC) const {
+ PathDiagnosticLocation::genRange(SourceLocation L, LocationOrAnalysisContext LAC) const {
assert(isValid());
// Note that we want a 'switch' here so that the compiler can warn us in
// case we add more cases.
switch (K) {
case SingleLocK:
- return PathDiagnosticRange(R, true);
+ return PathDiagnosticRange(SourceRange(L,L), true);
case RangeK:
break;
case StmtK: {
@@ -302,19 +302,16 @@
}
}
- return R;
+ return SourceRange(L,L);
}
void PathDiagnosticLocation::flatten() {
if (K == StmtK) {
- R = asRange();
K = RangeK;
S = 0;
D = 0;
}
else if (K == DeclK) {
- SourceLocation L = D->getLocation();
- R = SourceRange(L, L);
K = SingleLocK;
S = 0;
D = 0;
More information about the cfe-commits
mailing list