[cfe-commits] r117990 - in /cfe/trunk/lib: Basic/SourceManager.cpp Frontend/TextDiagnosticPrinter.cpp
Douglas Gregor
dgregor at apple.com
Mon Nov 1 17:39:22 PDT 2010
Author: dgregor
Date: Mon Nov 1 19:39:22 2010
New Revision: 117990
URL: http://llvm.org/viewvc/llvm-project?rev=117990&view=rev
Log:
Teach SourceManager::getPresumedLoc() how to fail gracefully if getLineNumber/getColumnNumber fail
Modified:
cfe/trunk/lib/Basic/SourceManager.cpp
cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=117990&r1=117989&r2=117990&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Mon Nov 1 19:39:22 2010
@@ -1058,8 +1058,14 @@
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
Modified: cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp?rev=117990&r1=117989&r2=117990&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp Mon Nov 1 19:39:22 2010
@@ -781,7 +781,7 @@
}
// Compute the column number.
- if (DiagOpts->ShowLocation) {
+ if (DiagOpts->ShowLocation && PLoc.isValid()) {
if (DiagOpts->ShowColors)
OS.changeColor(savedColor, true);
More information about the cfe-commits
mailing list