[clang] c926bff - Revert "[Frontend][PCH]-Add support for ignoring PCH options (-ignore-pch). (#142409)"
Ying Yi via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 10 09:20:52 PDT 2025
Author: Ying Yi
Date: 2025-06-10T17:19:58+01:00
New Revision: c926bff560ba733a661bb494932c612ee6c207e5
URL: https://github.com/llvm/llvm-project/commit/c926bff560ba733a661bb494932c612ee6c207e5
DIFF: https://github.com/llvm/llvm-project/commit/c926bff560ba733a661bb494932c612ee6c207e5.diff
LOG: Revert "[Frontend][PCH]-Add support for ignoring PCH options (-ignore-pch). (#142409)"
This reverts commit 4fb81f11cea0fce9f1f5409fcd55ae3aba70d368.
Added:
Modified:
clang/docs/ReleaseNotes.rst
clang/docs/UsersManual.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/Clang.cpp
Removed:
clang/test/Driver/ignored-pch.cpp
clang/test/PCH/Inputs/ignored-pch.h
clang/test/PCH/ignored-pch.c
################################################################################
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c548c261453a6..beed0da6883d6 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -339,8 +339,6 @@ New Compiler Flags
- New option ``-Wnrvo`` added and disabled by default to warn about missed NRVO opportunities.
-- New option ``-ignore-pch`` added to disable precompiled headers. It overrides ``-emit-pch`` and ``-include-pch``. (#GH142409, `PCHDocs <https://clang.llvm.org/docs/UsersManual.html#ignoring-a-pch-file>`_).
-
Deprecated Compiler Flags
-------------------------
diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 284a404026dfe..62844f7e6a2fa 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1458,19 +1458,6 @@ will be processed from the PCH file. Otherwise, Clang will report an error.
``test.h`` since ``test.h`` was included directly in the source file and not
specified on the command line using ``-include-pch``.
-Ignoring a PCH File
-^^^^^^^^^^^^^^^^^^^
-
-To ignore PCH options, a `-ignore-pch` option is passed to ``clang``:
-
-.. code-block:: console
-
- $ clang -x c-header test.h -Xclang -ignore-pch -o test.h.pch
- $ clang -include-pch test.h.pch -Xclang -ignore-pch test.c -o test
-
-This option disables precompiled headers, overrides -emit-pch and -include-pch.
-test.h.pch is not generated and not used as a prefix header.
-
Relocatable PCH Files
^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 66d3dc921816d..3582efd7721b0 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3348,9 +3348,6 @@ defm pch_codegen: OptInCC1FFlag<"pch-codegen", "Generate ", "Do not generate ",
"code for uses of this PCH that assumes an explicit object file will be built for the PCH">;
defm pch_debuginfo: OptInCC1FFlag<"pch-debuginfo", "Generate ", "Do not generate ",
"debug info for types in an object file built from this PCH and do not generate them elsewhere">;
-def ignore_pch : Flag<["-"], "ignore-pch">, Group<f_Group>,
- Visibility<[ClangOption]>,
- HelpText<"Disable precompiled headers, overrides -emit-pch and -include-pch">;
def fimplicit_module_maps : Flag <["-"], "fimplicit-module-maps">, Group<f_Group>,
Visibility<[ClangOption, CC1Option, CLOption]>,
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index a03fd508e006c..80728daca03c9 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4331,15 +4331,6 @@ void Driver::handleArguments(Compilation &C, DerivedArgList &Args,
YcArg = YuArg = nullptr;
}
- if (Args.hasArg(options::OPT_include_pch) &&
- (FinalPhase == phases::Preprocess ||
- Args.hasArg(options::OPT_ignore_pch))) {
- // If only preprocessing or -ignore-pch is used, -include-pch is disabled.
- // Since -emit-pch is CC1option, it will not be added to command argments if
- // -ignore-pch is used.
- Args.eraseArg(options::OPT_include_pch);
- }
-
bool LinkOnly = phases::Link == FinalPhase && Inputs.size() > 0;
for (auto &I : Inputs) {
types::ID InputType = I.first;
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 2d676aa0b9c8e..a74fa81f3cf5b 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5184,7 +5184,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-emit-module-interface");
else if (JA.getType() == types::TY_HeaderUnit)
CmdArgs.push_back("-emit-header-unit");
- else if (!Args.hasArg(options::OPT_ignore_pch))
+ else
CmdArgs.push_back("-emit-pch");
} else if (isa<VerifyPCHJobAction>(JA)) {
CmdArgs.push_back("-verify-pch");
@@ -5241,8 +5241,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
} else if (JA.getType() == types::TY_PP_Asm) {
CmdArgs.push_back("-S");
} else if (JA.getType() == types::TY_AST) {
- if (!Args.hasArg(options::OPT_ignore_pch))
- CmdArgs.push_back("-emit-pch");
+ CmdArgs.push_back("-emit-pch");
} else if (JA.getType() == types::TY_ModuleFile) {
CmdArgs.push_back("-module-file-info");
} else if (JA.getType() == types::TY_RewrittenObjC) {
diff --git a/clang/test/Driver/ignored-pch.cpp b/clang/test/Driver/ignored-pch.cpp
deleted file mode 100644
index b237fc3cba57d..0000000000000
--- a/clang/test/Driver/ignored-pch.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-// RUN: rm -rf %t
-// RUN: mkdir -p %t
-
-// Create PCH without -ignore-pch.
-// RUN: %clang -x c++-header %S/../Modules/Inputs/codegen-flags/foo.h -### 2>&1 | FileCheck %s -check-prefix=CHECK-EMIT-PCH
-// RUN: %clang -x c++-header %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo.h.pch
-// RUN: %clang %s -include-pch %t/foo.h.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-INCLUDE-PCH
-// RUN: %clang %s -emit-ast -include-pch %t/foo.h.pch -### 2>&1 | FileCheck %s -check-prefixes=CHECK-EMIT-PCH,CHECK-INCLUDE-PCH
-
-
-// Create PCH with -ignore-pch.
-// RUN: %clang -x c++-header -ignore-pch %S/../Modules/Inputs/codegen-flags/foo.h -### 2>&1 | FileCheck %s -check-prefix=CHECK-IGNORE-PCH
-// RUN: %clang %s -ignore-pch -include-pch %t/foo.h.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-IGNORE-PCH
-// RUN: %clang %s -ignore-pch -emit-ast -include-pch %t/foo.h.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-IGNORE-PCH
-
-// CHECK-EMIT-PCH: -emit-pch
-// CHECK-INCLUDE-PCH: -include-pch
-// CHECK-IGNORE-PCH-NOT: -emit-pch
-// CHECK-IGNORE-PCH-NOT: -include-pch
diff --git a/clang/test/PCH/Inputs/ignored-pch.h b/clang/test/PCH/Inputs/ignored-pch.h
deleted file mode 100644
index 56047037c331f..0000000000000
--- a/clang/test/PCH/Inputs/ignored-pch.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef IGNORED_PCH_H
-#define IGNORED_PCH_H
-inline int f() {
- return 42;
-}
-#endif // IGNORED_PCH_H
diff --git a/clang/test/PCH/ignored-pch.c b/clang/test/PCH/ignored-pch.c
deleted file mode 100644
index 5b64582cba618..0000000000000
--- a/clang/test/PCH/ignored-pch.c
+++ /dev/null
@@ -1,113 +0,0 @@
-// RUN: rm -rf %t.pch %t.ll
-// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -o %t.pch
-// RUN: %clang -S -emit-llvm %s -include-pch %t.pch -o %t.ll
-// RUN: ls %t.pch | FileCheck --check-prefix=CHECK-PCH %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
-
-// RUN: rm -rf %t.pch %t.ll
-// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -o %t.pch
-// RUN: %clang %s -emit-ast -include-pch %t.pch -o %t.ll
-// RUN: ls %t.pch | FileCheck --check-prefix=CHECK-PCH %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
-
-// Check that -ignore-pch causes -emit-pch and -include-pch options to be ignored.
-// RUN: rm -rf %t.pch %t.ll
-// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -o %t.pch
-// RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH-ERROR %s
-// RUN: ls %t.ll 2>&1 | FileCheck --check-prefix=CHECK-OBJ %s
-
-// RUN: rm -rf %t.pch %t.ll
-// RUN: %clang -emit-ast %s -include-pch %t.pch -ignore-pch -o %t.ll
-// RUN: not ls %t.ll 2>&1 | FileCheck --check-prefix=CHECK-OBJ-ERROR %s
-
-// Check that -ignore-pch works for multiple PCH related options.
-// Test with -building-pch-with-obj.
-// RUN: rm -rf %t.pch %t.ll
-// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -Xclang -building-pch-with-obj -o %t.pch
-// RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -Xclang -building-pch-with-obj -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH-ERROR %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
-
-// Test with -fallow-pch-with-compiler-errors.
-// RUN: rm -rf %t.pch %t.ll
-// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -Xclang -fallow-pch-with-compiler-errors -o %t.pch
-// RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -Xclang -fallow-pch-with-compiler-errors -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH-ERROR %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
-
-// Test with -fallow-pch-with-
diff erent-modules-cache-path.
-// RUN: rm -rf %t.pch %t.ll
-// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -Xclang -fallow-pch-with-
diff erent-modules-cache-path -o %t.pch
-// RUN: %clang -S -emit-llvm %s -ignore-pch -include-pch %t.pch -Xclang -fallow-pch-with-
diff erent-modules-cache-path -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH-ERROR %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
-
-// Test with -fpch-codegen.
-// RUN: rm -rf %t.pch %t.ll
-// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -fpch-codegen -o %t.pch
-// RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -fpch-codegen -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH-ERROR %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
-
-// Test with -fpch-debuginfo.
-// RUN: rm -rf %t.pch %t.ll
-// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -fpch-debuginfo -o %t.pch
-// RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -fpch-debuginfo -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
-
-// Test with -fpch-instantiate-templates.
-// RUN: rm -rf %t.pch %t.ll
-// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -fpch-instantiate-templates -o %t.pch
-// RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -fpch-instantiate-templates -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
-
-// Test with -fno-pch-timestamp.
-// RUN: rm -rf %t.pch %t.ll
-// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -Xclang -fno-pch-timestamp -o %t.pch
-// RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -Xclang -fno-pch-timestamp -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
-
-// Test with -fno-validate-pch.
-// RUN: rm -rf %t.pch %t.ll
-// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -Xclang -fno-validate-pch -o %t.pch
-// RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -Xclang -fno-validate-pch -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
-
-// Test with -relocatable-pch.
-// RUN: rm -rf %t.pch %t.ll
-// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -relocatable-pch -o %t.pch
-// RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -relocatable-pch -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
-
-// Test with -pch-through-hdrstop-create/-pch-through-hdrstop-use
-// RUN: rm -rf %t.pch %t.ll
-// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -Xclang -pch-through-hdrstop-create -o %t.pch
-// RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -Xclang -pch-through-hdrstop-use -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
-
-
-// Test with AST dump output:
-// RUN: rm -rf %t.pch %t.ll
-// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -o %t.pch
-// RUN: %clang %s -include-pch %t.pch -Xclang -ast-dump-all -c | FileCheck --check-prefix=CHECK-AST-PCH %s
-// RUN: %clang %s -include-pch %t.pch -ignore-pch -Xclang -ast-dump-all -c | FileCheck --check-prefix=CHECK-AST %s
-
-// CHECK-PCH: ignored-pch.c.{{.*}}.pch
-// CHECK-OBJ: ignored-pch.c.{{.*}}.ll
-// CHECK-PCH-ERROR: ignored-pch.c.{{.*}}.pch{{'?}}: No such file or directory
-// CHECK-OBJ-ERROR: ignored-pch.c.{{.*}}.ll{{'?}}: No such file or directory
-// CHECK-AST-PCH: <undeserialized declarations>
-// CHECK-AST-NOT: <undeserialized declarations>
-
-#pragma hdrstop
-#include "Inputs/ignored-pch.h"
-int main() {
- return f();
-}
More information about the cfe-commits
mailing list