aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/DiagnosticRenderer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Frontend/DiagnosticRenderer.cpp')
-rw-r--r--clang/lib/Frontend/DiagnosticRenderer.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Frontend/DiagnosticRenderer.cpp b/clang/lib/Frontend/DiagnosticRenderer.cpp
index 22b957988f46..0afc8f3b1dab 100644
--- a/clang/lib/Frontend/DiagnosticRenderer.cpp
+++ b/clang/lib/Frontend/DiagnosticRenderer.cpp
@@ -394,6 +394,13 @@ mapDiagnosticRanges(FullSourceLoc CaretLoc, ArrayRef<CharSourceRange> Ranges,
}
}
+ // There is a chance that begin or end is invalid here, for example if
+ // specific compile error is reported.
+ // It is possible that the FileID's do not match, if one comes from an
+ // included file. In this case we can not produce a meaningful source range.
+ if (Begin.isInvalid() || End.isInvalid() || BeginFileID != EndFileID)
+ continue;
+
// Do the backtracking.
SmallVector<FileID, 4> CommonArgExpansions;
computeCommonMacroArgExpansionFileIDs(Begin, End, SM, CommonArgExpansions);