Teach SourceManager::getPresumedLoc() how to fail gracefully if getLineNumber/getColumnNumber fail

llvm-svn: 117990
This commit is contained in:
Douglas Gregor 2010-11-02 00:39:22 +00:00
parent b3ca2060c0
commit 75f26d6c75
2 changed files with 9 additions and 3 deletions

View File

@ -1058,8 +1058,14 @@ PresumedLoc SourceManager::getPresumedLoc(SourceLocation Loc) const {
Filename = C->Entry->getName();
else
Filename = C->getBuffer(Diag, *this)->getBufferIdentifier();
unsigned LineNo = getLineNumber(LocInfo.first, LocInfo.second);
unsigned ColNo = getColumnNumber(LocInfo.first, LocInfo.second);
bool Invalid = false;
unsigned LineNo = getLineNumber(LocInfo.first, LocInfo.second, &Invalid);
if (Invalid)
return PresumedLoc();
unsigned ColNo = getColumnNumber(LocInfo.first, LocInfo.second, &Invalid);
if (Invalid)
return PresumedLoc();
SourceLocation IncludeLoc = FI.getIncludeLoc();
// If we have #line directives in this file, update and overwrite the physical

View File

@ -781,7 +781,7 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level,
}
// Compute the column number.
if (DiagOpts->ShowLocation) {
if (DiagOpts->ShowLocation && PLoc.isValid()) {
if (DiagOpts->ShowColors)
OS.changeColor(savedColor, true);