r238994 - Driver: Don't crash when generating crash reports for *-header inputs

Justin Bogner mail at justinbogner.com
Wed Jun 3 17:30:23 PDT 2015


Author: bogner
Date: Wed Jun  3 19:30:22 2015
New Revision: 238994

URL: http://llvm.org/viewvc/llvm-project?rev=238994&view=rev
Log:
Driver: Don't crash when generating crash reports for *-header inputs

If we crash while handling headers, the crash report mechanism
currently tries to make a string out of a null pointer when it tries
to make up a file extension.

Map *-header input types to reasonable extensions to avoid this.

Added:
    cfe/trunk/test/Driver/crash-report-header.h
Modified:
    cfe/trunk/include/clang/Driver/Types.def

Modified: cfe/trunk/include/clang/Driver/Types.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Types.def?rev=238994&r1=238993&r2=238994&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Types.def (original)
+++ cfe/trunk/include/clang/Driver/Types.def Wed Jun  3 19:30:22 2015
@@ -55,14 +55,14 @@ TYPE("objective-c++",            ObjCXX,
 
 // C family input files to precompile.
 TYPE("c-header-cpp-output",      PP_CHeader,   INVALID,         "i",     "p")
-TYPE("c-header",                 CHeader,      PP_CHeader,      nullptr, "pu")
-TYPE("cl-header",                CLHeader,     PP_CHeader,      nullptr, "pu")
+TYPE("c-header",                 CHeader,      PP_CHeader,      "h",     "pu")
+TYPE("cl-header",                CLHeader,     PP_CHeader,      "h",     "pu")
 TYPE("objective-c-header-cpp-output", PP_ObjCHeader, INVALID,   "mi",    "p")
-TYPE("objective-c-header",       ObjCHeader,   PP_ObjCHeader,   nullptr, "pu")
+TYPE("objective-c-header",       ObjCHeader,   PP_ObjCHeader,   "h",     "pu")
 TYPE("c++-header-cpp-output",    PP_CXXHeader, INVALID,         "ii",    "p")
-TYPE("c++-header",               CXXHeader,    PP_CXXHeader,    nullptr, "pu")
+TYPE("c++-header",               CXXHeader,    PP_CXXHeader,    "hh",    "pu")
 TYPE("objective-c++-header-cpp-output", PP_ObjCXXHeader, INVALID, "mii", "p")
-TYPE("objective-c++-header",     ObjCXXHeader, PP_ObjCXXHeader, nullptr, "pu")
+TYPE("objective-c++-header",     ObjCXXHeader, PP_ObjCXXHeader, "h",     "pu")
 
 // Other languages.
 TYPE("ada",                      Ada,          INVALID,         nullptr, "u")

Added: cfe/trunk/test/Driver/crash-report-header.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/crash-report-header.h?rev=238994&view=auto
==============================================================================
--- cfe/trunk/test/Driver/crash-report-header.h (added)
+++ cfe/trunk/test/Driver/crash-report-header.h Wed Jun  3 19:30:22 2015
@@ -0,0 +1,18 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: not env TMPDIR="%t" TEMP="%t" TMP="%t" RC_DEBUG_OPTIONS=1 %clang -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: cat %t/crash-report-header-*.h | FileCheck --check-prefix=CHECKSRC "%s"
+// RUN: cat %t/crash-report-header-*.sh | FileCheck --check-prefix=CHECKSH "%s"
+// REQUIRES: crash-recovery
+
+// because of the glob (*.h, *.sh)
+// REQUIRES: shell
+
+#pragma clang __debug parser_crash
+// CHECK: Preprocessed source(s) and associated run script(s) are located at:
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.h
+FOO
+// CHECKSRC: FOO
+// CHECKSH: "-cc1"
+// CHECKSH: "-main-file-name" "crash-report-header.h"
+// CHECKSH: "crash-report-header-{{[^ ]*}}.h"





More information about the cfe-commits mailing list