aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-12-23 14:13:23 -0500
committerNico Weber <thakis@chromium.org>2020-12-23 14:20:21 -0500
commit1876a2914fe0bedf50f7be6a305f5bf35493e496 (patch)
tree1c06adbc461064e1a177826184b3255cc2f4ebfb /clang/lib/Frontend/CompilerInvocation.cpp
parentbbd758a7913b1c374ca26e5a734a01200754fe0e (diff)
downloadllvm-1876a2914fe0bedf50f7be6a305f5bf35493e496.zip
llvm-1876a2914fe0bedf50f7be6a305f5bf35493e496.tar.gz
llvm-1876a2914fe0bedf50f7be6a305f5bf35493e496.tar.bz2
Revert more changes that landed on top of 741978d727
This should've been in 7ad666798f12456d9 but wasn't. Squashes these twoc commits: Revert "[clang][cli] Let denormalizer decide how to render the option based on the option class" This reverts commit 70410a264949101ced3ce3458f37dd4cc2f5af85. Revert "[clang][cli] Implement `getAllArgValues` marshalling" This reverts commit 63a24816f561a5d8e28ca7054892bd8602618be4.
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp96
1 files changed, 40 insertions, 56 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index a7a5a73..06d8d2e 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -152,8 +152,8 @@ static Optional<bool> normalizeSimpleNegativeFlag(OptSpecifier Opt, unsigned,
/// argument.
static void denormalizeSimpleFlag(SmallVectorImpl<const char *> &Args,
const char *Spelling,
- CompilerInvocation::StringAllocator,
- Option::OptionClass, unsigned, /*T*/...) {
+ CompilerInvocation::StringAllocator, unsigned,
+ /*T*/...) {
Args.push_back(Spelling);
}
@@ -193,41 +193,12 @@ static auto makeBooleanOptionNormalizer(bool Value, bool OtherValue,
static auto makeBooleanOptionDenormalizer(bool Value) {
return [Value](SmallVectorImpl<const char *> &Args, const char *Spelling,
- CompilerInvocation::StringAllocator, Option::OptionClass,
- unsigned, bool KeyPath) {
+ CompilerInvocation::StringAllocator, unsigned, bool KeyPath) {
if (KeyPath == Value)
Args.push_back(Spelling);
};
}
-static void denormalizeStringImpl(SmallVectorImpl<const char *> &Args,
- const char *Spelling,
- CompilerInvocation::StringAllocator SA,
- Option::OptionClass OptClass, unsigned,
- Twine Value) {
- switch (OptClass) {
- case Option::SeparateClass:
- case Option::JoinedOrSeparateClass:
- Args.push_back(Spelling);
- Args.push_back(SA(Value));
- break;
- case Option::JoinedClass:
- Args.push_back(SA(Twine(Spelling) + Value));
- break;
- default:
- llvm_unreachable("Cannot denormalize an option with option class "
- "incompatible with string denormalization.");
- }
-}
-
-template <typename T>
-static void
-denormalizeString(SmallVectorImpl<const char *> &Args, const char *Spelling,
- CompilerInvocation::StringAllocator SA,
- Option::OptionClass OptClass, unsigned TableIndex, T Value) {
- denormalizeStringImpl(Args, Spelling, SA, OptClass, TableIndex, Twine(Value));
-}
-
static Optional<SimpleEnumValue>
findValueTableByName(const SimpleEnumValueTable &Table, StringRef Name) {
for (int I = 0, E = Table.Size; I != E; ++I)
@@ -269,13 +240,12 @@ static llvm::Optional<unsigned> normalizeSimpleEnum(OptSpecifier Opt,
static void denormalizeSimpleEnumImpl(SmallVectorImpl<const char *> &Args,
const char *Spelling,
CompilerInvocation::StringAllocator SA,
- Option::OptionClass OptClass,
unsigned TableIndex, unsigned Value) {
assert(TableIndex < SimpleEnumValueTablesSize);
const SimpleEnumValueTable &Table = SimpleEnumValueTables[TableIndex];
if (auto MaybeEnumVal = findValueTableByValue(Table, Value)) {
- denormalizeString(Args, Spelling, SA, OptClass, TableIndex,
- MaybeEnumVal->Name);
+ Args.push_back(Spelling);
+ Args.push_back(MaybeEnumVal->Name);
} else {
llvm_unreachable("The simple enum value was not correctly defined in "
"the tablegen option description");
@@ -286,12 +256,24 @@ template <typename T>
static void denormalizeSimpleEnum(SmallVectorImpl<const char *> &Args,
const char *Spelling,
CompilerInvocation::StringAllocator SA,
- Option::OptionClass OptClass,
unsigned TableIndex, T Value) {
- return denormalizeSimpleEnumImpl(Args, Spelling, SA, OptClass, TableIndex,
+ return denormalizeSimpleEnumImpl(Args, Spelling, SA, TableIndex,
static_cast<unsigned>(Value));
}
+static void denormalizeSimpleEnumJoined(SmallVectorImpl<const char *> &Args,
+ const char *Spelling,
+ CompilerInvocation::StringAllocator SA,
+ unsigned TableIndex, unsigned Value) {
+ assert(TableIndex < SimpleEnumValueTablesSize);
+ const SimpleEnumValueTable &Table = SimpleEnumValueTables[TableIndex];
+ if (auto MaybeEnumVal = findValueTableByValue(Table, Value))
+ Args.push_back(SA(Twine(Spelling) + MaybeEnumVal->Name));
+ else
+ llvm_unreachable("The simple enum value was not correctly defined in "
+ "the tablegen option description");
+}
+
static Optional<std::string> normalizeString(OptSpecifier Opt, int TableIndex,
const ArgList &Args,
DiagnosticsEngine &Diags) {
@@ -301,6 +283,25 @@ static Optional<std::string> normalizeString(OptSpecifier Opt, int TableIndex,
return std::string(Arg->getValue());
}
+static void denormalizeString(SmallVectorImpl<const char *> &Args,
+ const char *Spelling,
+ CompilerInvocation::StringAllocator SA, unsigned,
+ Twine Value) {
+ Args.push_back(Spelling);
+ Args.push_back(SA(Value));
+}
+
+template <typename T,
+ std::enable_if_t<!std::is_convertible<T, Twine>::value &&
+ std::is_constructible<Twine, T>::value,
+ bool> = false>
+static void denormalizeString(SmallVectorImpl<const char *> &Args,
+ const char *Spelling,
+ CompilerInvocation::StringAllocator SA,
+ unsigned TableIndex, T Value) {
+ denormalizeString(Args, Spelling, SA, TableIndex, Twine(Value));
+}
+
template <typename IntTy>
static Optional<IntTy> normalizeStringIntegral(OptSpecifier Opt, int,
const ArgList &Args,
@@ -316,23 +317,6 @@ static Optional<IntTy> normalizeStringIntegral(OptSpecifier Opt, int,
return Res;
}
-static Optional<std::vector<std::string>>
-normalizeStringVector(OptSpecifier Opt, int, const ArgList &Args,
- DiagnosticsEngine &) {
- return Args.getAllArgValues(Opt);
-}
-
-static void denormalizeStringVector(SmallVectorImpl<const char *> &Args,
- const char *Spelling,
- CompilerInvocation::StringAllocator SA,
- Option::OptionClass OptClass,
- unsigned TableIndex,
- const std::vector<std::string> &Values) {
- for (const std::string &Value : Values) {
- denormalizeString(Args, Spelling, SA, OptClass, TableIndex, Value);
- }
-}
-
static Optional<std::string> normalizeTriple(OptSpecifier Opt, int TableIndex,
const ArgList &Args,
DiagnosticsEngine &Diags) {
@@ -2105,6 +2089,7 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
Opts.LLVMArgs = Args.getAllArgValues(OPT_mllvm);
Opts.ASTDumpDecls = Args.hasArg(OPT_ast_dump, OPT_ast_dump_EQ);
Opts.ASTDumpAll = Args.hasArg(OPT_ast_dump_all, OPT_ast_dump_all_EQ);
+ Opts.ModuleMapFiles = Args.getAllArgValues(OPT_fmodule_map_file);
// Only the -fmodule-file=<file> form.
for (const auto *A : Args.filtered(OPT_fmodule_file)) {
StringRef Val = A->getValue();
@@ -4001,8 +3986,7 @@ void CompilerInvocation::generateCC1CommandLine(
(Extracted != \
static_cast<decltype(this->KEYPATH)>( \
(IMPLIED_CHECK) ? (IMPLIED_VALUE) : (DEFAULT_VALUE)))) \
- DENORMALIZER(Args, SPELLING, SA, Option::KIND##Class, TABLE_INDEX, \
- Extracted); \
+ DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, Extracted); \
}(EXTRACTOR(this->KEYPATH)); \
}