summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2012-01-10 15:26:13 +0000
committerTed Kremenek <kremenek@apple.com>2012-01-10 15:26:13 +0000
commitc07e34ceedaab7e4cdfab5a62820f24168392004 (patch)
tree5f056971352b21f6d8441c3f8b0658d0e9299ed6
parenta04d2b333055a342f419b8aa8a88fd47fc4e75df (diff)
downloadbcm5719-llvm-c07e34ceedaab7e4cdfab5a62820f24168392004.tar.gz
bcm5719-llvm-c07e34ceedaab7e4cdfab5a62820f24168392004.zip
Make PathDiagnosticLocation more resilient to null Stmt pointers.
llvm-svn: 147854
-rw-r--r--clang/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h2
-rw-r--r--clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp6
2 files changed, 8 insertions, 0 deletions
diff --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h b/clang/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
index 23a1635788e..fba5692d05e 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
@@ -129,6 +129,7 @@ public:
: K(StmtK), S(s), D(0), SM(&sm),
Loc(genLocation(SourceLocation(), lac)),
Range(genRange(lac)) {
+ assert(S);
assert(Loc.isValid());
assert(Range.isValid());
}
@@ -137,6 +138,7 @@ public:
PathDiagnosticLocation(const Decl *d, const SourceManager &sm)
: K(DeclK), S(0), D(d), SM(&sm),
Loc(genLocation()), Range(genRange()) {
+ assert(D);
assert(Loc.isValid());
assert(Range.isValid());
}
diff --git a/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp b/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
index 50ebe3b7466..e398bae60fc 100644
--- a/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ b/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -237,9 +237,15 @@ FullSourceLoc
case RangeK:
break;
case StmtK:
+ // Defensive checking.
+ if (!S)
+ break;
return FullSourceLoc(getValidSourceLocation(S, LAC),
const_cast<SourceManager&>(*SM));
case DeclK:
+ // Defensive checking.
+ if (!D)
+ break;
return FullSourceLoc(D->getLocation(), const_cast<SourceManager&>(*SM));
}
OpenPOWER on IntegriCloud