diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-11-12 07:15:47 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-11-12 07:15:47 +0000 |
commit | cb7b1e17b63967317ab5cc55682168cf0380519a (patch) | |
tree | ae64d4fe18e56974c3aae2c99e86aa954410ccdb /lib/Checker/AnalyzerStatsChecker.cpp | |
parent | 8f0889ce457db51d3af1eb1245bceee272d4dc7d (diff) |
Make sure to always check the result of
SourceManager::getPresumedLoc(), so that we don't try to make use of
an invalid presumed location. Doing so can cause crashes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118885 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Checker/AnalyzerStatsChecker.cpp')
-rw-r--r-- | lib/Checker/AnalyzerStatsChecker.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/Checker/AnalyzerStatsChecker.cpp b/lib/Checker/AnalyzerStatsChecker.cpp index 9badb79625..c484537e95 100644 --- a/lib/Checker/AnalyzerStatsChecker.cpp +++ b/lib/Checker/AnalyzerStatsChecker.cpp @@ -83,16 +83,18 @@ void AnalyzerStatsChecker::VisitEndAnalysis(ExplodedGraph &G, llvm::SmallString<128> buf; llvm::raw_svector_ostream output(buf); PresumedLoc Loc = SM.getPresumedLoc(D->getLocation()); - output << Loc.getFilename() << " : "; + if (Loc.isValid()) { + output << Loc.getFilename() << " : "; - if (isa<FunctionDecl>(D) || isa<ObjCMethodDecl>(D)) { - const NamedDecl *ND = cast<NamedDecl>(D); - output << ND; - } - else if (isa<BlockDecl>(D)) { - output << "block(line:" << Loc.getLine() << ":col:" << Loc.getColumn(); + if (isa<FunctionDecl>(D) || isa<ObjCMethodDecl>(D)) { + const NamedDecl *ND = cast<NamedDecl>(D); + output << ND; + } + else if (isa<BlockDecl>(D)) { + output << "block(line:" << Loc.getLine() << ":col:" << Loc.getColumn(); + } } - + output << " -> Total CFGBlocks: " << total << " | Unreachable CFGBlocks: " << unreachable << " | Aborted Block: " << (Eng.wasBlockAborted() ? "yes" : "no") |