forked from OSchip/llvm-project
accept 'clang++ -c a.pch -o a.o' to create PCH's object file
This way should be the same like with a.pcm for modules. An alternative way is 'clang++ -c empty.cpp -include-pch a.pch -o a.o -Xclang -building-pch-with-obj', which is what clang-cl's /Yc does internally. Differential Revision: https://reviews.llvm.org/D83716
This commit is contained in:
parent
706a4353e8
commit
3895466e2c
|
@ -141,7 +141,7 @@ bool types::isAcceptedByClang(ID Id) {
|
|||
case TY_CXXHeader: case TY_PP_CXXHeader:
|
||||
case TY_ObjCXXHeader: case TY_PP_ObjCXXHeader:
|
||||
case TY_CXXModule: case TY_PP_CXXModule:
|
||||
case TY_AST: case TY_ModuleFile:
|
||||
case TY_AST: case TY_ModuleFile: case TY_PCH:
|
||||
case TY_LLVM_IR: case TY_LLVM_BC:
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -2022,8 +2022,9 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
|
|||
// FIXME: Supporting '<lang>-header-cpp-output' would be useful.
|
||||
bool Preprocessed = XValue.consume_back("-cpp-output");
|
||||
bool ModuleMap = XValue.consume_back("-module-map");
|
||||
IsHeaderFile =
|
||||
!Preprocessed && !ModuleMap && XValue.consume_back("-header");
|
||||
IsHeaderFile = !Preprocessed && !ModuleMap &&
|
||||
XValue != "precompiled-header" &&
|
||||
XValue.consume_back("-header");
|
||||
|
||||
// Principal languages.
|
||||
DashX = llvm::StringSwitch<InputKind>(XValue)
|
||||
|
@ -2050,7 +2051,7 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
|
|||
DashX = llvm::StringSwitch<InputKind>(XValue)
|
||||
.Case("cpp-output", InputKind(Language::C).getPreprocessed())
|
||||
.Case("assembler-with-cpp", Language::Asm)
|
||||
.Cases("ast", "pcm",
|
||||
.Cases("ast", "pcm", "precompiled-header",
|
||||
InputKind(Language::Unknown, InputKind::Precompiled))
|
||||
.Case("ir", Language::LLVM_IR)
|
||||
.Default(Language::Unknown);
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
// RUN: rm -rf %t
|
||||
// RUN: mkdir -p %t
|
||||
|
||||
// Create PCH without codegen.
|
||||
// RUN: %clang -x c++-header %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-cg.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-CREATE
|
||||
// CHECK-PCH-CREATE: -emit-pch
|
||||
// CHECK-PCH-CREATE-NOT: -fmodules-codegen
|
||||
// CHECK-PCH-CREATE-NOT: -fmodules-debuginfo
|
||||
|
||||
// Create PCH with -fmodules-codegen.
|
||||
// RUN: %clang -x c++-header -Xclang -fmodules-codegen %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-cg.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-CODEGEN-CREATE
|
||||
// CHECK-PCH-CODEGEN-CREATE: -emit-pch
|
||||
// CHECK-PCH-CODEGEN-CREATE: -fmodules-codegen
|
||||
// CHECK-PCH-CODEGEN-CREATE: "-x" "c++-header"
|
||||
// CHECK-PCH-CODEGEN-CREATE-NOT: -fmodules-debuginfo
|
||||
|
||||
// Create PCH with -fmodules-debuginfo.
|
||||
// RUN: %clang -x c++-header -Xclang -fmodules-debuginfo %S/../Modules/Inputs/codegen-flags/foo.h -g -o %t/foo-di.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-DEBUGINFO-CREATE
|
||||
// CHECK-PCH-DEBUGINFO-CREATE: -emit-pch
|
||||
// CHECK-PCH-DEBUGINFO-CREATE: -fmodules-debuginfo
|
||||
// CHECK-PCH-DEBUGINFO-CREATE: "-x" "c++-header"
|
||||
// CHECK-PCH-DEBUGINFO-CREATE-NOT: -fmodules-codegen
|
||||
|
||||
// Create PCH's object file for -fmodules-codegen.
|
||||
// RUN: touch %t/foo-cg.pch
|
||||
// RUN: %clang -c %t/foo-cg.pch -o %t/foo-cg.o -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-CODEGEN-OBJ
|
||||
// CHECK-PCH-CODEGEN-OBJ: -emit-obj
|
||||
// CHECK-PCH-CODEGEN-OBJ: "-main-file-name" "foo-cg.pch"
|
||||
// CHECK-PCH-CODEGEN-OBJ: "-o" "{{.*}}foo-cg.o"
|
||||
// CHECK-PCH-CODEGEN-OBJ: "-x" "precompiled-header"
|
||||
|
||||
// Create PCH's object file for -fmodules-debuginfo.
|
||||
// RUN: touch %t/foo-di.pch
|
||||
// RUN: %clang -c %t/foo-di.pch -g -o %t/foo-di.o -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-DEBUGINFO-OBJ
|
||||
// CHECK-PCH-DEBUGINFO-OBJ: -emit-obj
|
||||
// CHECK-PCH-DEBUGINFO-OBJ: "-main-file-name" "foo-di.pch"
|
||||
// CHECK-PCH-DEBUGINFO-OBJ: "-o" "{{.*}}foo-di.o"
|
||||
// CHECK-PCH-DEBUGINFO-OBJ: "-x" "precompiled-header"
|
|
@ -9,8 +9,8 @@
|
|||
// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -x c++-header -building-pch-with-obj -emit-pch %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-cg.pch
|
||||
// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-debuginfo -x c++-header -building-pch-with-obj -emit-pch %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-di.pch
|
||||
|
||||
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - %s -include-pch %t/foo-cg.pch -building-pch-with-obj -fmodules-codegen | FileCheck --check-prefix=CG %s
|
||||
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - %s -include-pch %t/foo-di.pch -building-pch-with-obj -fmodules-debuginfo | FileCheck --check-prefix=DI %s
|
||||
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -x precompiled-header %t/foo-cg.pch | FileCheck --check-prefix=CG %s
|
||||
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -x precompiled-header %t/foo-di.pch | FileCheck --check-prefix=DI %s
|
||||
|
||||
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -include-pch %t/foo-cg.pch %S/../Modules/Inputs/codegen-flags/use.cpp | FileCheck --check-prefix=CG-USE %s
|
||||
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -include-pch %t/foo-di.pch %S/../Modules/Inputs/codegen-flags/use.cpp | FileCheck --check-prefix=DI-USE %s
|
||||
|
@ -20,8 +20,8 @@
|
|||
// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -x c++-header -building-pch-with-obj -emit-pch -fpch-instantiate-templates %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-cg.pch
|
||||
// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-debuginfo -x c++-header -building-pch-with-obj -emit-pch -fpch-instantiate-templates %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-di.pch
|
||||
|
||||
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - %s -include-pch %t/foo-cg.pch -building-pch-with-obj -fmodules-codegen | FileCheck --check-prefix=CG %s
|
||||
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - %s -include-pch %t/foo-di.pch -building-pch-with-obj -fmodules-debuginfo | FileCheck --check-prefix=DI %s
|
||||
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -x precompiled-header %t/foo-cg.pch | FileCheck --check-prefix=CG %s
|
||||
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -x precompiled-header %t/foo-di.pch | FileCheck --check-prefix=DI %s
|
||||
|
||||
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -include-pch %t/foo-cg.pch %S/../Modules/Inputs/codegen-flags/use.cpp | FileCheck --check-prefix=CG-USE %s
|
||||
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -include-pch %t/foo-di.pch %S/../Modules/Inputs/codegen-flags/use.cpp | FileCheck --check-prefix=DI-USE %s
|
||||
|
|
Loading…
Reference in New Issue