Skip to content

Commit 0a6b5b6

Browse files
author
Erich Keane
committed
PTH-- Remove feature entirely-
When debugging a boost build with a modified version of Clang, I discovered that the PTH implementation stores TokenKind in 8 bits. However, we currently have 368 TokenKinds. The result is that the value gets truncated and the wrong token gets picked up when including PTH files. It seems that this will go wrong every time someone uses a token that uses the 9th bit. Upon asking on IRC, it was brought up that this was a highly experimental features that was considered a failure. I discovered via googling that BoostBuild (mostly Boost.Math) is the only user of this feature, using the CC1 flag directly. I believe that this can be transferred over to normal PCH with minimal effort: boostorg/build#367 Based on advice on IRC and research showing that this is a nearly completely unused feature, this patch removes it entirely. Note: I considered leaving the build-flags in place and making them emit an error/warning, however since I've basically identified and warned the only user, it seemed better to just remove them. Differential Revision: https://reviews.llvm.org/D54547 Change-Id: If32744275ef1f585357bd6c1c813d96973c4d8d9 llvm-svn: 348266
1 parent 924f98e commit 0a6b5b6

40 files changed

+54
-2279
lines changed

clang/NOTES.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@ To time GCC preprocessing speed without output, use:
88
"time gcc -MM file"
99
This is similar to -Eonly.
1010

11-
//===---------------------------------------------------------------------===//
12-
13-
Creating and using a PTH file for performance measurement (use a release build).
14-
15-
$ clang -ccc-pch-is-pth -x objective-c-header INPUTS/Cocoa_h.m -o /tmp/tokencache
16-
$ clang -cc1 -token-cache /tmp/tokencache INPUTS/Cocoa_h.m
17-
1811
//===---------------------------------------------------------------------===//
1912

2013
C++ Template Instantiation benchmark:

clang/docs/InternalsManual.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -559,13 +559,9 @@ The clang Driver and library are documented :doc:`here <DriverInternals>`.
559559
Precompiled Headers
560560
===================
561561

562-
Clang supports two implementations of precompiled headers. The default
563-
implementation, precompiled headers (:doc:`PCH <PCHInternals>`) uses a
562+
Clang supports precompiled headers (:doc:`PCH <PCHInternals>`), which uses a
564563
serialized representation of Clang's internal data structures, encoded with the
565564
`LLVM bitstream format <https://llvm.org/docs/BitCodeFormat.html>`_.
566-
Pretokenized headers (:doc:`PTH <PTHInternals>`), on the other hand, contain a
567-
serialized representation of the tokens encountered when preprocessing a header
568-
(and anything that header includes).
569565

570566
The Frontend Library
571567
====================

clang/docs/PTHInternals.rst

Lines changed: 0 additions & 163 deletions
This file was deleted.

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ Improvements to Clang's diagnostics
116116
Non-comprehensive list of changes in this release
117117
-------------------------------------------------
118118

119-
- ...
119+
- The experimental feature Pretokenized Headers (PTH) was removed in its
120+
entirely from Clang. The feature did not properly work with about 1/3 of the
121+
possible tokens available and was unmaintained.
120122

121123
New Compiler Flags
122124
------------------

clang/include/clang/Basic/DiagnosticFrontendKinds.td

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ def err_fe_unable_to_interface_with_target : Error<
9999
"unable to interface with target machine">;
100100
def err_fe_unable_to_open_output : Error<
101101
"unable to open output file '%0': '%1'">;
102-
def err_fe_pth_file_has_no_source_header : Error<
103-
"PTH file '%0' does not designate an original source header file for -include-pth">;
104102
def warn_fe_macro_contains_embedded_newline : Warning<
105103
"macro '%0' contains embedded newline; text after the newline is ignored">;
106104
def warn_fe_cc_print_header_failure : Warning<

clang/include/clang/Basic/DiagnosticLexKinds.td

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,6 @@ def warn_bad_character_encoding : ExtWarn<
258258
def err_lexing_string : Error<"failure when lexing a string">;
259259
def err_placeholder_in_source : Error<"editor placeholder in source file">;
260260

261-
262-
//===----------------------------------------------------------------------===//
263-
// PTH Diagnostics
264-
//===----------------------------------------------------------------------===//
265-
def err_invalid_pth_file : Error<
266-
"invalid or corrupt PTH file '%0'">;
267-
268261
//===----------------------------------------------------------------------===//
269262
// Preprocessor Diagnostics
270263
//===----------------------------------------------------------------------===//
@@ -570,8 +563,6 @@ def err_pp_module_end_without_module_begin : Error<
570563
"'#pragma clang module end'">;
571564
def note_pp_module_begin_here : Note<
572565
"entering module '%0' due to this pragma">;
573-
def err_pp_module_build_pth : Error<
574-
"'#pragma clang module build' not supported in pretokenized header">;
575566
def err_pp_module_build_missing_end : Error<
576567
"no matching '#pragma clang module endbuild' for this '#pragma clang module build'">;
577568

