aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2011-09-21 00:35:58 +0000
committerAnna Zaks <ganna@apple.com>2011-09-21 00:35:58 +0000
commit09ca9ef5f92cf4375a19bf7a80d571779c9f370f (patch)
tree7b5a227d08733b2a27d064e6e6cee94ea25a3452 /lib/StaticAnalyzer/Core/PathDiagnostic.cpp
parent5b76f373d23cc3b292ecf523349aaaa388eea375 (diff)
[analyzer] Fix a bug where PathDiagnosticLocation did not generate a valid range and add asserts to check validity of locations early on. Ignore invalid ranges in PathDiagnosticPiece (they could be added by checker writers).
Addresses radar://10124836 and radar://radar10102244. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140218 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/PathDiagnostic.cpp')
-rw-r--r--lib/StaticAnalyzer/Core/PathDiagnostic.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/StaticAnalyzer/Core/PathDiagnostic.cpp b/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
index 6fbfddbfd7..76acfc2e31 100644
--- a/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ b/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -228,7 +228,8 @@ PathDiagnosticLocation PathDiagnosticLocation::createSingleLocation(
}
FullSourceLoc
- PathDiagnosticLocation::genLocation(SourceLocation L, 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.
@@ -247,13 +248,13 @@ FullSourceLoc
}
PathDiagnosticRange
- PathDiagnosticLocation::genRange(SourceLocation L, LocationOrAnalysisContext LAC) const {
+ PathDiagnosticLocation::genRange(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(SourceRange(L,L), true);
+ return PathDiagnosticRange(SourceRange(Loc,Loc), true);
case RangeK:
break;
case StmtK: {
@@ -286,8 +287,10 @@ PathDiagnosticRange
return SourceRange(L, L);
}
}
-
- return S->getSourceRange();
+ SourceRange R = S->getSourceRange();
+ if (R.isValid())
+ return R;
+ break;
}
case DeclK:
if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D))
@@ -302,7 +305,7 @@ PathDiagnosticRange
}
}
- return SourceRange(L,L);
+ return SourceRange(Loc,Loc);
}
void PathDiagnosticLocation::flatten() {