Skip to content

Commit d1b3f82

Browse files
committed
[clang][cli] Port PreprocessorOpts simple string based options to new option parsing system
Depends on D84671 Reviewed By: Bigcheese Original patch by Daniel Grumberg. Differential Revision: https://reviews.llvm.org/D84672
1 parent aec2991 commit d1b3f82

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2615,7 +2615,8 @@ def image__base : Separate<["-"], "image_base">;
26152615
def include_ : JoinedOrSeparate<["-", "--"], "include">, Group<clang_i_Group>, EnumName<"include">,
26162616
MetaVarName<"<file>">, HelpText<"Include file before parsing">, Flags<[CC1Option]>;
26172617
def include_pch : Separate<["-"], "include-pch">, Group<clang_i_Group>, Flags<[CC1Option]>,
2618-
HelpText<"Include precompiled header file">, MetaVarName<"<file>">;
2618+
HelpText<"Include precompiled header file">, MetaVarName<"<file>">,
2619+
MarshallingInfoString<"PreprocessorOpts->ImplicitPCHInclude">;
26192620
def relocatable_pch : Flag<["-", "--"], "relocatable-pch">, Flags<[CC1Option]>,
26202621
HelpText<"Whether to build a relocatable precompiled header">,
26212622
MarshallingInfoFlag<"FrontendOpts.RelocatablePCH">;
@@ -4857,7 +4858,8 @@ def foverride_record_layout_EQ : Joined<["-"], "foverride-record-layout=">,
48574858
HelpText<"Override record layouts with those in the given file">;
48584859
def pch_through_header_EQ : Joined<["-"], "pch-through-header=">,
48594860
HelpText<"Stop PCH generation after including this file. When using a PCH, "
4860-
"skip tokens until after this file is included.">;
4861+
"skip tokens until after this file is included.">,
4862+
MarshallingInfoString<"PreprocessorOpts->PCHThroughHeader">;
48614863
def pch_through_hdrstop_create : Flag<["-"], "pch-through-hdrstop-create">,
48624864
HelpText<"When creating a PCH, stop PCH generation after #pragma hdrstop.">,
48634865
MarshallingInfoFlag<"PreprocessorOpts->PCHWithHdrStopCreate">;
@@ -4904,7 +4906,9 @@ def fconstant_string_class : Separate<["-"], "fconstant-string-class">,
49044906
HelpText<"Specify the class to use for constant Objective-C string objects.">,
49054907
MarshallingInfoString<"LangOpts->ObjCConstantStringClass">;
49064908
def fobjc_arc_cxxlib_EQ : Joined<["-"], "fobjc-arc-cxxlib=">,
4907-
HelpText<"Objective-C++ Automatic Reference Counting standard library kind">, Values<"libc++,libstdc++,none">;
4909+
HelpText<"Objective-C++ Automatic Reference Counting standard library kind">, Values<"libc++,libstdc++,none">,
4910+
NormalizedValues<["ARCXX_libcxx", "ARCXX_libstdcxx", "ARCXX_nolib"]>,
4911+
MarshallingInfoString<"PreprocessorOpts->ObjCXXARCStandardLibrary", "ARCXX_nolib">, AutoNormalizeEnum;
49084912
def fobjc_runtime_has_weak : Flag<["-"], "fobjc-runtime-has-weak">,
49094913
HelpText<"The target Objective-C runtime supports ARC weak operations">;
49104914
def fobjc_dispatch_method_EQ : Joined<["-"], "fobjc-dispatch-method=">,

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3115,11 +3115,8 @@ static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {
31153115
static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args,
31163116
DiagnosticsEngine &Diags,
31173117
frontend::ActionKind Action) {
3118-
Opts.ImplicitPCHInclude = std::string(Args.getLastArgValue(OPT_include_pch));
31193118
Opts.PCHWithHdrStop = Args.hasArg(OPT_pch_through_hdrstop_create) ||
31203119
Args.hasArg(OPT_pch_through_hdrstop_use);
3121-
Opts.PCHThroughHeader =
3122-
std::string(Args.getLastArgValue(OPT_pch_through_header_EQ));
31233120
Opts.AllowPCHWithCompilerErrors =
31243121
Args.hasArg(OPT_fallow_pch_with_errors, OPT_fallow_pcm_with_errors);
31253122

@@ -3187,19 +3184,6 @@ static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args,
31873184
Opts.addRemappedFile(Split.first, Split.second);
31883185
}
31893186

3190-
if (Arg *A = Args.getLastArg(OPT_fobjc_arc_cxxlib_EQ)) {
3191-
StringRef Name = A->getValue();
3192-
unsigned Library = llvm::StringSwitch<unsigned>(Name)
3193-
.Case("libc++", ARCXX_libcxx)
3194-
.Case("libstdc++", ARCXX_libstdcxx)
3195-
.Case("none", ARCXX_nolib)
3196-
.Default(~0U);
3197-
if (Library == ~0U)
3198-
Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
3199-
else
3200-
Opts.ObjCXXARCStandardLibrary = (ObjCXXARCStandardLibraryKind)Library;
3201-
}
3202-
32033187
// Always avoid lexing editor placeholders when we're just running the
32043188
// preprocessor as we never want to emit the
32053189
// "editor placeholder in source file" error in PP only mode.

0 commit comments

Comments
 (0)