diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -260,11 +260,11 @@ class PreprocessorOpts : KeyPathAndMacro<"PreprocessorOpts->", base, "PREPROCESSOR_"> {} class FileSystemOpts - : KeyPathAndMacro<"FileSystemOpts.", base> {} + : KeyPathAndMacro<"FileSystemOpts.", base, "FILE_SYSTEM_"> {} class AnalyzerOpts : KeyPathAndMacro<"AnalyzerOpts->", base, "ANALYZER_"> {} class MigratorOpts - : KeyPathAndMacro<"MigratorOpts.", base> {} + : KeyPathAndMacro<"MigratorOpts.", base, "MIGRATOR_"> {} // A boolean option which is opt-in in CC1. The positive option exists in CC1 and // Args.hasArg(OPT_ffoo) is used to check that the flag is enabled. diff --git a/clang/include/clang/Frontend/CompilerInvocation.h b/clang/include/clang/Frontend/CompilerInvocation.h --- a/clang/include/clang/Frontend/CompilerInvocation.h +++ b/clang/include/clang/Frontend/CompilerInvocation.h @@ -239,15 +239,6 @@ /// @} private: - /// Parse options for flags that expose marshalling information in their - /// table-gen definition - /// - /// \param Args - The argument list containing the arguments to parse - /// \param Diags - The DiagnosticsEngine associated with CreateFromArgs - /// \returns - True if parsing was successful, false otherwise - bool parseSimpleArgs(const llvm::opt::ArgList &Args, - DiagnosticsEngine &Diags); - /// Parse command line options from DiagnosticOptions. static bool ParseDiagnosticArgsRoundTrip(CompilerInvocation &Res, DiagnosticOptions &Opts, diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2155,21 +2155,70 @@ return Success; } -bool CompilerInvocation::parseSimpleArgs(const ArgList &Args, - DiagnosticsEngine &Diags) { +static void GenerateFileSystemArgs(const FileSystemOptions &FileSystemOpts, + SmallVectorImpl &Args, + CompilerInvocation::StringAllocator SA) { +#define FILE_SYSTEM_OPTION_WITH_MARSHALLING( \ + PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ + HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH, \ + DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, \ + MERGER, EXTRACTOR, TABLE_INDEX) \ + GENERATE_OPTION_WITH_MARSHALLING( \ + Args, SA, KIND, FLAGS, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE, \ + IMPLIED_CHECK, IMPLIED_VALUE, DENORMALIZER, EXTRACTOR, TABLE_INDEX) +#include "clang/Driver/Options.inc" +#undef FILE_SYSTEM_OPTION_WITH_MARSHALLING +} + +static bool ParseFileSystemArgs(FileSystemOptions &FileSystemOpts, + const ArgList &Args, DiagnosticsEngine &Diags) { bool Success = true; -#define OPTION_WITH_MARSHALLING( \ +#define FILE_SYSTEM_OPTION_WITH_MARSHALLING( \ PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH, \ DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, \ MERGER, EXTRACTOR, TABLE_INDEX) \ PARSE_OPTION_WITH_MARSHALLING(Args, Diags, Success, ID, FLAGS, PARAM, \ - SHOULD_PARSE, this->KEYPATH, DEFAULT_VALUE, \ + SHOULD_PARSE, KEYPATH, DEFAULT_VALUE, \ IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, \ MERGER, TABLE_INDEX) #include "clang/Driver/Options.inc" -#undef OPTION_WITH_MARSHALLING +#undef FILE_SYSTEM_OPTION_WITH_MARSHALLING + + return Success; +} + +static void GenerateMigratorArgs(const MigratorOptions &MigratorOpts, + SmallVectorImpl &Args, + CompilerInvocation::StringAllocator SA) { +#define MIGRATOR_OPTION_WITH_MARSHALLING( \ + PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ + HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH, \ + DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, \ + MERGER, EXTRACTOR, TABLE_INDEX) \ + GENERATE_OPTION_WITH_MARSHALLING( \ + Args, SA, KIND, FLAGS, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE, \ + IMPLIED_CHECK, IMPLIED_VALUE, DENORMALIZER, EXTRACTOR, TABLE_INDEX) +#include "clang/Driver/Options.inc" +#undef MIGRATOR_OPTION_WITH_MARSHALLING +} + +static bool ParseMigratorArgs(MigratorOptions &MigratorOpts, + const ArgList &Args, DiagnosticsEngine &Diags) { + bool Success = true; + +#define MIGRATOR_OPTION_WITH_MARSHALLING( \ + PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ + HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH, \ + DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, \ + MERGER, EXTRACTOR, TABLE_INDEX) \ + PARSE_OPTION_WITH_MARSHALLING(Args, Diags, Success, ID, FLAGS, PARAM, \ + SHOULD_PARSE, KEYPATH, DEFAULT_VALUE, \ + IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, \ + MERGER, TABLE_INDEX) +#include "clang/Driver/Options.inc" +#undef MIGRATOR_OPTION_WITH_MARSHALLING return Success; } @@ -4487,8 +4536,8 @@ Success = false; } - Success &= Res.parseSimpleArgs(Args, Diags); - + Success &= ParseFileSystemArgs(Res.getFileSystemOpts(), Args, Diags); + Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args, Diags); Success &= ParseAnalyzerArgs(Res, *Res.getAnalyzerOpts(), Args, Diags); Success &= ParseDiagnosticArgsRoundTrip(Res, Res.getDiagnosticOpts(), Args, &Diags, @@ -4702,20 +4751,10 @@ void CompilerInvocation::generateCC1CommandLine( SmallVectorImpl &Args, StringAllocator SA) const { -#define OPTION_WITH_MARSHALLING( \ - PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH, \ - DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, \ - MERGER, EXTRACTOR, TABLE_INDEX) \ - GENERATE_OPTION_WITH_MARSHALLING(Args, SA, KIND, FLAGS, SPELLING, \ - ALWAYS_EMIT, this->KEYPATH, DEFAULT_VALUE, \ - IMPLIED_CHECK, IMPLIED_VALUE, DENORMALIZER, \ - EXTRACTOR, TABLE_INDEX) -#include "clang/Driver/Options.inc" -#undef OPTION_WITH_MARSHALLING - llvm::Triple T(TargetOpts->Triple); + GenerateFileSystemArgs(FileSystemOpts, Args, SA); + GenerateMigratorArgs(MigratorOpts, Args, SA); GenerateAnalyzerArgs(*AnalyzerOpts, Args, SA); GenerateDiagnosticArgs(*DiagnosticOpts, Args, SA, false); GenerateFrontendArgs(FrontendOpts, Args, SA, LangOpts->IsHeaderFile);