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.

llvm-svn: 238994
This commit is contained in:
Justin Bogner 2015-06-04 00:30:22 +00:00
parent d7112c391c
commit 90e8e2c586
2 changed files with 23 additions and 5 deletions

View File

@ -55,14 +55,14 @@ TYPE("objective-c++", ObjCXX, PP_ObjCXX, "mm", "u")
// 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")

View File

@ -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"