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/AnalysisConsumer.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/AnalysisConsumer.cpp')
-rw-r--r-- | lib/Checker/AnalysisConsumer.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/Checker/AnalysisConsumer.cpp b/lib/Checker/AnalysisConsumer.cpp index e1591a6a64..16ad5a7ef1 100644 --- a/lib/Checker/AnalysisConsumer.cpp +++ b/lib/Checker/AnalysisConsumer.cpp @@ -143,19 +143,21 @@ public: SourceManager &SM = Mgr->getASTContext().getSourceManager(); PresumedLoc Loc = SM.getPresumedLoc(D->getLocation()); - llvm::errs() << "ANALYZE: " << Loc.getFilename(); + if (Loc.isValid()) { + llvm::errs() << "ANALYZE: " << Loc.getFilename(); - if (isa<FunctionDecl>(D) || isa<ObjCMethodDecl>(D)) { - const NamedDecl *ND = cast<NamedDecl>(D); - llvm::errs() << ' ' << ND << '\n'; - } - else if (isa<BlockDecl>(D)) { - llvm::errs() << ' ' << "block(line:" << Loc.getLine() << ",col:" - << Loc.getColumn() << '\n'; - } - else if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) { - Selector S = MD->getSelector(); - llvm::errs() << ' ' << S.getAsString(); + if (isa<FunctionDecl>(D) || isa<ObjCMethodDecl>(D)) { + const NamedDecl *ND = cast<NamedDecl>(D); + llvm::errs() << ' ' << ND << '\n'; + } + else if (isa<BlockDecl>(D)) { + llvm::errs() << ' ' << "block(line:" << Loc.getLine() << ",col:" + << Loc.getColumn() << '\n'; + } + else if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) { + Selector S = MD->getSelector(); + llvm::errs() << ' ' << S.getAsString(); + } } } |