summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
diff options
context:
space:
mode:
authorGeorge Karpenkov <ekarpenkov@apple.com>2018-09-07 00:43:17 +0000
committerGeorge Karpenkov <ekarpenkov@apple.com>2018-09-07 00:43:17 +0000
commit55e3d1ec353a5849a0c3da72faa44cec6d528dfa (patch)
treeaf36bc77bf3c821a4485ab26955d7ecf93a1ed7a /clang/lib/StaticAnalyzer/Core/BugReporter.cpp
parent5f8d361c9cb718a1001d52442bdf88cd046b6174 (diff)
downloadbcm5719-llvm-55e3d1ec353a5849a0c3da72faa44cec6d528dfa.tar.gz
bcm5719-llvm-55e3d1ec353a5849a0c3da72faa44cec6d528dfa.zip
[analyzer] Do not add invalid source location to the coverage information
Invalid source locations may arise from generated code. Differential Revision: https://reviews.llvm.org/D51761 llvm-svn: 341618
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/BugReporter.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/BugReporter.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
index 19e9b4af900..4e0a0d5045e 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -1892,6 +1892,7 @@ static void updateExecutedLinesWithDiagnosticPieces(
FullSourceLoc Loc = P->getLocation().asLocation().getExpansionLoc();
FileID FID = Loc.getFileID();
unsigned LineNo = Loc.getLineNumber();
+ assert(FID.isValid());
ExecutedLines[FID.getHashValue()].insert(LineNo);
}
}
@@ -3022,6 +3023,8 @@ static void populateExecutedLinesWithFunctionSignature(
SourceLocation Start = SignatureSourceRange.getBegin();
SourceLocation End = Body ? Body->getSourceRange().getBegin()
: SignatureSourceRange.getEnd();
+ if (!Start.isValid() || !End.isValid())
+ return;
unsigned StartLine = SM.getExpansionLineNumber(Start);
unsigned EndLine = SM.getExpansionLineNumber(End);
@@ -3034,6 +3037,8 @@ static void populateExecutedLinesWithStmt(
const Stmt *S, SourceManager &SM,
std::unique_ptr<FilesToLineNumsMap> &ExecutedLines) {
SourceLocation Loc = S->getSourceRange().getBegin();
+ if (!Loc.isValid())
+ return;
SourceLocation ExpansionLoc = SM.getExpansionLoc(Loc);
FileID FID = SM.getFileID(ExpansionLoc);
unsigned LineNo = SM.getExpansionLineNumber(ExpansionLoc);
OpenPOWER on IntegriCloud