forked from OSchip/llvm-project
Teach SourceManager::getPresumedLoc() how to fail gracefully if getLineNumber/getColumnNumber fail
llvm-svn: 117990
This commit is contained in:
parent
b3ca2060c0
commit
75f26d6c75
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue