[analyzer] Refactor PathDiagnosticLocation: Remove SourceRange member from PathDiagnosticLocation - FullSourceLoc Loc and PathDiagnosticRange Range are sufficient.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140206 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Anna Zaks 2011-09-20 23:27:32 +00:00
Родитель c20f399889
Коммит ef70724e66
2 изменённых файлов: 15 добавлений и 16 удалений

Просмотреть файл

@ -95,7 +95,6 @@ typedef llvm::PointerUnion<const LocationContext*, AnalysisContext*>
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 @@ private:
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 @@ public:
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 @@ public:
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 {

Просмотреть файл

@ -228,7 +228,7 @@ PathDiagnosticLocation PathDiagnosticLocation::createSingleLocation(
}
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 @@ FullSourceLoc
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 @@ PathDiagnosticRange
}
}
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;