Skip to content

[Driver] -include: deprecate probing .gch #67084

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ C/C++ Language Potentially Breaking Changes

- The default extension name for PCH generation (``-c -xc-header`` and ``-c
-xc++-header``) is now ``.pch`` instead of ``.gch``.
- ``-include a.h`` probing ``a.h.gch`` is deprecated. Change the extension name
to ``.pch`` or use ``-include-pch a.h.gch``.

C++ Specific Potentially Breaking Changes
-----------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/DiagnosticDriverKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,9 @@ def warn_drv_overriding_option : Warning<
def warn_drv_treating_input_as_cxx : Warning<
"treating '%0' input as '%1' when in C++ mode, this behavior is deprecated">,
InGroup<Deprecated>;
def warn_drv_include_probe_gch : Warning<
"'%0' probing .gch is deprecated. Use '-include-pch %1' or switch to .pch instead">,
InGroup<Deprecated>;
def warn_drv_pch_not_first_include : Warning<
"precompiled header '%0' was ignored because '%1' is not first '-include'">;
def warn_missing_sysroot : Warning<"no such sysroot directory: '%0'">,
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,7 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
llvm::sys::path::replace_extension(P, "gch");
if (D.getVFS().exists(P)) {
FoundPCH = true;
D.Diag(diag::warn_drv_include_probe_gch) << A->getAsString(Args) << P;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"directory": "DIR",
"command": "clang -x c-header DIR/pch.h -fmodules -gmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -o DIR/pch.h.gch",
"command": "clang -x c-header DIR/pch.h -fmodules -gmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -o DIR/pch.h.pch",
"file": "DIR/pch.h"
}
]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"directory": "DIR",
"command": "clang -x c-header DIR/pch.h -fmodules -gmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -o DIR/pch.h.gch",
"command": "clang -x c-header DIR/pch.h -fmodules -gmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -o DIR/pch.h.pch",
"file": "DIR/pch.h"
}
]
2 changes: 1 addition & 1 deletion clang/test/ClangScanDeps/Inputs/modules-pch/cdb_pch.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"directory": "DIR",
"command": "clang -x c-header DIR/pch.h -fmodules -gmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -o DIR/pch.h.gch",
"command": "clang -x c-header DIR/pch.h -fmodules -gmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -o DIR/pch.h.pch",
"file": "DIR/pch.h"
}
]
2 changes: 1 addition & 1 deletion clang/test/ClangScanDeps/modules-pch-common-submodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
// CHECK-TU: ],
// CHECK-TU: "file-deps": [
// CHECK-TU-NEXT: "[[PREFIX]]/tu.c",
// CHECK-TU-NEXT: "[[PREFIX]]/pch.h.gch"
// CHECK-TU-NEXT: "[[PREFIX]]/pch.h.pch"
// CHECK-TU-NEXT: ],
// CHECK-TU-NEXT: "input-file": "[[PREFIX]]/tu.c"
// CHECK-TU-NEXT: }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
// CHECK-TU: ],
// CHECK-TU: "file-deps": [
// CHECK-TU-NEXT: "[[PREFIX]]/tu.c",
// CHECK-TU-NEXT: "[[PREFIX]]/pch.h.gch"
// CHECK-TU-NEXT: "[[PREFIX]]/pch.h.pch"
// CHECK-TU-NEXT: ],
// CHECK-TU-NEXT: "input-file": "[[PREFIX]]/tu.c"
// CHECK-TU-NEXT: }
Expand Down
6 changes: 3 additions & 3 deletions clang/test/ClangScanDeps/modules-pch.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// RUN: cat %t/result_pch.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t -check-prefix=CHECK-PCH
//
// Check we didn't build the PCH during dependency scanning.
// RUN: not cat %/t/pch.h.gch
// RUN: not cat %/t/pch.h.pch
//
// CHECK-PCH: {
// CHECK-PCH-NEXT: "modules": [
Expand Down Expand Up @@ -129,7 +129,7 @@
// CHECK-TU: ],
// CHECK-TU: "file-deps": [
// CHECK-TU-NEXT: "[[PREFIX]]/tu.c",
// CHECK-TU-NEXT: "[[PREFIX]]/pch.h.gch"
// CHECK-TU-NEXT: "[[PREFIX]]/pch.h.pch"
// CHECK-TU-NEXT: ],
// CHECK-TU-NEXT: "input-file": "[[PREFIX]]/tu.c"
// CHECK-TU-NEXT: }
Expand Down Expand Up @@ -179,7 +179,7 @@
// CHECK-TU-WITH-COMMON: ],
// CHECK-TU-WITH-COMMON: "file-deps": [
// CHECK-TU-WITH-COMMON-NEXT: "[[PREFIX]]/tu_with_common.c",
// CHECK-TU-WITH-COMMON-NEXT: "[[PREFIX]]/pch.h.gch"
// CHECK-TU-WITH-COMMON-NEXT: "[[PREFIX]]/pch.h.pch"
// CHECK-TU-WITH-COMMON-NEXT: ],
// CHECK-TU-WITH-COMMON-NEXT: "input-file": "[[PREFIX]]/tu_with_common.c"
// CHECK-TU-WITH-COMMON-NEXT: }
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Index/cindex-from-source.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// REQUIRES: native
// RUN: c-index-test -write-pch %t.pfx.h.gch -x objective-c-header %S/Inputs/cindex-from-source.h
// RUN: c-index-test -write-pch %t.pfx.h.pch -x objective-c-header %S/Inputs/cindex-from-source.h
// RUN: c-index-test -test-load-source local %s -include %t.pfx.h > %t
// RUN: FileCheck %s < %t
// CHECK: cindex-from-source.m:{{.*}}:{{.*}}: StructDecl=s0:{{.*}}:{{.*}}
Expand Down
2 changes: 2 additions & 0 deletions clang/test/PCH/pch-dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ int FOO;

int get(void) {
#ifdef __cplusplus
// CHECK-CPP: warning: '-include {{.*}}.h' probing .gch is deprecated. Use '-include-pch {{.*}}.h.gch' or switch to .pch instead
// CHECK-CPP: .h.gch{{[/\\]}}cpp.gch
return i;
#else
// CHECK-C: warning: '-include {{.*}}.h' probing .gch is deprecated. Use '-include-pch {{.*}}.h.gch' or switch to .pch instead
// CHECK-C: .h.gch{{[/\\]}}c.gch
return j;
#endif
Expand Down
2 changes: 1 addition & 1 deletion clang/test/SemaCXX/warn-unused-local-typedef-serialize.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang -x c++-header -c -Wunused-local-typedef %s -o %t.gch -Werror
// RUN: %clang -x c++-header -c -Wunused-local-typedef %s -o %t.pch -Werror
// RUN: %clang -DBE_THE_SOURCE -c -Wunused-local-typedef -include %t %s -o /dev/null 2>&1 | FileCheck %s
// RUN: %clang -DBE_THE_SOURCE -c -Wunused-local-typedef -include %t %s -o /dev/null 2>&1 | FileCheck %s

Expand Down