clang/include/clang/Driver/CC1Options.td

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -562,8 +562,6 @@ def emit_module_interface : Flag<["-"], "emit-module-interface">,
562562
HelpText<"Generate pre-compiled module file from a C++ module interface">;
563563
def emit_header_module : Flag<["-"], "emit-header-module">,
564564
HelpText<"Generate pre-compiled module file from a set of header files">;
565-
def emit_pth : Flag<["-"], "emit-pth">,
566-
HelpText<"Generate pre-tokenized header file">;
567565
def emit_pch : Flag<["-"], "emit-pch">,
568566
HelpText<"Generate pre-compiled header file">;
569567
def emit_llvm_bc : Flag<["-"], "emit-llvm-bc">,
@@ -794,15 +792,11 @@ def internal_externc_isystem : JoinedOrSeparate<["-"], "internal-externc-isystem
794792
// Preprocessor Options
795793
//===----------------------------------------------------------------------===//
796794

797-
def include_pth : Separate<["-"], "include-pth">, MetaVarName<"<file>">,
798-
HelpText<"Include file before parsing">;
799795
def chain_include : Separate<["-"], "chain-include">, MetaVarName<"<file>">,
800796
HelpText<"Include and chain a header file after turning it into PCH">;
801797
def preamble_bytes_EQ : Joined<["-"], "preamble-bytes=">,
802798
HelpText<"Assume that the precompiled header is a precompiled preamble "
803799
"covering the first N bytes of the main file">;
804-
def token_cache : Separate<["-"], "token-cache">, MetaVarName<"<path>">,
805-
HelpText<"Use specified token cache file">;
806800
def detailed_preprocessing_record : Flag<["-"], "detailed-preprocessing-record">,
807801
HelpText<"include a detailed record of preprocessing actions">;
808802

clang/include/clang/Driver/Driver.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,6 @@ class Driver {
227227
unsigned CheckInputsExist : 1;
228228

229229
public:
230-
/// Use lazy precompiled headers for PCH support.
231-
unsigned CCCUsePCH : 1;
232-
233230
/// Force clang to emit reproducer for driver invocation. This is enabled
234231
/// indirectly by setting FORCE_CLANG_DIAGNOSTICS_CRASH environment variable
235232
/// or when using the -gen-reproducer driver flag.

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,6 @@ def rsp_quoting : Joined<["--"], "rsp-quoting=">, Group<internal_driver_Group>,
258258
def ccc_gcc_name : Separate<["-"], "ccc-gcc-name">, InternalDriverOpt,
259259
HelpText<"Name for native GCC compiler">,
260260
MetaVarName<"<gcc-path>">;
261-
def ccc_pch_is_pch : Flag<["-"], "ccc-pch-is-pch">, InternalDriverOpt,
262-
HelpText<"Use lazy PCH for precompiled headers">;
263-
def ccc_pch_is_pth : Flag<["-"], "ccc-pch-is-pth">, InternalDriverOpt,
264-
HelpText<"Use pretokenized headers for precompiled headers">;
265261

266262
class InternalDebugOpt : Group<internal_debug_Group>,
267263
Flags<[DriverOption, HelpHidden, CoreOption]>;

clang/include/clang/Frontend/FrontendActions.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,6 @@ class DumpTokensAction : public PreprocessorFrontendAction {
261261
void ExecuteAction() override;
262262
};
263263

264-
class GeneratePTHAction : public PreprocessorFrontendAction {
265-
protected:
266-
void ExecuteAction() override;
267-
};
268-
269264
class PreprocessOnlyAction : public PreprocessorFrontendAction {
270265
protected:
271266
void ExecuteAction() override;

clang/include/clang/Frontend/FrontendOptions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@ enum ActionKind {
8888
/// Generate pre-compiled header.
8989
GeneratePCH,
9090

91-
/// Generate pre-tokenized header.
92-
GeneratePTH,
93-
9491
/// Only execute frontend initialization.
9592
InitOnly,
9693

clang/include/clang/Frontend/Utils.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,6 @@ void AttachHeaderIncludeGen(Preprocessor &PP,
183183
StringRef OutputPath = {},
184184
bool ShowDepth = true, bool MSStyle = false);
185185

186-
/// Cache tokens for use with PCH. Note that this requires a seekable stream.
187-
void CacheTokens(Preprocessor &PP, raw_pwrite_stream *OS);
188-
189186
/// The ChainedIncludesSource class converts headers to chained PCHs in
190187
/// memory, mainly for testing.
191188
IntrusiveRefCntPtr<ExternalSemaSource>

0 commit comments

Comments
 (0)