Skip to content

Commit 4a450da

Browse files
committed
Revert "[Preprocessor] Implement -fminimize-whitespace."
This reverts commit ae6b400. llvm.org/PR51300
1 parent 3bce613 commit 4a450da

19 files changed

+144
-395
lines changed

clang/docs/ClangCommandLineReference.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2475,16 +2475,6 @@ Turn on loop unroller
24752475

24762476
Use #line in preprocessed output
24772477

2478-
.. option:: -fminimize-whitespace, -fno-minimize-whitespace
2479-
2480-
Ignore the whitespace from the input file when emitting preprocessor
2481-
output. It will only contain whitespace when necessary, e.g. to keep two
2482-
minus signs from merging into to an increment operator. Useful with the
2483-
-P option to normalize whitespace such that two files with only formatting
2484-
changes are equal.
2485-
2486-
Only valid with -E on C-like inputs and incompatible with -traditional-cpp.
2487-
24882478
.. option:: -fvalidate-ast-input-files-content
24892479

24902480
Compute and store the hash of input files used to build an AST. Files with mismatching mtime's are considered valid if both contents is identical

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ def err_drv_invalid_Xopenmp_target_with_args : Error<
129129
"invalid -Xopenmp-target argument: '%0', options requiring arguments are unsupported">;
130130
def err_drv_argument_only_allowed_with : Error<
131131
"invalid argument '%0' only allowed with '%1'">;
132-
def err_drv_minws_unsupported_input_type : Error<
133-
"'-fminimize-whitespace' invalid for input of type %0">;
134132
def err_drv_amdgpu_ieee_without_no_honor_nans : Error<
135133
"invalid argument '-mno-amdgpu-ieee' only allowed with relaxed NaN handling">;
136134
def err_drv_argument_not_allowed_with : Error<

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,9 +1799,6 @@ def frewrite_map_file_EQ : Joined<["-"], "frewrite-map-file=">,
17991799
defm use_line_directives : BoolFOption<"use-line-directives",
18001800
PreprocessorOutputOpts<"UseLineDirectives">, DefaultFalse,
18011801
PosFlag<SetTrue, [CC1Option], "Use #line in preprocessed output">, NegFlag<SetFalse>>;
1802-
defm minimize_whitespace : BoolFOption<"minimize-whitespace",
1803-
PreprocessorOutputOpts<"MinimizeWhitespace">, DefaultFalse,
1804-
PosFlag<SetTrue, [CC1Option], "Minimize whitespace when emitting preprocessor output">, NegFlag<SetFalse>>;
18051802

18061803
def ffreestanding : Flag<["-"], "ffreestanding">, Group<f_Group>, Flags<[CC1Option]>,
18071804
HelpText<"Assert that the compilation takes place in a freestanding environment">,

clang/include/clang/Driver/Types.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,6 @@ namespace types {
6666
/// isAcceptedByClang - Can clang handle this input type.
6767
bool isAcceptedByClang(ID Id);
6868

69-
/// isDerivedFromC - Is the input derived from C.
70-
///
71-
/// That is, does the lexer follow the rules of
72-
/// TokenConcatenation::AvoidConcat. If this is the case, the preprocessor may
73-
/// add and remove whitespace between tokens. Used to determine whether the
74-
/// input can be processed by -fminimize-whitespace.
75-
bool isDerivedFromC(ID Id);
76-
7769
/// isCXX - Is this a "C++" input (C++ and Obj-C++ sources and headers).
7870
bool isCXX(ID Id);
7971

clang/include/clang/Frontend/PreprocessorOutputOptions.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class PreprocessorOutputOptions {
2424
unsigned ShowIncludeDirectives : 1; ///< Print includes, imports etc. within preprocessed output.
2525
unsigned RewriteIncludes : 1; ///< Preprocess include directives only.
2626
unsigned RewriteImports : 1; ///< Include contents of transitively-imported modules.
27-
unsigned MinimizeWhitespace : 1; ///< Ignore whitespace from input.
2827

2928
public:
3029
PreprocessorOutputOptions() {
@@ -37,7 +36,6 @@ class PreprocessorOutputOptions {
3736
ShowIncludeDirectives = 0;
3837
RewriteIncludes = 0;
3938
RewriteImports = 0;
40-
MinimizeWhitespace = 0;
4139
}
4240
};
4341

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ using namespace clang;
5252
using namespace llvm::opt;
5353

5454
static void CheckPreprocessingOptions(const Driver &D, const ArgList &Args) {
55-
if (Arg *A = Args.getLastArg(clang::driver::options::OPT_C, options::OPT_CC,
56-
options::OPT_fminimize_whitespace,
57-
options::OPT_fno_minimize_whitespace)) {
55+
if (Arg *A =
56+
Args.getLastArg(clang::driver::options::OPT_C, options::OPT_CC)) {
5857
if (!Args.hasArg(options::OPT_E) && !Args.hasArg(options::OPT__SLASH_P) &&
5958
!Args.hasArg(options::OPT__SLASH_EP) && !D.CCCIsCPP()) {
6059
D.Diag(clang::diag::err_drv_argument_only_allowed_with)
@@ -6068,16 +6067,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
60686067
options::OPT_fno_use_line_directives, false))
60696068
CmdArgs.push_back("-fuse-line-directives");
60706069

6071-
// -fno-minimize-whitespace is default.
6072-
if (Args.hasFlag(options::OPT_fminimize_whitespace,
6073-
options::OPT_fno_minimize_whitespace, false)) {
6074-
types::ID InputType = Inputs[0].getType();
6075-
if (!isDerivedFromC(InputType))
6076-
D.Diag(diag::err_drv_minws_unsupported_input_type)
6077-
<< types::getTypeName(InputType);
6078-
CmdArgs.push_back("-fminimize-whitespace");
6079-
}
6080-
60816070
// -fms-extensions=0 is default.
60826071
if (Args.hasFlag(options::OPT_fms_extensions, options::OPT_fno_ms_extensions,
60836072
IsWindowsMSVC))

clang/lib/Driver/Types.cpp

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -147,45 +147,6 @@ bool types::isAcceptedByClang(ID Id) {
147147
}
148148
}
149149

150-
bool types::isDerivedFromC(ID Id) {
151-
switch (Id) {
152-
default:
153-
return false;
154-
155-
case TY_PP_C:
156-
case TY_C:
157-
case TY_CL:
158-
case TY_CLCXX:
159-
case TY_PP_CUDA:
160-
case TY_CUDA:
161-
case TY_CUDA_DEVICE:
162-
case TY_PP_HIP:
163-
case TY_HIP:
164-
case TY_HIP_DEVICE:
165-
case TY_PP_ObjC:
166-
case TY_PP_ObjC_Alias:
167-
case TY_ObjC:
168-
case TY_PP_CXX:
169-
case TY_CXX:
170-
case TY_PP_ObjCXX:
171-
case TY_PP_ObjCXX_Alias:
172-
case TY_ObjCXX:
173-
case TY_RenderScript:
174-
case TY_PP_CHeader:
175-
case TY_CHeader:
176-
case TY_CLHeader:
177-
case TY_PP_ObjCHeader:
178-
case TY_ObjCHeader:
179-
case TY_PP_CXXHeader:
180-
case TY_CXXHeader:
181-
case TY_PP_ObjCXXHeader:
182-
case TY_ObjCXXHeader:
183-
case TY_CXXModule:
184-
case TY_PP_CXXModule:
185-
return true;
186-
}
187-
}
188-
189150
bool types::isObjC(ID Id) {
190151
switch (Id) {
191152
default:

0 commit comments

Comments
 (0)