[cfe-commits] r130909 - in /cfe/trunk: lib/Frontend/LogDiagnosticPrinter.cpp test/Driver/cc-log-diagnostics.c

Daniel Dunbar daniel at zuster.org
Wed May 4 19:12:02 PDT 2011


Author: ddunbar
Date: Wed May  4 21:12:02 2011
New Revision: 130909

URL: http://llvm.org/viewvc/llvm-project?rev=130909&view=rev
Log:
Frontend: Fix a crash in CC_LOG_DIAGNOSTICS handling.

Modified:
    cfe/trunk/lib/Frontend/LogDiagnosticPrinter.cpp
    cfe/trunk/test/Driver/cc-log-diagnostics.c

Modified: cfe/trunk/lib/Frontend/LogDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/LogDiagnosticPrinter.cpp?rev=130909&r1=130908&r2=130909&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/LogDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/LogDiagnosticPrinter.cpp Wed May  4 21:12:02 2011
@@ -99,7 +99,7 @@
   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 @@
   // 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());
 

Modified: cfe/trunk/test/Driver/cc-log-diagnostics.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cc-log-diagnostics.c?rev=130909&r1=130908&r2=130909&view=diff
==============================================================================
--- cfe/trunk/test/Driver/cc-log-diagnostics.c (original)
+++ cfe/trunk/test/Driver/cc-log-diagnostics.c Wed May  4 21:12:02 2011
@@ -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 @@
 // 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>





More information about the cfe-commits mailing list