diff options
-rw-r--r-- | lib/Frontend/LogDiagnosticPrinter.cpp | 4 | ||||
-rw-r--r-- | test/Driver/cc-log-diagnostics.c | 12 |
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/Frontend/LogDiagnosticPrinter.cpp b/lib/Frontend/LogDiagnosticPrinter.cpp index 954bad4e7c..78eb1b2128 100644 --- a/lib/Frontend/LogDiagnosticPrinter.cpp +++ b/lib/Frontend/LogDiagnosticPrinter.cpp @@ -99,7 +99,7 @@ void LogDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, DiagnosticClient::HandleDiagnostic(Level, Info); // Initialize the main file name, if we haven't already fetched it. - if (MainFilename.empty()) { + if (MainFilename.empty() && Info.hasSourceManager()) { const SourceManager &SM = Info.getSourceManager(); FileID FID = SM.getMainFileID(); if (!FID.isInvalid()) { @@ -122,7 +122,7 @@ void LogDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, // Set the location information. DE.Filename = ""; DE.Line = DE.Column = 0; - if (Info.getLocation().isValid()) { + if (Info.getLocation().isValid() && Info.hasSourceManager()) { const SourceManager &SM = Info.getSourceManager(); PresumedLoc PLoc = SM.getPresumedLoc(Info.getLocation()); diff --git a/test/Driver/cc-log-diagnostics.c b/test/Driver/cc-log-diagnostics.c index a70686ad61..6c1b8ed896 100644 --- a/test/Driver/cc-log-diagnostics.c +++ b/test/Driver/cc-log-diagnostics.c @@ -1,7 +1,7 @@ +// RUN: rm -f %t.log // RUN: env RC_DEBUG_OPTIONS=1 \ -// RUN: CC_LOG_DIAGNOSTICS=1 \ -// RUN: CC_LOG_DIAGNOSTICS_FILE=%t.log \ -// RUN: %clang -no-canonical-prefixes -ccc-host-triple x86_64-apple-darwin10 -fsyntax-only %s +// RUN: CC_LOG_DIAGNOSTICS=1 CC_LOG_DIAGNOSTICS_FILE=%t.log \ +// RUN: %clang -Wfoobar -no-canonical-prefixes -ccc-host-triple x86_64-apple-darwin10 -fsyntax-only %s // RUN: FileCheck %s < %t.log int f0() {} @@ -16,6 +16,12 @@ int f0() {} // CHECK: <dict> // CHECK: <key>level</key> // CHECK: <string>warning</string> +// CHECK: <key>message</key> +// CHECK: <string>unknown warning option '-Wfoobar'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>level</key> +// CHECK: <string>warning</string> // CHECK: <key>filename</key> // CHECK: <string>{{.*}}cc-log-diagnostics.c</string> // CHECK: <key>line</key> |