Permalink
Browse files

Prevent segmentation fault

  • Loading branch information...
1 parent 661ca34 commit 744238644089f7b668756626977f9981b91c7ccf @pukkaone committed Apr 18, 2011
Showing with 13 additions and 2 deletions.
  1. +2 −0 .gitignore
  2. +11 −2 src/UnnecessaryIncludeFinder.cpp
View
2 .gitignore
@@ -1 +1,3 @@
build
+debug
+release
View
13 src/UnnecessaryIncludeFinder.cpp
@@ -231,11 +231,18 @@ UnnecessaryIncludeFinder::markUsed (
}
FileID declarationFileID = sourceManager_.getFileID(declarationLocation);
+ if (sourceManager_.getSLocEntry(declarationFileID).isFile() == false) {
+ return;
+ }
+
if (declarationFileID != sourceManager_.getMainFileID()) {
const FileEntry* pFile = sourceManager_.getFileEntryForID(
declarationFileID);
- UsedHeaders::key_type fileName(pFile->getName());
+ if (pFile == 0) {
+ return;
+ }
+ UsedHeaders::key_type fileName(pFile->getName());
pMainSource_->usedHeaders_.insert(fileName);
action_.allUsedHeaders_.insert(fileName);
}
@@ -396,7 +403,9 @@ UnnecessaryIncludeFinder::VisitMemberExpr (MemberExpr* pExpr)
bool
UnnecessaryIncludeFinder::VisitCXXMemberCallExpr (CXXMemberCallExpr* pExpr)
{
- markUsed(pExpr->getMethodDecl()->getLocation(), pExpr->getExprLoc());
+ if (pExpr->getMethodDecl() != 0) {
+ markUsed(pExpr->getMethodDecl()->getLocation(), pExpr->getExprLoc());
+ }
return true;
}

0 comments on commit 7442386

Please sign in to comment.