[clang] c4a2a13 - Move all fields of '-cc1' option related classes into def file databases

Daniel Grumberg via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 2 05:07:20 PDT 2020


Author: Daniel Grumberg
Date: 2020-09-02T13:07:01+01:00
New Revision: c4a2a1307484cffe94a291c42572775411bac8d8

URL: https://github.com/llvm/llvm-project/commit/c4a2a1307484cffe94a291c42572775411bac8d8
DIFF: https://github.com/llvm/llvm-project/commit/c4a2a1307484cffe94a291c42572775411bac8d8.diff

LOG: Move all fields of '-cc1' option related classes into def file databases

Once the new option parsing system is committed, this will allow to generate a
check to ensure that correct command line generation happens

Differential Revision: https://reviews.llvm.org/D86290

Added: 
    clang/include/clang/Basic/CommentOptions.def
    clang/include/clang/Basic/FileSystemOptions.def
    clang/include/clang/Basic/TargetOptions.def
    clang/include/clang/Frontend/DependencyOutputOptions.def
    clang/include/clang/Frontend/FrontendOptions.def
    clang/include/clang/Frontend/MigratorOptions.def
    clang/include/clang/Frontend/PreprocessorOutputOptions.def
    clang/include/clang/Lex/HeaderSearchOptions.def
    clang/include/clang/Lex/PreprocessorOptions.def
    clang/include/clang/Sema/CodeCompleteOptions.def

Modified: 
    clang/include/clang/Basic/CodeGenOptions.def
    clang/include/clang/Basic/CodeGenOptions.h
    clang/include/clang/Basic/CommentOptions.h
    clang/include/clang/Basic/DiagnosticOptions.def
    clang/include/clang/Basic/DiagnosticOptions.h
    clang/include/clang/Basic/FileSystemOptions.h
    clang/include/clang/Basic/LangOptions.def
    clang/include/clang/Basic/LangOptions.h
    clang/include/clang/Basic/TargetOptions.h
    clang/include/clang/Frontend/CompilerInvocation.h
    clang/include/clang/Frontend/DependencyOutputOptions.h
    clang/include/clang/Frontend/FrontendOptions.h
    clang/include/clang/Frontend/MigratorOptions.h
    clang/include/clang/Frontend/PreprocessorOutputOptions.h
    clang/include/clang/Lex/HeaderSearchOptions.h
    clang/include/clang/Lex/PreprocessorOptions.h
    clang/include/clang/Sema/CodeCompleteOptions.h
    clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
    clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
    clang/lib/Basic/CodeGenOptions.cpp
    clang/lib/Basic/LangOptions.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def
index 8b89aac8d6d5..758dfbc1d283 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -14,17 +14,20 @@
 //
 //===----------------------------------------------------------------------===//
 #ifndef CODEGENOPT
-#  error Define the CODEGENOPT macro to handle language options
+#error Define the CODEGENOPT macro to handle language options
 #endif
 
 #ifndef VALUE_CODEGENOPT
-#  define VALUE_CODEGENOPT(Name, Bits, Default) \
-CODEGENOPT(Name, Bits, Default)
+#define VALUE_CODEGENOPT(Name, Bits, Default) CODEGENOPT(Name, Bits, Default)
 #endif
 
 #ifndef ENUM_CODEGENOPT
-#  define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
-CODEGENOPT(Name, Bits, Default)
+#define ENUM_CODEGENOPT(Name, Type, Bits, Default)                             \
+  CODEGENOPT(Name, Bits, Default)
+#endif
+
+#ifndef TYPED_CODEGENOPT
+#define TYPED_CODEGENOPT(Type, Name, Description)
 #endif
 
 CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
@@ -395,6 +398,226 @@ CODEGENOPT(KeepStaticConsts, 1, 0)
 /// Whether to not follow the AAPCS that enforce at least one read before storing to a volatile bitfield
 CODEGENOPT(ForceAAPCSBitfieldLoad, 1, 0)
 
+TYPED_CODEGENOPT(
+    std::string, BBSections,
+    "This field stores one of the allowed values for the option "
+    "-fbasic-block-sections=.  The allowed values with this option are: "
+    "{\"labels\", \"all\", \"list=<file>\", \"none\"}. \"labels\":      Only "
+    "generate basic block symbols (labels) for all basic blocks, do not "
+    "generate unique sections for basic blocks. Use the machine basic block id "
+    "in the symbol name to associate profile info from virtual address to "
+    "machine basic block. \"all\" :        Generate basic block sections for "
+    "all basic blocks. \"list=<file>\": Generate basic block sections for a "
+    "subset of basic blocks. The functions and the machine basic block ids are "
+    "specified in the file. \"none\":        Disable sections/labels for basic "
+    "blocks.")
+
+TYPED_CODEGENOPT(std::string, CodeModel, "The code model to use (-mcmodel).")
+
+TYPED_CODEGENOPT(std::string, CoverageDataFile,
+                 "The filename with path we use for coverage data files. The "
+                 "runtime allows further manipulation with the GCOV_PREFIX and "
+                 "GCOV_PREFIX_STRIP environment variables. The filename with "
+                 "path we use for coverage notes files.")
+TYPED_CODEGENOPT(std::string, CoverageNotesFile, "")
+
+TYPED_CODEGENOPT(
+    std::string, ProfileFilterFiles,
+    "Regexes separated by a semi-colon to filter the files to instrument.")
+
+TYPED_CODEGENOPT(
+    std::string, ProfileExcludeFiles,
+    "Regexes separated by a semi-colon to filter the files to not instrument.")
+
+TYPED_CODEGENOPT(CoverageVersionTy, CoverageVersion,
+                 "The version string to put into coverage files.")
+
+TYPED_CODEGENOPT(std::string, DebugPass,
+                 "Enable additional debugging information.")
+
+TYPED_CODEGENOPT(std::string, DebugCompilationDir,
+                 "The string to embed in debug information as the current "
+                 "working directory.")
+
+TYPED_CODEGENOPT(std::string, DwarfDebugFlags,
+                 "The string to embed in the debug information for the compile "
+                 "unit, if non-empty.")
+
+TYPED_CODEGENOPT(std::string, RecordCommandLine,
+                 "The string containing the commandline for the "
+                 "llvm.commandline metadata, if non-empty.")
+
+TYPED_CODEGENOPT(DebugPrefixMapTy, DebugPrefixMap, "")
+
+TYPED_CODEGENOPT(std::string, FloatABI,
+                 "The ABI to use for passing floating point arguments.")
+
+TYPED_CODEGENOPT(llvm::DenormalMode, FPDenormalMode,
+                 "The floating-point denormal mode to use.")
+
+TYPED_CODEGENOPT(llvm::DenormalMode, FP32DenormalMode,
+                 "The floating-point denormal mode to use, for float.")
+
+TYPED_CODEGENOPT(std::string, LimitFloatPrecision,
+                 "The float precision limit to use, if non-empty.")
+
+TYPED_CODEGENOPT(std::vector<BitcodeFileToLink>, LinkBitcodeFiles,
+                 "The files specified here are linked in to the module before "
+                 "optimizations.")
+
+TYPED_CODEGENOPT(
+    std::string, MainFileName,
+    "The user provided name for the \"main file\", if non-empty. This is "
+    "useful in situations where the input file name does not match the "
+    "original input file, for example with -save-temps.")
+
+TYPED_CODEGENOPT(std::string, SplitDwarfFile,
+                 "The name for the split debug info file used for the "
+                 "DW_AT_[GNU_]dwo_name attribute in the skeleton CU.")
+
+TYPED_CODEGENOPT(
+    std::string, SplitDwarfOutput,
+    "Output filename for the split debug info, not used in the skeleton CU.")
+
+TYPED_CODEGENOPT(llvm::Reloc::Model, RelocationModel,
+                 "The name of the relocation model to use.")
+
+TYPED_CODEGENOPT(std::string, ThreadModel, "The thread model to use")
+
+TYPED_CODEGENOPT(std::string, TrapFuncName,
+                 "If not an empty string, trap intrinsics are lowered to calls "
+                 "to this function instead of to trap instructions.")
+
+TYPED_CODEGENOPT(std::vector<std::string>, DependentLibraries,
+                 "A list of dependent libraries.")
+
+TYPED_CODEGENOPT(std::vector<std::string>, LinkerOptions,
+                 "A list of linker options to embed in the object file.")
+
+TYPED_CODEGENOPT(
+    std::string, InstrProfileOutput,
+    "Name of the profile file to use as output for -fprofile-instr-generate, "
+    "-fprofile-generate, and -fcs-profile-generate.")
+
+TYPED_CODEGENOPT(std::string, SampleProfileFile,
+                 "Name of the profile file to use with -fprofile-sample-use.")
+
+TYPED_CODEGENOPT(
+    std::string, ProfileInstrumentUsePath,
+    "Name of the profile file to use as input for -fprofile-instr-use")
+
+TYPED_CODEGENOPT(
+    std::string, ProfileRemappingFile,
+    "Name of the profile remapping file to apply to the profile data supplied "
+    "by -fprofile-sample-use or -fprofile-instr-use.")
+
+TYPED_CODEGENOPT(std::string, ThinLTOIndexFile,
+                 "Name of the function summary index file to use for ThinLTO "
+                 "function importing.")
+
+TYPED_CODEGENOPT(
+    std::string, ThinLinkBitcodeFile,
+    "Name of a file that can optionally be written with minimized bitcode to "
+    "be used as input for the ThinLTO thin link step, which only needs the "
+    "summary and module symbol table (and not, e.g. any debug metadata).")
+
+TYPED_CODEGENOPT(std::string, SaveTempsFilePrefix,
+                 "Prefix to use for -save-temps output.")
+
+TYPED_CODEGENOPT(
+    std::string, CudaGpuBinaryFileName,
+    "Name of file passed with -fcuda-include-gpubinary option to forward to "
+    "CUDA runtime back-end for incorporating them into host-side object file.")
+
+TYPED_CODEGENOPT(std::string, OptRecordFile,
+                 "The name of the file to which the backend should save YAML "
+                 "optimization records.")
+
+TYPED_CODEGENOPT(std::string, OptRecordPasses,
+                 "The regex that filters the passes that should be saved to "
+                 "the optimization records.")
+
+TYPED_CODEGENOPT(std::string, OptRecordFormat,
+                 "The format used for serializing remarks (default: YAML)")
+
+TYPED_CODEGENOPT(
+    std::string, SymbolPartition,
+    "The name of the partition that symbols are assigned to, specified with "
+    "-fsymbol-partition (see https://lld.llvm.org/Partitions.html).")
+
+TYPED_CODEGENOPT(
+    std::shared_ptr<llvm::Regex>, OptimizationRemarkPattern,
+    "Regular expression to select optimizations for which we should enable "
+    "optimization remarks. Transformation passes whose name matches this "
+    "expression (and support this feature), will emit a diagnostic whenever "
+    "they perform a transformation. This is enabled by the -Rpass=regexp flag.")
+
+TYPED_CODEGENOPT(
+    std::shared_ptr<llvm::Regex>, OptimizationRemarkMissedPattern,
+    "Regular expression to select optimizations for which we should enable "
+    "missed optimization remarks. Transformation passes whose name matches "
+    "this expression (and support this feature), will emit a diagnostic "
+    "whenever they tried but failed to perform a transformation. This is "
+    "enabled by the -Rpass-missed=regexp flag.")
+
+TYPED_CODEGENOPT(
+    std::shared_ptr<llvm::Regex>, OptimizationRemarkAnalysisPattern,
+    "Regular expression to select optimizations for which we should enable "
+    "optimization analyses. Transformation passes whose name matches this "
+    "expression (and support this feature), will emit a diagnostic whenever "
+    "they want to explain why they decided to apply or not apply a given "
+    "transformation. This is enabled by the -Rpass-analysis=regexp flag.")
+
+TYPED_CODEGENOPT(std::vector<std::string>, RewriteMapFiles,
+                 "Set of files defining the rules for the symbol rewriting.")
+
+TYPED_CODEGENOPT(SanitizerSet, SanitizeRecover,
+                 "Set of sanitizer checks that are non-fatal (i.e. execution "
+                 "should be continued when possible).")
+
+TYPED_CODEGENOPT(SanitizerSet, SanitizeTrap,
+                 "Set of sanitizer checks that trap rather than diagnose.")
+
+TYPED_CODEGENOPT(std::vector<uint8_t>, CmdArgs,
+                 "List of backend command-line options for -fembed-bitcode.")
+
+TYPED_CODEGENOPT(std::vector<std::string>, NoBuiltinFuncs,
+                 "A list of all -fno-builtin-* function names (e.g., memset).")
+
+TYPED_CODEGENOPT(std::vector<std::string>, Reciprocals, "")
+
+TYPED_CODEGENOPT(std::string, PreferVectorWidth,
+                 "The preferred width for auto-vectorization transforms. This "
+                 "is intended to override default transforms based on the "
+                 "width of the architected vector registers.")
+
+TYPED_CODEGENOPT(XRayInstrSet, XRayInstrumentationBundle,
+                 "Set of XRay instrumentation kinds to emit.")
+
+TYPED_CODEGENOPT(std::vector<std::string>, DefaultFunctionAttrs, "")
+
+TYPED_CODEGENOPT(
+    std::vector<std::string>, PassPlugins,
+    "List of dynamic shared object files to be loaded as pass plugins.")
+
+TYPED_CODEGENOPT(
+    std::vector<std::string>, SanitizeCoverageAllowlistFiles,
+    "Path to allowlist file specifying which objects (files, functions) should "
+    "exclusively be instrumented by sanitizer coverage pass.")
+
+TYPED_CODEGENOPT(std::vector<std::string>, SanitizeCoverageBlocklistFiles,
+                 "Path to blocklist file specifying which objects (files, "
+                 "functions) listed for instrumentation by sanitizer coverage "
+                 "pass should actually not be instrumented.")
+
+TYPED_CODEGENOPT(
+    const char *, Argv0,
+    "Executable and command-line used to create a given CompilerInvocation. "
+    "Most of the time this will be the full -cc1 command.")
+
+TYPED_CODEGENOPT(ArrayRef<const char *>, CommandLineArgs, "")
+
 #undef CODEGENOPT
 #undef ENUM_CODEGENOPT
 #undef VALUE_CODEGENOPT
+#undef TYPED_CODEGENOPT

diff  --git a/clang/include/clang/Basic/CodeGenOptions.h b/clang/include/clang/Basic/CodeGenOptions.h
index ca391bf8f186..093f4014ae8c 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -110,75 +110,15 @@ class CodeGenOptions : public CodeGenOptionsBase {
     Embed_Marker    // Embed a marker as a placeholder for bitcode.
   };
 
-  // This field stores one of the allowed values for the option
-  // -fbasic-block-sections=.  The allowed values with this option are:
-  // {"labels", "all", "list=<file>", "none"}.
-  //
-  // "labels":      Only generate basic block symbols (labels) for all basic
-  //                blocks, do not generate unique sections for basic blocks.
-  //                Use the machine basic block id in the symbol name to
-  //                associate profile info from virtual address to machine
-  //                basic block.
-  // "all" :        Generate basic block sections for all basic blocks.
-  // "list=<file>": Generate basic block sections for a subset of basic blocks.
-  //                The functions and the machine basic block ids are specified
-  //                in the file.
-  // "none":        Disable sections/labels for basic blocks.
-  std::string BBSections;
-
   enum class FramePointerKind {
     None,        // Omit all frame pointers.
     NonLeaf,     // Keep non-leaf frame pointers.
     All,         // Keep all frame pointers.
   };
 
-  /// The code model to use (-mcmodel).
-  std::string CodeModel;
-
-  /// The filename with path we use for coverage data files. The runtime
-  /// allows further manipulation with the GCOV_PREFIX and GCOV_PREFIX_STRIP
-  /// environment variables.
-  std::string CoverageDataFile;
-
-  /// The filename with path we use for coverage notes files.
-  std::string CoverageNotesFile;
-
-  /// Regexes separated by a semi-colon to filter the files to instrument.
-  std::string ProfileFilterFiles;
-
-  /// Regexes separated by a semi-colon to filter the files to not instrument.
-  std::string ProfileExcludeFiles;
-
-  /// The version string to put into coverage files.
-  char CoverageVersion[4];
-
-  /// Enable additional debugging information.
-  std::string DebugPass;
-
-  /// The string to embed in debug information as the current working directory.
-  std::string DebugCompilationDir;
-
-  /// The string to embed in the debug information for the compile unit, if
-  /// non-empty.
-  std::string DwarfDebugFlags;
-
-  /// The string containing the commandline for the llvm.commandline metadata,
-  /// if non-empty.
-  std::string RecordCommandLine;
-
-  std::map<std::string, std::string> DebugPrefixMap;
-
-  /// The ABI to use for passing floating point arguments.
-  std::string FloatABI;
-
-  /// The floating-point denormal mode to use.
-  llvm::DenormalMode FPDenormalMode = llvm::DenormalMode::getIEEE();
+  using DebugPrefixMapTy = std::map<std::string, std::string>;
 
-  /// The floating-point denormal mode to use, for float.
-  llvm::DenormalMode FP32DenormalMode = llvm::DenormalMode::getIEEE();
-
-  /// The float precision limit to use, if non-empty.
-  std::string LimitFloatPrecision;
+  using CoverageVersionTy = char[4];
 
   struct BitcodeFileToLink {
     /// The filename of the bitcode file to link in.
@@ -193,156 +133,14 @@ class CodeGenOptions : public CodeGenOptionsBase {
     unsigned LinkFlags = 0;
   };
 
-  /// The files specified here are linked in to the module before optimizations.
-  std::vector<BitcodeFileToLink> LinkBitcodeFiles;
-
-  /// The user provided name for the "main file", if non-empty. This is useful
-  /// in situations where the input file name does not match the original input
-  /// file, for example with -save-temps.
-  std::string MainFileName;
-
-  /// The name for the split debug info file used for the DW_AT_[GNU_]dwo_name
-  /// attribute in the skeleton CU.
-  std::string SplitDwarfFile;
-
-  /// Output filename for the split debug info, not used in the skeleton CU.
-  std::string SplitDwarfOutput;
-
-  /// The name of the relocation model to use.
-  llvm::Reloc::Model RelocationModel;
-
-  /// The thread model to use
-  std::string ThreadModel;
-
-  /// If not an empty string, trap intrinsics are lowered to calls to this
-  /// function instead of to trap instructions.
-  std::string TrapFuncName;
-
-  /// A list of dependent libraries.
-  std::vector<std::string> DependentLibraries;
-
-  /// A list of linker options to embed in the object file.
-  std::vector<std::string> LinkerOptions;
-
-  /// Name of the profile file to use as output for -fprofile-instr-generate,
-  /// -fprofile-generate, and -fcs-profile-generate.
-  std::string InstrProfileOutput;
-
-  /// Name of the profile file to use with -fprofile-sample-use.
-  std::string SampleProfileFile;
-
-  /// Name of the profile file to use as input for -fprofile-instr-use
-  std::string ProfileInstrumentUsePath;
-
-  /// Name of the profile remapping file to apply to the profile data supplied
-  /// by -fprofile-sample-use or -fprofile-instr-use.
-  std::string ProfileRemappingFile;
-
-  /// Name of the function summary index file to use for ThinLTO function
-  /// importing.
-  std::string ThinLTOIndexFile;
-
-  /// Name of a file that can optionally be written with minimized bitcode
-  /// to be used as input for the ThinLTO thin link step, which only needs
-  /// the summary and module symbol table (and not, e.g. any debug metadata).
-  std::string ThinLinkBitcodeFile;
-
-  /// Prefix to use for -save-temps output.
-  std::string SaveTempsFilePrefix;
-
-  /// Name of file passed with -fcuda-include-gpubinary option to forward to
-  /// CUDA runtime back-end for incorporating them into host-side object file.
-  std::string CudaGpuBinaryFileName;
-
-  /// The name of the file to which the backend should save YAML optimization
-  /// records.
-  std::string OptRecordFile;
-
-  /// The regex that filters the passes that should be saved to the optimization
-  /// records.
-  std::string OptRecordPasses;
-
-  /// The format used for serializing remarks (default: YAML)
-  std::string OptRecordFormat;
-
-  /// The name of the partition that symbols are assigned to, specified with
-  /// -fsymbol-partition (see https://lld.llvm.org/Partitions.html).
-  std::string SymbolPartition;
-
-  /// Regular expression to select optimizations for which we should enable
-  /// optimization remarks. Transformation passes whose name matches this
-  /// expression (and support this feature), will emit a diagnostic
-  /// whenever they perform a transformation. This is enabled by the
-  /// -Rpass=regexp flag.
-  std::shared_ptr<llvm::Regex> OptimizationRemarkPattern;
-
-  /// Regular expression to select optimizations for which we should enable
-  /// missed optimization remarks. Transformation passes whose name matches this
-  /// expression (and support this feature), will emit a diagnostic
-  /// whenever they tried but failed to perform a transformation. This is
-  /// enabled by the -Rpass-missed=regexp flag.
-  std::shared_ptr<llvm::Regex> OptimizationRemarkMissedPattern;
-
-  /// Regular expression to select optimizations for which we should enable
-  /// optimization analyses. Transformation passes whose name matches this
-  /// expression (and support this feature), will emit a diagnostic
-  /// whenever they want to explain why they decided to apply or not apply
-  /// a given transformation. This is enabled by the -Rpass-analysis=regexp
-  /// flag.
-  std::shared_ptr<llvm::Regex> OptimizationRemarkAnalysisPattern;
-
-  /// Set of files defining the rules for the symbol rewriting.
-  std::vector<std::string> RewriteMapFiles;
-
-  /// Set of sanitizer checks that are non-fatal (i.e. execution should be
-  /// continued when possible).
-  SanitizerSet SanitizeRecover;
-
-  /// Set of sanitizer checks that trap rather than diagnose.
-  SanitizerSet SanitizeTrap;
-
-  /// List of backend command-line options for -fembed-bitcode.
-  std::vector<uint8_t> CmdArgs;
-
-  /// A list of all -fno-builtin-* function names (e.g., memset).
-  std::vector<std::string> NoBuiltinFuncs;
-
-  std::vector<std::string> Reciprocals;
-
-  /// The preferred width for auto-vectorization transforms. This is intended to
-  /// override default transforms based on the width of the architected vector
-  /// registers.
-  std::string PreferVectorWidth;
-
-  /// Set of XRay instrumentation kinds to emit.
-  XRayInstrSet XRayInstrumentationBundle;
-
-  std::vector<std::string> DefaultFunctionAttrs;
-
-  /// List of dynamic shared object files to be loaded as pass plugins.
-  std::vector<std::string> PassPlugins;
-
-  /// Path to allowlist file specifying which objects
-  /// (files, functions) should exclusively be instrumented
-  /// by sanitizer coverage pass.
-  std::vector<std::string> SanitizeCoverageAllowlistFiles;
-
-  /// Path to blocklist file specifying which objects
-  /// (files, functions) listed for instrumentation by sanitizer
-  /// coverage pass should actually not be instrumented.
-  std::vector<std::string> SanitizeCoverageBlocklistFiles;
-
-  /// Executable and command-line used to create a given CompilerInvocation.
-  /// Most of the time this will be the full -cc1 command.
-  const char *Argv0 = nullptr;
-  ArrayRef<const char *> CommandLineArgs;
 
 public:
   // Define accessors/mutators for code generation options of enumeration type.
 #define CODEGENOPT(Name, Bits, Default)
-#define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
-  Type get##Name() const { return static_cast<Type>(Name); } \
+#define ENUM_CODEGENOPT(Name, Type, Bits, Default)                             \
+  Type get##Name() const { return static_cast<Type>(Name); }                   \
   void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
+#define TYPED_CODEGENOPT(Type, Name, Description) Type Name;
 #include "clang/Basic/CodeGenOptions.def"
 
   CodeGenOptions();

diff  --git a/clang/include/clang/Basic/CommentOptions.def b/clang/include/clang/Basic/CommentOptions.def
new file mode 100644
index 000000000000..537f9eb34bd4
--- /dev/null
+++ b/clang/include/clang/Basic/CommentOptions.def
@@ -0,0 +1,26 @@
+//===--- CommentOptions.def - Comment option database -------------*- C++
+//-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the comment options. Users of this file must
+// define the TYPED_COMMENTOPT macro to make use of this information.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TYPED_COMMENTOPT
+#define TYPED_COMMENTOPT(Type, Name, Description)
+#endif
+
+TYPED_COMMENTOPT(BlockCommandNamesTy, BlockCommandNames,
+                 "Command names to treat as vlock commands in comments. Should "
+                 "not include the leading backslash.")
+
+TYPED_COMMENTOPT(bool, ParseAllComments,
+                 "Treat ordinary comments as documentation comments")
+
+#undef TYPED_COMMENTOPT

diff  --git a/clang/include/clang/Basic/CommentOptions.h b/clang/include/clang/Basic/CommentOptions.h
index 7d142fc32f51..149650e6192a 100644
--- a/clang/include/clang/Basic/CommentOptions.h
+++ b/clang/include/clang/Basic/CommentOptions.h
@@ -23,14 +23,10 @@ namespace clang {
 struct CommentOptions {
   using BlockCommandNamesTy = std::vector<std::string>;
 
-  /// Command names to treat as block commands in comments.
-  /// Should not include the leading backslash.
-  BlockCommandNamesTy BlockCommandNames;
+#define TYPED_COMMENTOPT(Type, Name, Description) Type Name;
+#include "clang/Basic/CommentOptions.def"
 
-  /// Treat ordinary comments as documentation comments.
-  bool ParseAllComments = false;
-
-  CommentOptions() = default;
+  CommentOptions() : ParseAllComments(false) {}
 };
 
 } // namespace clang

diff  --git a/clang/include/clang/Basic/DiagnosticOptions.def b/clang/include/clang/Basic/DiagnosticOptions.def
index a946b5c6be8e..35b01b8c5ce0 100644
--- a/clang/include/clang/Basic/DiagnosticOptions.def
+++ b/clang/include/clang/Basic/DiagnosticOptions.def
@@ -43,6 +43,10 @@ DIAGOPT(Name, Bits, Default)
      ENUM_DIAGOPT(Name, Type, Bits, Default)
 #endif
 
+#ifndef TYPED_DIAGOPT
+#define TYPED_DIAGOPT(Type, Name, Description)
+#endif
+
 SEMANTIC_DIAGOPT(IgnoreWarnings, 1, 0)   /// -w
 DIAGOPT(NoRewriteMacros, 1, 0)  /// -Wno-rewrite-macros
 DIAGOPT(Pedantic, 1, 0)         /// -pedantic
@@ -95,9 +99,32 @@ VALUE_DIAGOPT(TabStop, 32, DefaultTabStop) /// The distance between tab stops.
 /// Column limit for formatting message diagnostics, or 0 if unused.
 VALUE_DIAGOPT(MessageLength, 32, 0)
 
+TYPED_DIAGOPT(std::string, DiagnosticLogFile,
+              "The file to log diagnostic output to.")
+
+TYPED_DIAGOPT(std::string, DiagnosticSerializationFile,
+              "The file to serialize diagnostics to (non-appending).")
+
+TYPED_DIAGOPT(std::vector<std::string>, Warnings,
+              "The list of -W... options used to alter the diagnostic "
+              "mappings, with the prefixes removed.")
+
+TYPED_DIAGOPT(std::vector<std::string>, UndefPrefixes,
+              "The list of prefixes from -Wundef-prefix=... used to generate "
+              "warnings for undefined macros.")
+
+TYPED_DIAGOPT(std::vector<std::string>, Remarks,
+              "The list of -R... options used to alter the diagnostic "
+              "mappings, with the prefixes removed.")
+
+TYPED_DIAGOPT(std::vector<std::string>, VerifyPrefixes,
+              "The prefixes for comment directives sought by -verify "
+              "(\"expected\" by /// default).")
+
 #undef DIAGOPT
 #undef ENUM_DIAGOPT
 #undef VALUE_DIAGOPT
 #undef SEMANTIC_DIAGOPT
 #undef SEMANTIC_ENUM_DIAGOPT
 #undef SEMANTIC_VALUE_DIAGOPT
+#undef TYPED_DIAGOPT

diff  --git a/clang/include/clang/Basic/DiagnosticOptions.h b/clang/include/clang/Basic/DiagnosticOptions.h
index 7fbe534c5994..2b6bd1fd2be5 100644
--- a/clang/include/clang/Basic/DiagnosticOptions.h
+++ b/clang/include/clang/Basic/DiagnosticOptions.h
@@ -88,31 +88,9 @@ class DiagnosticOptions : public RefCountedBase<DiagnosticOptions>{
 #include "clang/Basic/DiagnosticOptions.def"
 
 public:
-  /// The file to log diagnostic output to.
-  std::string DiagnosticLogFile;
-
-  /// The file to serialize diagnostics to (non-appending).
-  std::string DiagnosticSerializationFile;
-
-  /// The list of -W... options used to alter the diagnostic mappings, with the
-  /// prefixes removed.
-  std::vector<std::string> Warnings;
-
-  /// The list of prefixes from -Wundef-prefix=... used to generate warnings
-  /// for undefined macros.
-  std::vector<std::string> UndefPrefixes;
-
-  /// The list of -R... options used to alter the diagnostic mappings, with the
-  /// prefixes removed.
-  std::vector<std::string> Remarks;
-
-  /// The prefixes for comment directives sought by -verify ("expected" by
-  /// default).
-  std::vector<std::string> VerifyPrefixes;
-
-public:
-  // Define accessors/mutators for diagnostic options of enumeration type.
+#define TYPED_DIAGOPT(Type, Name, Description) Type Name;
 #define DIAGOPT(Name, Bits, Default)
+// Define accessors/mutators for diagnostic options of enumeration type.
 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \
   Type get##Name() const { return static_cast<Type>(Name); } \
   void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }

diff  --git a/clang/include/clang/Basic/FileSystemOptions.def b/clang/include/clang/Basic/FileSystemOptions.def
new file mode 100644
index 000000000000..794e9871998e
--- /dev/null
+++ b/clang/include/clang/Basic/FileSystemOptions.def
@@ -0,0 +1,21 @@
+//===--- FileSystemOptions.def - FileSystem option database -----*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the FileSystem options.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TYPED_FILESYSTEMOPT
+#error define TYPED_FILESYSTEMOPT macro to hand filesystem options
+#endif
+
+TYPED_FILESYSTEMOPT(std::string, WorkingDir,
+              "If set, paths are resolved as if the working directory was set "
+              "to the value of WorkingDir.")
+
+#undef TYPED_FILESYSTEMOPT

diff  --git a/clang/include/clang/Basic/FileSystemOptions.h b/clang/include/clang/Basic/FileSystemOptions.h
index 458af0c7b659..4fd0851145a2 100644
--- a/clang/include/clang/Basic/FileSystemOptions.h
+++ b/clang/include/clang/Basic/FileSystemOptions.h
@@ -21,9 +21,8 @@ namespace clang {
 /// Keeps track of options that affect how file operations are performed.
 class FileSystemOptions {
 public:
-  /// If set, paths are resolved as if the working directory was
-  /// set to the value of WorkingDir.
-  std::string WorkingDir;
+#define TYPED_FILESYSTEMOPT(Type, Name, Description) Type Name;
+#include "clang/Basic/FileSystemOptions.def"
 };
 
 } // end namespace clang

diff  --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def
index c458e7014d62..d7bba5426c2a 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -78,6 +78,10 @@
      COMPATIBLE_VALUE_LANGOPT(Name, Bits, Default, Description)
 #endif
 
+#ifndef TYPED_LANGOPT
+#define TYPED_LANGOPT(Type, Name, Descritpion)
+#endif
+
 // FIXME: A lot of the BENIGN_ options should be COMPATIBLE_ instead.
 LANGOPT(C99               , 1, 0, "C99")
 LANGOPT(C11               , 1, 0, "C11")
@@ -384,6 +388,73 @@ LANGOPT(RelativeCXXABIVTables, 1, 0,
 
 LANGOPT(ArmSveVectorBits, 32, 0, "SVE vector size in bits")
 
+TYPED_LANGOPT(SanitizerSet, Sanitize, "Set of enabled sanitizers.")
+
+TYPED_LANGOPT(std::vector<std::string>, SanitizerBlacklistFiles,
+              "Paths to blacklist files specifying which objects (files, "
+              "functions, variables) should not be instrumented.")
+
+TYPED_LANGOPT(std::vector<std::string>, XRayAlwaysInstrumentFiles,
+              "Paths to the XRay \"always instrument\" files specifying which "
+              "objects (files, functions, variables) should be imbued with the "
+              "XRay \"always instrument\" attribute. WARNING: This is a "
+              "deprecated field and will go away in the future.")
+
+TYPED_LANGOPT(std::vector<std::string>, XRayNeverInstrumentFiles,
+              "Paths to the XRay \"never instrument\" files specifying which "
+              "objects (files, functions, variables) should be imbued with the "
+              "XRay \"never instrument\" attribute. WARNING: This is a "
+              "deprecated field and will go away in the future.")
+
+TYPED_LANGOPT(std::vector<std::string>, XRayAttrListFiles,
+              "Paths to the XRay attribute list files, specifying which "
+              "objects (files, functions, variables) should be imbued with the "
+              "appropriate XRay attribute(s).")
+
+TYPED_LANGOPT(clang::ObjCRuntime, ObjCRuntime, "")
+
+TYPED_LANGOPT(CoreFoundationABI, CFRuntime, "")
+
+TYPED_LANGOPT(std::string, ObjCConstantStringClass, "")
+
+TYPED_LANGOPT(
+    std::string, OverflowHandler,
+    "The name of the handler function to be called when -ftrapv is specified. "
+    "If none is specified, abort (GCC-compatible behaviour).")
+
+TYPED_LANGOPT(
+    std::string, ModuleName,
+    "The module currently being compiled as specified by -fmodule-name.")
+
+TYPED_LANGOPT(
+    std::string, CurrentModule,
+    "The name of the current module, of which the main source file is a part. "
+    "If CompilingModule is set, we are compiling the interface of this module, "
+    "otherwise we are compiling an implementation file of it. This starts as "
+    "ModuleName in case -fmodule-name is provided and changes during "
+    "compilation to reflect the current module.")
+
+TYPED_LANGOPT(std::vector<std::string>, ModuleFeatures,
+              "The names of any features to enable in module 'requires' decls "
+              "in addition to the hard-coded list in Module.cpp and the target "
+              "features. This list is sorted.")
+
+TYPED_LANGOPT(std::vector<std::string>, NoBuiltinFuncs,
+              "A list of all -fno-builtin-* function names (e.g., memset).")
+
+TYPED_LANGOPT(
+    std::vector<llvm::Triple>, OMPTargetTriples,
+    "Triples of the OpenMP targets that the host code codegen should take into "
+    "account in order to generate accurate offloading descriptors.")
+
+TYPED_LANGOPT(std::string, OMPHostIRFile,
+              "Name of the IR file that contains the result of the OpenMP "
+              "target host code generation.")
+
+TYPED_LANGOPT(bool, IsHeaderFile,
+              "Indicates whether the front-end is explicitly told that the "
+              "input is a header file (i.e. -x c-header).")
+
 #undef LANGOPT
 #undef COMPATIBLE_LANGOPT
 #undef BENIGN_LANGOPT
@@ -393,3 +464,4 @@ LANGOPT(ArmSveVectorBits, 32, 0, "SVE vector size in bits")
 #undef VALUE_LANGOPT
 #undef COMPATIBLE_VALUE_LANGOPT
 #undef BENIGN_VALUE_LANGOPT
+#undef TYPED_LANGOPT

diff  --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h
index 4e277435bf8f..6af97fd5b2a7 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -227,75 +227,12 @@ class LangOptions : public LangOptionsBase {
   };
 
 public:
-  /// Set of enabled sanitizers.
-  SanitizerSet Sanitize;
-
-  /// Paths to blacklist files specifying which objects
-  /// (files, functions, variables) should not be instrumented.
-  std::vector<std::string> SanitizerBlacklistFiles;
-
-  /// Paths to the XRay "always instrument" files specifying which
-  /// objects (files, functions, variables) should be imbued with the XRay
-  /// "always instrument" attribute.
-  /// WARNING: This is a deprecated field and will go away in the future.
-  std::vector<std::string> XRayAlwaysInstrumentFiles;
-
-  /// Paths to the XRay "never instrument" files specifying which
-  /// objects (files, functions, variables) should be imbued with the XRay
-  /// "never instrument" attribute.
-  /// WARNING: This is a deprecated field and will go away in the future.
-  std::vector<std::string> XRayNeverInstrumentFiles;
-
-  /// Paths to the XRay attribute list files, specifying which objects
-  /// (files, functions, variables) should be imbued with the appropriate XRay
-  /// attribute(s).
-  std::vector<std::string> XRayAttrListFiles;
-
-  clang::ObjCRuntime ObjCRuntime;
-
-  CoreFoundationABI CFRuntime = CoreFoundationABI::Unspecified;
-
-  std::string ObjCConstantStringClass;
-
-  /// The name of the handler function to be called when -ftrapv is
-  /// specified.
-  ///
-  /// If none is specified, abort (GCC-compatible behaviour).
-  std::string OverflowHandler;
-
-  /// The module currently being compiled as specified by -fmodule-name.
-  std::string ModuleName;
-
-  /// The name of the current module, of which the main source file
-  /// is a part. If CompilingModule is set, we are compiling the interface
-  /// of this module, otherwise we are compiling an implementation file of
-  /// it. This starts as ModuleName in case -fmodule-name is provided and
-  /// changes during compilation to reflect the current module.
-  std::string CurrentModule;
-
-  /// The names of any features to enable in module 'requires' decls
-  /// in addition to the hard-coded list in Module.cpp and the target features.
-  ///
-  /// This list is sorted.
-  std::vector<std::string> ModuleFeatures;
-
   /// Options for parsing comments.
   CommentOptions CommentOpts;
 
-  /// A list of all -fno-builtin-* function names (e.g., memset).
-  std::vector<std::string> NoBuiltinFuncs;
-
-  /// Triples of the OpenMP targets that the host code codegen should
-  /// take into account in order to generate accurate offloading descriptors.
-  std::vector<llvm::Triple> OMPTargetTriples;
-
-  /// Name of the IR file that contains the result of the OpenMP target
-  /// host code generation.
-  std::string OMPHostIRFile;
-
-  /// Indicates whether the front-end is explicitly told that the
-  /// input is a header file (i.e. -x c-header).
-  bool IsHeaderFile = false;
+#define LANGOPT(Name, Bits, Default, Description)
+#define TYPED_LANGOPT(Type, Name, Description) Type Name;
+#include "clang/Basic/LangOptions.def"
 
   LangOptions();
 

diff  --git a/clang/include/clang/Basic/TargetOptions.def b/clang/include/clang/Basic/TargetOptions.def
new file mode 100644
index 000000000000..33e746f012ce
--- /dev/null
+++ b/clang/include/clang/Basic/TargetOptions.def
@@ -0,0 +1,88 @@
+//===--- TargetOptions.def - Target option database -------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the target options. Users of this file must
+// define the TYPED_TARGETOPT macro to make use of this information.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TYPED_TARGETOPT
+#error Define the TYPED_TARGETOPT macro to handle target options
+#endif
+
+TYPED_TARGETOPT(std::string, Triple,
+                "The name of the target triple to compile for.")
+
+TYPED_TARGETOPT(
+    std::string, HostTriple,
+    "When compiling for the device side, contains the triple used to "
+    "compile for the host.")
+
+TYPED_TARGETOPT(std::string, CPU,
+                "If given, the name of the target CPU to generate code for.")
+
+TYPED_TARGETOPT(std::string, TuneCPU,
+                "If given, the name of the target CPU to tune code for.")
+
+TYPED_TARGETOPT(std::string, FPMath,
+                "If given, the unit to use for floating point math.")
+
+TYPED_TARGETOPT(std::string, ABI,
+                "If given, the name of the target ABI to use.")
+
+TYPED_TARGETOPT(llvm::EABI, EABIVersion, "The EABI version to use.")
+
+TYPED_TARGETOPT(std::string, LinkerVersion,
+                "If given, the version string of the linker in use.")
+
+TYPED_TARGETOPT(std::vector<std::string>, FeaturesAsWritten,
+                "The list of target specific features to enable or disable, as "
+                "written on the command line.")
+
+TYPED_TARGETOPT(
+    std::vector<std::string>, Features,
+    "The list of target specific features to enable or disable -- this "
+    "should be a list of strings starting with by '+' or '-'.")
+
+TYPED_TARGETOPT(llvm::StringMap<bool>, FeatureMap,
+                "The map of which features have been enabled disabled based on "
+                "the command line.")
+
+TYPED_TARGETOPT(OpenCLOptions, SupportedOpenCLOptions,
+                "Supported OpenCL extensions and optional core features.")
+
+TYPED_TARGETOPT(
+    std::vector<std::string>, OpenCLExtensionsAsWritten,
+    "The list of OpenCL extensions to enable or disable, as written on "
+    "the command line.")
+
+TYPED_TARGETOPT(
+    bool, ForceEnableInt128,
+    "If given, enables support for __int128_t and __uint128_t types.")
+
+TYPED_TARGETOPT(
+    bool, NVPTXUseShortPointers,
+    "If enabled, use 32-bit pointers for accessing const/local/shared "
+    "address space.")
+
+TYPED_TARGETOPT(
+    std::string, CodeModel,
+    "The code model to be used as specified by the user. Corresponds to "
+    "CodeModel::Model enum defined in include/llvm/Support/CodeGen.h, "
+    "plus \"default\" for the case when the user has not explicitly "
+    "specified a code model.")
+
+TYPED_TARGETOPT(
+    llvm::VersionTuple, SDKVersion,
+    "The version of the SDK which was used during the compilation. The option "
+    "is used for two 
diff erent purposes. On Darwin the version is propagated "
+    "to LLVM where it's used to support SDK Version metadata (See D55673). "
+    "CUDA compilation uses it to control parts of CUDA compilation in clang "
+    "that depend on specific version of the CUDA SDK.")
+
+#undef TYPED_TARGETOPT

diff  --git a/clang/include/clang/Basic/TargetOptions.h b/clang/include/clang/Basic/TargetOptions.h
index d1cc024957da..1771c3bdbb61 100644
--- a/clang/include/clang/Basic/TargetOptions.h
+++ b/clang/include/clang/Basic/TargetOptions.h
@@ -25,69 +25,9 @@ namespace clang {
 /// Options for controlling the target.
 class TargetOptions {
 public:
-  /// The name of the target triple to compile for.
-  std::string Triple;
-
-  /// When compiling for the device side, contains the triple used to compile
-  /// for the host.
-  std::string HostTriple;
-
-  /// If given, the name of the target CPU to generate code for.
-  std::string CPU;
-
-  /// If given, the name of the target CPU to tune code for.
-  std::string TuneCPU;
-
-  /// If given, the unit to use for floating point math.
-  std::string FPMath;
-
-  /// If given, the name of the target ABI to use.
-  std::string ABI;
-
-  /// The EABI version to use
-  llvm::EABI EABIVersion;
-
-  /// If given, the version string of the linker in use.
-  std::string LinkerVersion;
-
-  /// The list of target specific features to enable or disable, as written on the command line.
-  std::vector<std::string> FeaturesAsWritten;
-
-  /// The list of target specific features to enable or disable -- this should
-  /// be a list of strings starting with by '+' or '-'.
-  std::vector<std::string> Features;
-
-  /// The map of which features have been enabled disabled based on the command
-  /// line.
-  llvm::StringMap<bool> FeatureMap;
-
-  /// Supported OpenCL extensions and optional core features.
-  OpenCLOptions SupportedOpenCLOptions;
-
-  /// The list of OpenCL extensions to enable or disable, as written on
-  /// the command line.
-  std::vector<std::string> OpenCLExtensionsAsWritten;
-
-  /// If given, enables support for __int128_t and __uint128_t types.
-  bool ForceEnableInt128 = false;
-
-  /// \brief If enabled, use 32-bit pointers for accessing const/local/shared
-  /// address space.
-  bool NVPTXUseShortPointers = false;
-
-  // The code model to be used as specified by the user. Corresponds to
-  // CodeModel::Model enum defined in include/llvm/Support/CodeGen.h, plus
-  // "default" for the case when the user has not explicitly specified a
-  // code model.
-  std::string CodeModel;
-
-  /// The version of the SDK which was used during the compilation.
-  /// The option is used for two 
diff erent purposes:
-  /// * on darwin the version is propagated to LLVM where it's used
-  ///   to support SDK Version metadata (See D55673).
-  /// * CUDA compilation uses it to control parts of CUDA compilation
-  ///   in clang that depend on specific version of the CUDA SDK.
-  llvm::VersionTuple SDKVersion;
+#define TYPED_TARGETOPT(Type, Name, Description) Type Name;
+#include "clang/Basic/TargetOptions.def"
+  TargetOptions() : ForceEnableInt128(false), NVPTXUseShortPointers(false) {}
 };
 
 }  // end namespace clang

diff  --git a/clang/include/clang/Frontend/CompilerInvocation.h b/clang/include/clang/Frontend/CompilerInvocation.h
index c723fc084c85..c8a95ae69d72 100644
--- a/clang/include/clang/Frontend/CompilerInvocation.h
+++ b/clang/include/clang/Frontend/CompilerInvocation.h
@@ -19,9 +19,10 @@
 #include "clang/Frontend/FrontendOptions.h"
 #include "clang/Frontend/MigratorOptions.h"
 #include "clang/Frontend/PreprocessorOutputOptions.h"
+#include "clang/Sema/CodeCompleteOptions.h"
 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
-#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include <memory>
 #include <string>
 
@@ -86,6 +87,9 @@ class CompilerInvocationBase {
   LangOptions *getLangOpts() { return LangOpts.get(); }
   const LangOptions *getLangOpts() const { return LangOpts.get(); }
 
+  CommentOptions &getCommentOpts() { return LangOpts->CommentOpts; }
+  const CommentOptions &getCommentOpts() const { return LangOpts->CommentOpts; }
+
   TargetOptions &getTargetOpts() { return *TargetOpts.get(); }
   const TargetOptions &getTargetOpts() const { return *TargetOpts.get(); }
 
@@ -227,6 +231,14 @@ class CompilerInvocation : public CompilerInvocationBase {
   FrontendOptions &getFrontendOpts() { return FrontendOpts; }
   const FrontendOptions &getFrontendOpts() const { return FrontendOpts; }
 
+  CodeCompleteOptions &getCodeCompleteOpts() {
+    return FrontendOpts.CodeCompleteOpts;
+  }
+
+  const CodeCompleteOptions &getCodeCompleteOpts() const {
+    return FrontendOpts.CodeCompleteOpts;
+  }
+
   PreprocessorOutputOptions &getPreprocessorOutputOpts() {
     return PreprocessorOutputOpts;
   }

diff  --git a/clang/include/clang/Frontend/DependencyOutputOptions.def b/clang/include/clang/Frontend/DependencyOutputOptions.def
new file mode 100644
index 000000000000..0fbd90226f11
--- /dev/null
+++ b/clang/include/clang/Frontend/DependencyOutputOptions.def
@@ -0,0 +1,50 @@
+//===--- DependencyOutputOptions.def -------------------------------C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains the DependencyOutput options, to use this file one needs
+// to define the TYPED_DEPENDENCY_OUTPUTOPT and/or the DEPENDECY_OUTPUTOPT macro
+// to get more information about bitfields.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TYPED_DEPENDENCY_OUTPUTOPT
+#define TYPED_DEPENDENCY_OUTPUTOPT(Type, Name, Description)
+#endif
+
+#ifndef DEPENDENCY_OUTPUTOPT
+#define DEPENDENCY_OUTPUTOPT(Name, Bits, Description)                          \
+  TYPED_DEPENDENCY_OUTPUTOPT(unsigned, Name, Description)
+#endif
+
+DEPENDENCY_OUTPUTOPT(IncludeSystemHeaders, 1, "Include system header dependencies.")
+DEPENDENCY_OUTPUTOPT(ShowHeaderIncludes, 1, "Show header inclusions (-H).")
+DEPENDENCY_OUTPUTOPT(UsePhonyTargets, 1, "Include phony targets for each dependency, which can "
+                     "avoid some 'make' problems.")
+DEPENDENCY_OUTPUTOPT(AddMissingHeaderDeps, 1, "Add missing headers to dependency list.")
+DEPENDENCY_OUTPUTOPT(IncludeModuleFiles, 1, "Include module file dependencies.")
+
+TYPED_DEPENDENCY_OUTPUTOPT(ShowIncludesDestination, ShowIncludesDest, "Destination of cl.exe style /showIncludes info.")
+
+TYPED_DEPENDENCY_OUTPUTOPT(DependencyOutputFormat, OutputFormat, "The format for the dependency file")
+
+TYPED_DEPENDENCY_OUTPUTOPT(std::string, OutputFile, "The file to write dependency output to.")
+
+TYPED_DEPENDENCY_OUTPUTOPT(std::string, HeaderIncludeOutputFile, "The file to write header include output to. This is orthogonal to ShowHeaderIncludes (-H) and will include headers mentioned in the predefines buffer. If the output file is \"-\", output will be sent to stderr.")
+
+TYPED_DEPENDENCY_OUTPUTOPT(std::vector<std::string>, Targets, "A list of names to use as the targets in the dependency file; this list must contain at least one entry.")
+
+TYPED_DEPENDENCY_OUTPUTOPT(std::vector<std::string>, ExtraDeps, "A list of filenames to be used as extra dependencies for every target.")
+
+TYPED_DEPENDENCY_OUTPUTOPT(std::string, ShowIncludesPretendHeader, "In /showIncludes mode, pretend the main TU is a header with this name.")
+
+TYPED_DEPENDENCY_OUTPUTOPT(std::string, DOTOutputFile, "The file to write GraphViz-formatted header dependencies to.")
+
+TYPED_DEPENDENCY_OUTPUTOPT(std::string, ModuleDependencyOutputDir, "The directory to copy module dependencies to when collecting them.")
+
+#undef TYPED_DEPENDENCY_OUTPUTOPT
+#undef DEPENDENCY_OUTPUTOPT
\ No newline at end of file

diff  --git a/clang/include/clang/Frontend/DependencyOutputOptions.h b/clang/include/clang/Frontend/DependencyOutputOptions.h
index 7a4f3337936f..581e9b5a544b 100644
--- a/clang/include/clang/Frontend/DependencyOutputOptions.h
+++ b/clang/include/clang/Frontend/DependencyOutputOptions.h
@@ -24,49 +24,15 @@ enum class DependencyOutputFormat { Make, NMake };
 /// file generation.
 class DependencyOutputOptions {
 public:
-  unsigned IncludeSystemHeaders : 1; ///< Include system header dependencies.
-  unsigned ShowHeaderIncludes : 1;   ///< Show header inclusions (-H).
-  unsigned UsePhonyTargets : 1;      ///< Include phony targets for each
-                                     /// dependency, which can avoid some 'make'
-                                     /// problems.
-  unsigned AddMissingHeaderDeps : 1; ///< Add missing headers to dependency list
-  unsigned IncludeModuleFiles : 1; ///< Include module file dependencies.
-
-  /// Destination of cl.exe style /showIncludes info.
-  ShowIncludesDestination ShowIncludesDest = ShowIncludesDestination::None;
-
-  /// The format for the dependency file.
-  DependencyOutputFormat OutputFormat = DependencyOutputFormat::Make;
-
-  /// The file to write dependency output to.
-  std::string OutputFile;
-
-  /// The file to write header include output to. This is orthogonal to
-  /// ShowHeaderIncludes (-H) and will include headers mentioned in the
-  /// predefines buffer. If the output file is "-", output will be sent to
-  /// stderr.
-  std::string HeaderIncludeOutputFile;
-
-  /// A list of names to use as the targets in the dependency file; this list
-  /// must contain at least one entry.
-  std::vector<std::string> Targets;
-
-  /// A list of filenames to be used as extra dependencies for every target.
-  std::vector<std::string> ExtraDeps;
-
-  /// In /showIncludes mode, pretend the main TU is a header with this name.
-  std::string ShowIncludesPretendHeader;
-
-  /// The file to write GraphViz-formatted header dependencies to.
-  std::string DOTOutputFile;
-
-  /// The directory to copy module dependencies to when collecting them.
-  std::string ModuleDependencyOutputDir;
-
+#define TYPED_DEPENDENCY_OUTPUTOPT(Type, Name, Description) Type Name;
+#define DEPENDENCY_OUTPUTOPT(Name, Bits, Description) unsigned Name : Bits;
+#include "clang/Frontend/DependencyOutputOptions.def"
 public:
   DependencyOutputOptions()
       : IncludeSystemHeaders(0), ShowHeaderIncludes(0), UsePhonyTargets(0),
-        AddMissingHeaderDeps(0), IncludeModuleFiles(0) {}
+        AddMissingHeaderDeps(0), IncludeModuleFiles(0),
+        ShowIncludesDest(ShowIncludesDestination::None),
+        OutputFormat(DependencyOutputFormat::Make) {}
 };
 
 }  // end namespace clang

diff  --git a/clang/include/clang/Frontend/FrontendOptions.def b/clang/include/clang/Frontend/FrontendOptions.def
new file mode 100644
index 000000000000..c6188d9cf025
--- /dev/null
+++ b/clang/include/clang/Frontend/FrontendOptions.def
@@ -0,0 +1,179 @@
+//===--- FrontendOptions.def - FileSystem option database -----*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the Frontend options.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TYPED_FRONTENDOPT
+#define TYPED_FRONTENDOPT(Type, Name, Description)
+#endif
+
+#ifndef FRONTENDOPT
+#define FRONTENDOPT(Name, Bits, Description)                                   \
+  TYPED_FRONTENDOPT(unsigned, Name, Description)
+#endif
+
+FRONTENDOPT(DisableFree, 1, "Disable memory freeing on exit.")
+
+FRONTENDOPT(RelocatablePCH, 1,
+            "When generating PCH files, instruct the AST writer to create "
+            "relocatable PCH files.")
+
+FRONTENDOPT(ShowHelp, 1, "Show the -help text.")
+
+FRONTENDOPT(ShowStats, 1, "Show frontend performance metrics and statistics.")
+
+FRONTENDOPT(ShowTimers, 1, "Show timers for individual actions.")
+
+FRONTENDOPT(PrintSupportedCPUs, 1,
+            "print the supported cpus for the current target")
+
+FRONTENDOPT(TimeTrace, 1, "Output time trace profile.")
+
+FRONTENDOPT(ShowVersion, 1, "Show the -version text.")
+
+FRONTENDOPT(FixWhatYouCan, 1, "Apply fixes even if there are unfixable errors.")
+
+FRONTENDOPT(FixOnlyWarnings, 1, "Apply fixes only for warnings.")
+
+FRONTENDOPT(FixAndRecompile, 1, "Apply fixes and recompile.")
+
+FRONTENDOPT(FixToTemporaries, 1, "Apply fixes to temporary files.")
+
+FRONTENDOPT(ARCMTAction, 3, "")
+
+FRONTENDOPT(ARCMTMigrateEmitARCErrors, 1,
+            "Emit ARC errors even if the migrator can fix them.")
+
+FRONTENDOPT(SkipFunctionBodies, 1,
+            "Skip over function bodies to speed up parsing in cases you do not "
+            "need them (e.g. with code completion).")
+
+FRONTENDOPT(UseGlobalModuleIndex, 1,
+            "Whether we can use the global module index if available.")
+
+FRONTENDOPT(GenerateGlobalModuleIndex, 1,
+            "Whether we can generate the global module index if needed.")
+
+FRONTENDOPT(ASTDumpDecls, 1,
+            "Whether we include declaration dumps in AST dumps.")
+
+FRONTENDOPT(ASTDumpAll, 1,
+            "Whether we deserialize all decls when forming AST dumps.")
+
+FRONTENDOPT(ASTDumpLookups, 1,
+            "Whether we include lookup table dumps in AST dumps.")
+
+FRONTENDOPT(ASTDumpDeclTypes, 1,
+            "Whether we include declaration type dumps in AST dumps.")
+
+FRONTENDOPT(BuildingImplicitModule, 1,
+            "Whether we are performing an implicit module build.")
+
+FRONTENDOPT(ModulesEmbedAllFiles, 1,
+            "Whether we should embed all used files into the PCM file.")
+
+FRONTENDOPT(IncludeTimestamps, 1,
+            "Whether timestamps should be written to the produced PCH file.")
+
+FRONTENDOPT(UseTemporary, 1,
+            "Should a temporary file be used during compilation.")
+
+FRONTENDOPT(IsSystemModule, 1,
+            "When using -emit-module, treat the modulemap as a system module.")
+
+TYPED_FRONTENDOPT(ASTDumpOutputFormat, ASTDumpFormat,
+                  "Specifies the output format of the AST.")
+
+TYPED_FRONTENDOPT(unsigned, ObjCMTAction, "")
+
+TYPED_FRONTENDOPT(std::string, ObjCMTWhiteListPath, "")
+
+TYPED_FRONTENDOPT(std::string, MTMigrateDir, "")
+
+TYPED_FRONTENDOPT(std::string, ARCMTMigrateReportOut, "")
+
+TYPED_FRONTENDOPT(InputsTy, Inputs, "The input files and their types.")
+
+TYPED_FRONTENDOPT(
+    std::string, OriginalModuleMap,
+    "When the input is a module map, the original module map file from which "
+    "that map was inferred, if any (for umbrella modules).")
+
+TYPED_FRONTENDOPT(std::string, OutputFile, "The output file, if any.")
+
+TYPED_FRONTENDOPT(std::string, FixItSuffix,
+                  "If given, the new suffix for fix-it rewritten files.")
+
+TYPED_FRONTENDOPT(std::string, ASTDumpFilter,
+                  "If given, filter dumped AST Decl nodes by this substring.")
+
+TYPED_FRONTENDOPT(ParsedSourceLocation, CodeCompletionAt,
+                  "If given, enable code completion at the provided location.")
+
+TYPED_FRONTENDOPT(frontend::ActionKind, ProgramAction,
+                  "The frontend action to perform.")
+
+TYPED_FRONTENDOPT(std::string, ActionName,
+                  "The name of the action to run when using a plugin action.")
+
+TYPED_FRONTENDOPT(PluginArgsTy, PluginArgs, "Args to pass to the plugins")
+
+TYPED_FRONTENDOPT(
+    std::vector<std::string>, AddPluginActions,
+    "The list of plugin actions to run in addition to the normal action.")
+
+TYPED_FRONTENDOPT(std::vector<std::string>, Plugins,
+                  "The list of plugins to load.")
+
+TYPED_FRONTENDOPT(std::vector<std::shared_ptr<ModuleFileExtension>>,
+                  ModuleFileExtensions, "The list of module file extensions.")
+
+TYPED_FRONTENDOPT(
+    std::vector<std::string>, ModuleMapFiles,
+    "The list of module map files to load before processing the input.")
+
+TYPED_FRONTENDOPT(std::vector<std::string>, ModuleFiles,
+                  "The list of additional prebuilt module files to load before "
+                  "processing the input.")
+
+TYPED_FRONTENDOPT(std::vector<std::string>, ModulesEmbedFiles,
+                  "The list of files to embed into the compiled module file.")
+
+TYPED_FRONTENDOPT(std::vector<std::string>, ASTMergeFiles,
+                  "The list of AST files to merge.")
+
+TYPED_FRONTENDOPT(
+    std::vector<std::string>, LLVMArgs,
+    "A list of arguments to forward to LLVM's option processing; this should "
+    "only be used for debugging and experimental features.")
+
+TYPED_FRONTENDOPT(std::string, OverrideRecordLayoutsFile,
+                  "File name of the file that will provide record layouts (in "
+                  "the format produced by -fdump-record-layouts).")
+
+TYPED_FRONTENDOPT(std::string, AuxTriple,
+                  "Auxiliary triple for CUDA/HIP compilation.")
+
+TYPED_FRONTENDOPT(Optional<std::string>, AuxTargetCPU,
+                  "Auxiliary target CPU for CUDA/HIP compilation.")
+
+TYPED_FRONTENDOPT(Optional<std::vector<std::string>>, AuxTargetFeatures,
+                  "Auxiliary target features for CUDA/HIP compilation.")
+
+TYPED_FRONTENDOPT(std::string, StatsFile, "Filename to write statistics to.")
+
+TYPED_FRONTENDOPT(
+    unsigned, TimeTraceGranularity,
+    "Minimum time granularity (in microseconds) traced by time profiler.")
+
+TYPED_FRONTENDOPT(InputKind, DashX, "Input Kind")
+
+#undef TYPED_FRONTENDOPT
+#undef FRONTENDOPT
\ No newline at end of file

diff  --git a/clang/include/clang/Frontend/FrontendOptions.h b/clang/include/clang/Frontend/FrontendOptions.h
index b2be33032c08..5dccdf50ca46 100644
--- a/clang/include/clang/Frontend/FrontendOptions.h
+++ b/clang/include/clang/Frontend/FrontendOptions.h
@@ -226,94 +226,14 @@ class FrontendInputFile {
 /// FrontendOptions - Options for controlling the behavior of the frontend.
 class FrontendOptions {
 public:
-  /// Disable memory freeing on exit.
-  unsigned DisableFree : 1;
+  using PluginArgsTy =
+      std::unordered_map<std::string, std::vector<std::string>>;
 
-  /// When generating PCH files, instruct the AST writer to create relocatable
-  /// PCH files.
-  unsigned RelocatablePCH : 1;
-
-  /// Show the -help text.
-  unsigned ShowHelp : 1;
-
-  /// Show frontend performance metrics and statistics.
-  unsigned ShowStats : 1;
-
-  /// Show timers for individual actions.
-  unsigned ShowTimers : 1;
-
-  /// print the supported cpus for the current target
-  unsigned PrintSupportedCPUs : 1;
-
-  /// Output time trace profile.
-  unsigned TimeTrace : 1;
-
-  /// Show the -version text.
-  unsigned ShowVersion : 1;
-
-  /// Apply fixes even if there are unfixable errors.
-  unsigned FixWhatYouCan : 1;
-
-  /// Apply fixes only for warnings.
-  unsigned FixOnlyWarnings : 1;
-
-  /// Apply fixes and recompile.
-  unsigned FixAndRecompile : 1;
-
-  /// Apply fixes to temporary files.
-  unsigned FixToTemporaries : 1;
-
-  /// Emit ARC errors even if the migrator can fix them.
-  unsigned ARCMTMigrateEmitARCErrors : 1;
-
-  /// Skip over function bodies to speed up parsing in cases you do not need
-  /// them (e.g. with code completion).
-  unsigned SkipFunctionBodies : 1;
-
-  /// Whether we can use the global module index if available.
-  unsigned UseGlobalModuleIndex : 1;
-
-  /// Whether we can generate the global module index if needed.
-  unsigned GenerateGlobalModuleIndex : 1;
-
-  /// Whether we include declaration dumps in AST dumps.
-  unsigned ASTDumpDecls : 1;
-
-  /// Whether we deserialize all decls when forming AST dumps.
-  unsigned ASTDumpAll : 1;
-
-  /// Whether we include lookup table dumps in AST dumps.
-  unsigned ASTDumpLookups : 1;
-
-  /// Whether we include declaration type dumps in AST dumps.
-  unsigned ASTDumpDeclTypes : 1;
-
-  /// Whether we are performing an implicit module build.
-  unsigned BuildingImplicitModule : 1;
-
-  /// Whether we should embed all used files into the PCM file.
-  unsigned ModulesEmbedAllFiles : 1;
-
-  /// Whether timestamps should be written to the produced PCH file.
-  unsigned IncludeTimestamps : 1;
-
-  /// Should a temporary file be used during compilation.
-  unsigned UseTemporary : 1;
-
-  /// When using -emit-module, treat the modulemap as a system module.
-  unsigned IsSystemModule : 1;
+  using InputsTy = llvm::SmallVector<FrontendInputFile, 0>;
 
   CodeCompleteOptions CodeCompleteOpts;
 
-  /// Specifies the output format of the AST.
-  ASTDumpOutputFormat ASTDumpFormat = ADOF_Default;
-
-  enum {
-    ARCMT_None,
-    ARCMT_Check,
-    ARCMT_Modify,
-    ARCMT_Migrate
-  } ARCMTAction = ARCMT_None;
+  enum { ARCMT_None, ARCMT_Check, ARCMT_Modify, ARCMT_Migrate };
 
   enum {
     ObjCMT_None = 0,
@@ -360,92 +280,18 @@ class FrontendOptions {
     /// Enable converting setter/getter expressions to property-dot syntx.
     ObjCMT_PropertyDotSyntax = 0x1000,
 
-    ObjCMT_MigrateDecls = (ObjCMT_ReadonlyProperty | ObjCMT_ReadwriteProperty |
-                           ObjCMT_Annotation | ObjCMT_Instancetype |
-                           ObjCMT_NsMacros | ObjCMT_ProtocolConformance |
-                           ObjCMT_NsAtomicIOSOnlyProperty |
-                           ObjCMT_DesignatedInitializer),
+    ObjCMT_MigrateDecls =
+        (ObjCMT_ReadonlyProperty | ObjCMT_ReadwriteProperty |
+         ObjCMT_Annotation | ObjCMT_Instancetype | ObjCMT_NsMacros |
+         ObjCMT_ProtocolConformance | ObjCMT_NsAtomicIOSOnlyProperty |
+         ObjCMT_DesignatedInitializer),
     ObjCMT_MigrateAll = (ObjCMT_Literals | ObjCMT_Subscripting |
                          ObjCMT_MigrateDecls | ObjCMT_PropertyDotSyntax)
   };
-  unsigned ObjCMTAction = ObjCMT_None;
-  std::string ObjCMTWhiteListPath;
-
-  std::string MTMigrateDir;
-  std::string ARCMTMigrateReportOut;
-
-  /// The input files and their types.
-  SmallVector<FrontendInputFile, 0> Inputs;
-
-  /// When the input is a module map, the original module map file from which
-  /// that map was inferred, if any (for umbrella modules).
-  std::string OriginalModuleMap;
-
-  /// The output file, if any.
-  std::string OutputFile;
-
-  /// If given, the new suffix for fix-it rewritten files.
-  std::string FixItSuffix;
-
-  /// If given, filter dumped AST Decl nodes by this substring.
-  std::string ASTDumpFilter;
-
-  /// If given, enable code completion at the provided location.
-  ParsedSourceLocation CodeCompletionAt;
-
-  /// The frontend action to perform.
-  frontend::ActionKind ProgramAction = frontend::ParseSyntaxOnly;
-
-  /// The name of the action to run when using a plugin action.
-  std::string ActionName;
-
-  /// Args to pass to the plugins
-  std::unordered_map<std::string,std::vector<std::string>> PluginArgs;
-
-  /// The list of plugin actions to run in addition to the normal action.
-  std::vector<std::string> AddPluginActions;
-
-  /// The list of plugins to load.
-  std::vector<std::string> Plugins;
-
-  /// The list of module file extensions.
-  std::vector<std::shared_ptr<ModuleFileExtension>> ModuleFileExtensions;
-
-  /// The list of module map files to load before processing the input.
-  std::vector<std::string> ModuleMapFiles;
-
-  /// The list of additional prebuilt module files to load before
-  /// processing the input.
-  std::vector<std::string> ModuleFiles;
-
-  /// The list of files to embed into the compiled module file.
-  std::vector<std::string> ModulesEmbedFiles;
-
-  /// The list of AST files to merge.
-  std::vector<std::string> ASTMergeFiles;
-
-  /// A list of arguments to forward to LLVM's option processing; this
-  /// should only be used for debugging and experimental features.
-  std::vector<std::string> LLVMArgs;
-
-  /// File name of the file that will provide record layouts
-  /// (in the format produced by -fdump-record-layouts).
-  std::string OverrideRecordLayoutsFile;
-
-  /// Auxiliary triple for CUDA/HIP compilation.
-  std::string AuxTriple;
-
-  /// Auxiliary target CPU for CUDA/HIP compilation.
-  Optional<std::string> AuxTargetCPU;
-
-  /// Auxiliary target features for CUDA/HIP compilation.
-  Optional<std::vector<std::string>> AuxTargetFeatures;
-
-  /// Filename to write statistics to.
-  std::string StatsFile;
 
-  /// Minimum time granularity (in microseconds) traced by time profiler.
-  unsigned TimeTraceGranularity;
+#define FRONTENDOPT(Name, Bits, Description) unsigned Name : Bits;
+#define TYPED_FRONTENDOPT(Type, Name, Description) Type Name;
+#include "clang/Frontend/FrontendOptions.def"
 
 public:
   FrontendOptions()
@@ -453,11 +299,14 @@ class FrontendOptions {
         ShowStats(false), ShowTimers(false), TimeTrace(false),
         ShowVersion(false), FixWhatYouCan(false), FixOnlyWarnings(false),
         FixAndRecompile(false), FixToTemporaries(false),
-        ARCMTMigrateEmitARCErrors(false), SkipFunctionBodies(false),
-        UseGlobalModuleIndex(true), GenerateGlobalModuleIndex(true),
-        ASTDumpDecls(false), ASTDumpLookups(false),
-        BuildingImplicitModule(false), ModulesEmbedAllFiles(false),
-        IncludeTimestamps(true), UseTemporary(true), TimeTraceGranularity(500) {}
+        ARCMTAction(ARCMT_None), ARCMTMigrateEmitARCErrors(false),
+        SkipFunctionBodies(false), UseGlobalModuleIndex(true),
+        GenerateGlobalModuleIndex(true), ASTDumpDecls(false),
+        ASTDumpLookups(false), BuildingImplicitModule(false),
+        ModulesEmbedAllFiles(false), IncludeTimestamps(true),
+        UseTemporary(true), ASTDumpFormat(ADOF_Default),
+        ObjCMTAction(ObjCMT_None), ProgramAction(frontend::ParseSyntaxOnly),
+        TimeTraceGranularity(500), DashX() {}
 
   /// getInputKindForExtension - Return the appropriate input kind for a file
   /// extension. For example, "c" would return Language::C.

diff  --git a/clang/include/clang/Frontend/MigratorOptions.def b/clang/include/clang/Frontend/MigratorOptions.def
new file mode 100644
index 000000000000..fbbcc6b686fd
--- /dev/null
+++ b/clang/include/clang/Frontend/MigratorOptions.def
@@ -0,0 +1,27 @@
+//===--- MigratorOptions.def - Migrator option database ---------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the migrator options. Users of this file must
+// define the TYPED_MIGRATOROPT macro to make use of this information.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TYPED_MIGRATOROPT
+#define TYPED_MIGRATOROPT(Type, Name, Description)
+#endif
+
+#ifndef MIGRATOROPT
+#define MIGRATOROPT(Name, Bits, Description)                                   \
+  TYPED_MIGRATOROPT(unsigned, Name, Description)
+#endif
+
+MIGRATOROPT(NoNSAllocReallocError, 1, "")
+MIGRATOROPT(NoFinalizeRemoval, 1, "")
+
+#undef TYPED_MIGRATOROPT
+#undef MIGRATOROPT

diff  --git a/clang/include/clang/Frontend/MigratorOptions.h b/clang/include/clang/Frontend/MigratorOptions.h
index cf50ffcf0c4f..f5ee9bba9dec 100644
--- a/clang/include/clang/Frontend/MigratorOptions.h
+++ b/clang/include/clang/Frontend/MigratorOptions.h
@@ -18,13 +18,10 @@ namespace clang {
 
 class MigratorOptions {
 public:
-  unsigned NoNSAllocReallocError : 1;
-  unsigned NoFinalizeRemoval : 1;
-  MigratorOptions() {
-    NoNSAllocReallocError = 0;
-    NoFinalizeRemoval = 0;
-  }
-};
+#define MIGRATOROPT(Name, Bits, Description) unsigned Name : Bits;
+#include "clang/Frontend/MigratorOptions.def"
 
+  MigratorOptions() : NoNSAllocReallocError(0), NoFinalizeRemoval(0) {}
+};
 }
 #endif

diff  --git a/clang/include/clang/Frontend/PreprocessorOutputOptions.def b/clang/include/clang/Frontend/PreprocessorOutputOptions.def
new file mode 100644
index 000000000000..aad2f5eb7294
--- /dev/null
+++ b/clang/include/clang/Frontend/PreprocessorOutputOptions.def
@@ -0,0 +1,46 @@
+//=== PreprocessorOutputOptions.def - FileSystem option database -*- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the PreprocessorOutput options.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TYPED_PREPROCESSOR_OUTPUTOPT
+#define TYPED_PREPROCESSOR_OUTPUTOPT(Type, Name, Description)
+#endif
+
+#ifndef PREPROCESSOR_OUTPUTOPT
+#define PREPROCESSOR_OUTPUTOPT(Name, Bits, Description)                        \
+  TYPED_PREPROCESSOR_OUTPUTOPT(unsigned, Name, Description)
+#endif
+
+PREPROCESSOR_OUTPUTOPT(ShowCPP, 1, "Print normal preprocessed output.")
+
+PREPROCESSOR_OUTPUTOPT(ShowComments, 1, "Show comments.")
+
+PREPROCESSOR_OUTPUTOPT(ShowLineMarkers, 1, "Show \#line markers.")
+
+PREPROCESSOR_OUTPUTOPT(UseLineDirectives, 1,
+                       "Use \#line instead of GCC-style \# N.")
+
+PREPROCESSOR_OUTPUTOPT(ShowMacroComments, 1, "Show comments, even in macros.")
+
+PREPROCESSOR_OUTPUTOPT(ShowMacros, 1, "Print macro definitions.")
+
+PREPROCESSOR_OUTPUTOPT(
+    ShowIncludeDirectives, 1,
+    "Print includes, imports etc. within preprocessed output.")
+
+PREPROCESSOR_OUTPUTOPT(RewriteIncludes, 1,
+                       "Preprocess include directives only.")
+
+PREPROCESSOR_OUTPUTOPT(RewriteImports, 1,
+                       "Include contents of transitively-imported modules.")
+
+#undef TYPED_PREPROCESSOR_OUTPUTOPT
+#undef PREPROCESSOR_OUTPUTOPT
\ No newline at end of file

diff  --git a/clang/include/clang/Frontend/PreprocessorOutputOptions.h b/clang/include/clang/Frontend/PreprocessorOutputOptions.h
index 72e5ad1137fb..ab4f25e394a2 100644
--- a/clang/include/clang/Frontend/PreprocessorOutputOptions.h
+++ b/clang/include/clang/Frontend/PreprocessorOutputOptions.h
@@ -15,15 +15,9 @@ namespace clang {
 /// output (e.g., -E).
 class PreprocessorOutputOptions {
 public:
-  unsigned ShowCPP : 1;            ///< Print normal preprocessed output.
-  unsigned ShowComments : 1;       ///< Show comments.
-  unsigned ShowLineMarkers : 1;    ///< Show \#line markers.
-  unsigned UseLineDirectives : 1;   ///< Use \#line instead of GCC-style \# N.
-  unsigned ShowMacroComments : 1;  ///< Show comments, even in macros.
-  unsigned ShowMacros : 1;         ///< Print macro definitions.
-  unsigned ShowIncludeDirectives : 1;  ///< Print includes, imports etc. within preprocessed output.
-  unsigned RewriteIncludes : 1;    ///< Preprocess include directives only.
-  unsigned RewriteImports  : 1;    ///< Include contents of transitively-imported modules.
+#define PREPROCESSOR_OUTPUTOPT(Name, Bits, Description) unsigned Name : Bits;
+#define TYPED_PREPROCESSOR_OUTPUTOPT(Type, Name, Description) Type Name;
+#include "clang/Frontend/PreprocessorOutputOptions.def"
 
 public:
   PreprocessorOutputOptions() {

diff  --git a/clang/include/clang/Lex/HeaderSearchOptions.def b/clang/include/clang/Lex/HeaderSearchOptions.def
new file mode 100644
index 000000000000..79fd196c8f90
--- /dev/null
+++ b/clang/include/clang/Lex/HeaderSearchOptions.def
@@ -0,0 +1,136 @@
+//===--- HeaderSearchOptions.def - HeaderSearch option database -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the header search options. Users of this file must
+// define the HEADERSEARCHOPT macro to make use of this information.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef HEADERSEARCHOPT
+#define HEADERSEARCHOPT(Name, Bits, Description)                               \
+  TYPED_HEADERSEARCHOPT(unsigned, Name, Description)
+#endif
+
+#ifndef TYPED_HEADERSEARCHOPT
+#define TYPED_HEADERSEARCHOPT(Type, Name, Description)
+#endif
+
+TYPED_HEADERSEARCHOPT(std::string, Sysroot,
+                      "If non-empty, the directory to use as a \"virtual "
+                      "system root\" for include paths.")
+
+TYPED_HEADERSEARCHOPT(std::string, ModuleFormat,
+                      "The module/pch container format.")
+
+HEADERSEARCHOPT(DisableModuleHash, 1,
+                "Whether we should disable the use of the hash string within "
+                "the module cache. Note: Only used for testing!")
+
+HEADERSEARCHOPT(ImplicitModuleMaps, 1,
+                "Implicit module maps.  This option is enabld by default when "
+                "modules is enabled.")
+
+HEADERSEARCHOPT(
+    ModuleMapFileHomeIsCwd, 1,
+    "Set the 'home directory' of a module map file to the current working "
+    "directory (or the home directory of the module map file that contained "
+    "the 'extern module' directive importing this module map file if any) "
+    "rather than the directory containing the module map file. The home "
+    "directory is where we look for files named in the module map file.")
+
+HEADERSEARCHOPT(UseBuiltinIncludes, 1, "Include the compiler builtin includes.")
+
+HEADERSEARCHOPT(UseStandardSystemIncludes, 1,
+                "Include the system standard include search directories.")
+
+HEADERSEARCHOPT(
+    UseStandardCXXIncludes, 1,
+    "Include the system standard C++ library include search directories.")
+
+HEADERSEARCHOPT(UseLibcxx, 1, "Use libc++ instead of the default libstdc++.")
+
+HEADERSEARCHOPT(Verbose, 1,
+                "Whether header search information should be output as for -v.")
+
+HEADERSEARCHOPT(
+    ModulesValidateOncePerBuildSession, 1,
+    "If true, skip verifying input files used by modules if the module was "
+    "already verified during this build session (see BuildSessionTimestamp).")
+
+HEADERSEARCHOPT(
+    ModulesValidateSystemHeaders, 1,
+    "Whether to validate system input files when a module is loaded.")
+
+HEADERSEARCHOPT(ValidateASTInputFilesContent, 1,
+                "Whether the content of input files should be hashed and used "
+                "to validate consistency.")
+
+HEADERSEARCHOPT(UseDebugInfo, 1,
+                "Whether the module includes debug information (-gmodules).")
+
+HEADERSEARCHOPT(ModulesValidateDiagnosticOptions, 1, "")
+
+HEADERSEARCHOPT(ModulesHashContent, 1, "")
+
+HEADERSEARCHOPT(ModulesStrictContextHash, 1,
+                "Whether we should include all things that could impact the "
+                "module in the hash. This includes things like the full header "
+                "search path, and enabled diagnostics.")
+
+TYPED_HEADERSEARCHOPT(std::vector<Entry>, UserEntries,
+                      "User specified include entries.")
+
+TYPED_HEADERSEARCHOPT(std::vector<SystemHeaderPrefix>, SystemHeaderPrefixes,
+                      "User-specified system header prefixes.")
+
+TYPED_HEADERSEARCHOPT(std::string, ResourceDir,
+                      "The directory which holds the compiler resource files "
+                      "(builtin includes, etc.).")
+
+TYPED_HEADERSEARCHOPT(std::string, ModuleCachePath,
+                      "The directory used for the module cache.")
+
+TYPED_HEADERSEARCHOPT(std::string, ModuleUserBuildPath,
+                      "The directory used for a user build.")
+
+TYPED_HEADERSEARCHOPT(PrebuiltModuleFilesTy, PrebuiltModuleFiles,
+                      "The mapping of module names to prebuilt module files.")
+
+TYPED_HEADERSEARCHOPT(std::vector<std::string>, PrebuiltModulePaths,
+                      "The directories used to load prebuilt module files.")
+
+TYPED_HEADERSEARCHOPT(
+    unsigned, ModuleCachePruneInterval,
+    "The interval (in seconds) between pruning operations. This operation is "
+    "expensive, because it requires Clang to walk through the directory "
+    "structure of the module cache, stat()'ing and removing files. The "
+    "default value is large, e.g., the operation runs once a week.")
+
+TYPED_HEADERSEARCHOPT(
+    unsigned, ModuleCachePruneAfter,
+    "The time (in seconds) after which an unused module file will be "
+    "considered unused and will, therefore, be pruned. When the module cache "
+    "is pruned, any module file that has not been accessed in this many "
+    "seconds will be removed. The default value is large, e.g., a month, to "
+    "avoid forcing infrequently-used modules to be regenerated often.")
+
+TYPED_HEADERSEARCHOPT(
+    uint64_t, BuildSessionTimestamp,
+    "The time in seconds when the build session started. This time is used "
+    "by other optimizations in header search and module loading.")
+
+TYPED_HEADERSEARCHOPT(ModulesIgnoreMacrosTy, ModulesIgnoreMacros,
+                      "The set of macro names that should be ignored for the "
+                      "purposes of computing the module hash.")
+
+TYPED_HEADERSEARCHOPT(
+    std::vector<std::string>, VFSOverlayFiles,
+    "The set of user-provided virtual filesystem overlay files.")
+
+#undef HEADERSEARCHOPT
+#undef TYPED_HEADERSEARCHOPT

diff  --git a/clang/include/clang/Lex/HeaderSearchOptions.h b/clang/include/clang/Lex/HeaderSearchOptions.h
index 3af49e175395..41a7ca915d79 100644
--- a/clang/include/clang/Lex/HeaderSearchOptions.h
+++ b/clang/include/clang/Lex/HeaderSearchOptions.h
@@ -94,125 +94,14 @@ class HeaderSearchOptions {
         : Prefix(Prefix), IsSystemHeader(IsSystemHeader) {}
   };
 
-  /// If non-empty, the directory to use as a "virtual system root" for include
-  /// paths.
-  std::string Sysroot;
-
-  /// User specified include entries.
-  std::vector<Entry> UserEntries;
-
-  /// User-specified system header prefixes.
-  std::vector<SystemHeaderPrefix> SystemHeaderPrefixes;
-
-  /// The directory which holds the compiler resource files (builtin includes,
-  /// etc.).
-  std::string ResourceDir;
+  using PrebuiltModuleFilesTy = std::map<std::string, std::string, std::less<>>;
 
-  /// The directory used for the module cache.
-  std::string ModuleCachePath;
-
-  /// The directory used for a user build.
-  std::string ModuleUserBuildPath;
-
-  /// The mapping of module names to prebuilt module files.
-  std::map<std::string, std::string, std::less<>> PrebuiltModuleFiles;
-
-  /// The directories used to load prebuilt module files.
-  std::vector<std::string> PrebuiltModulePaths;
-
-  /// The module/pch container format.
-  std::string ModuleFormat;
-
-  /// Whether we should disable the use of the hash string within the
-  /// module cache.
-  ///
-  /// Note: Only used for testing!
-  unsigned DisableModuleHash : 1;
-
-  /// Implicit module maps.  This option is enabld by default when
-  /// modules is enabled.
-  unsigned ImplicitModuleMaps : 1;
-
-  /// Set the 'home directory' of a module map file to the current
-  /// working directory (or the home directory of the module map file that
-  /// contained the 'extern module' directive importing this module map file
-  /// if any) rather than the directory containing the module map file.
-  //
-  /// The home directory is where we look for files named in the module map
-  /// file.
-  unsigned ModuleMapFileHomeIsCwd : 1;
-
-  /// The interval (in seconds) between pruning operations.
-  ///
-  /// This operation is expensive, because it requires Clang to walk through
-  /// the directory structure of the module cache, stat()'ing and removing
-  /// files.
-  ///
-  /// The default value is large, e.g., the operation runs once a week.
-  unsigned ModuleCachePruneInterval = 7 * 24 * 60 * 60;
-
-  /// The time (in seconds) after which an unused module file will be
-  /// considered unused and will, therefore, be pruned.
-  ///
-  /// When the module cache is pruned, any module file that has not been
-  /// accessed in this many seconds will be removed. The default value is
-  /// large, e.g., a month, to avoid forcing infrequently-used modules to be
-  /// regenerated often.
-  unsigned ModuleCachePruneAfter = 31 * 24 * 60 * 60;
-
-  /// The time in seconds when the build session started.
-  ///
-  /// This time is used by other optimizations in header search and module
-  /// loading.
-  uint64_t BuildSessionTimestamp = 0;
-
-  /// The set of macro names that should be ignored for the purposes
-  /// of computing the module hash.
-  llvm::SmallSetVector<llvm::CachedHashString, 16> ModulesIgnoreMacros;
-
-  /// The set of user-provided virtual filesystem overlay files.
-  std::vector<std::string> VFSOverlayFiles;
-
-  /// Include the compiler builtin includes.
-  unsigned UseBuiltinIncludes : 1;
-
-  /// Include the system standard include search directories.
-  unsigned UseStandardSystemIncludes : 1;
-
-  /// Include the system standard C++ library include search directories.
-  unsigned UseStandardCXXIncludes : 1;
-
-  /// Use libc++ instead of the default libstdc++.
-  unsigned UseLibcxx : 1;
-
-  /// Whether header search information should be output as for -v.
-  unsigned Verbose : 1;
-
-  /// If true, skip verifying input files used by modules if the
-  /// module was already verified during this build session (see
-  /// \c BuildSessionTimestamp).
-  unsigned ModulesValidateOncePerBuildSession : 1;
-
-  /// Whether to validate system input files when a module is loaded.
-  unsigned ModulesValidateSystemHeaders : 1;
+  using ModulesIgnoreMacrosTy =
+      llvm::SmallSetVector<llvm::CachedHashString, 16>;
 
-  // Whether the content of input files should be hashed and used to
-  // validate consistency.
-  unsigned ValidateASTInputFilesContent : 1;
-
-  /// Whether the module includes debug information (-gmodules).
-  unsigned UseDebugInfo : 1;
-
-  unsigned ModulesValidateDiagnosticOptions : 1;
-
-  unsigned ModulesHashContent : 1;
-
-  /// Whether we should include all things that could impact the module in the
-  /// hash.
-  ///
-  /// This includes things like the full header search path, and enabled
-  /// diagnostics.
-  unsigned ModulesStrictContextHash : 1;
+#define HEADERSEARCHOPT(Name, Bits, Description) unsigned Name : Bits;
+#define TYPED_HEADERSEARCHOPT(Type, Name, Description) Type Name;
+#include "clang/Lex/HeaderSearchOptions.def"
 
   HeaderSearchOptions(StringRef _Sysroot = "/")
       : Sysroot(_Sysroot), ModuleFormat("raw"), DisableModuleHash(false),
@@ -223,7 +112,9 @@ class HeaderSearchOptions {
         ModulesValidateSystemHeaders(false),
         ValidateASTInputFilesContent(false), UseDebugInfo(false),
         ModulesValidateDiagnosticOptions(true), ModulesHashContent(false),
-        ModulesStrictContextHash(false) {}
+        ModulesStrictContextHash(false),
+        ModuleCachePruneInterval(7 * 24 * 60 * 60),
+        ModuleCachePruneAfter(31 * 24 * 60 * 60), BuildSessionTimestamp(0) {}
 
   /// AddPath - Add the \p Path path to the specified \p Group list.
   void AddPath(StringRef Path, frontend::IncludeDirGroup Group,

diff  --git a/clang/include/clang/Lex/PreprocessorOptions.def b/clang/include/clang/Lex/PreprocessorOptions.def
new file mode 100644
index 000000000000..5b9e982351a0
--- /dev/null
+++ b/clang/include/clang/Lex/PreprocessorOptions.def
@@ -0,0 +1,166 @@
+//===--- PreprocessorOptions.def - Preprocessor option database -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the preprocessor options. Users of this file must
+// define the TYPED_PREPROCESSOROPT macro to make use of this information.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TYPED_PREPROCESSOROPT
+#error Define the TYPED_PREPROCESSOROPT macro to handle target options
+#endif
+
+TYPED_PREPROCESSOROPT(MacrosTy, Macros, "")
+
+TYPED_PREPROCESSOROPT(std::vector<std::string>, Includes, "")
+
+TYPED_PREPROCESSOROPT(std::vector<std::string>, MacroIncludes, "")
+
+TYPED_PREPROCESSOROPT(
+    bool, UsePredefines,
+    "Initialize the preprocessor with the compiler and target "
+    "specific predefines.")
+
+TYPED_PREPROCESSOROPT(
+    bool, DetailedRecord,
+    "Whether we should maintain a detailed record of all macro "
+    "definitions and expansions.")
+
+TYPED_PREPROCESSOROPT(
+    bool, PCHWithHdrStop,
+    "When true, we are creating or using a PCH where a #pragma hdrstop is "
+    "expected to indicate the beginning or end of the PCH.")
+
+TYPED_PREPROCESSOROPT(
+    bool, PCHWithHdrStopCreate,
+    "When true, we are creating a PCH or creating the PCH object "
+    "while expecting a #pragma hdrstop to separate the two.  Allow "
+    "for a missing #pragma hdrstop, which generates a PCH for the "
+    "whole file, and creates an empty PCH object.")
+
+TYPED_PREPROCESSOROPT(
+    std::string, PCHThroughHeader,
+    "If non-empty, the filename used in an #include directive in the primary "
+    "source file (or command-line preinclude) that is used to implement "
+    "MSVC-style precompiled headers. When creating a PCH, after the #include "
+    "of this header, the PCH generation stops. When using a PCH, tokens are "
+    "skipped until after an #include of this header is seen.")
+
+TYPED_PREPROCESSOROPT(
+    std::string, ImplicitPCHInclude,
+    "The implicit PCH included at the start of the translation unit, or empty.")
+
+TYPED_PREPROCESSOROPT(
+    std::vector<std::string>, ChainedIncludes,
+    "Headers that will be converted to chained PCHs in memory.")
+
+TYPED_PREPROCESSOROPT(
+    bool, DisablePCHValidation,
+    "When true, disables most of the normal validation performed "
+    "on precompiled headers.")
+
+TYPED_PREPROCESSOROPT(
+    bool, AllowPCHWithCompilerErrors,
+    "When true, a PCH with compiler errors will not be rejected.")
+
+TYPED_PREPROCESSOROPT(
+    bool, DumpDeserializedPCHDecls,
+    "Dump declarations that are deserialized from PCH, for testing.")
+
+TYPED_PREPROCESSOROPT(
+    std::set<std::string>, DeserializedPCHDeclsToErrorOn,
+    "This is a set of names for decls that we do not want to be deserialized, "
+    "and we emit an error if they are; for testing purposes.")
+
+TYPED_PREPROCESSOROPT(
+    PrecompiledPreambleBytesTy, PrecompiledPreambleBytes,
+    "If non-zero, the implicit PCH include is actually a precompiled preamble "
+    "that covers this number of bytes in the main source file. The boolean "
+    "indicates whether the preamble ends at the start of a new line.")
+
+TYPED_PREPROCESSOROPT(
+    bool, GeneratePreamble,
+    "True indicates that a preamble is being generated. When the "
+    "lexer is done, one of the things that need to be preserved is "
+    "the conditional #if stack, so the ASTWriter/ASTReader can "
+    "save/restore it when processing the rest of the file.")
+
+TYPED_PREPROCESSOROPT(
+    bool, WriteCommentListToPCH,
+    "Whether to write comment locations into the PCH when building "
+    "it. Reading the comments from the PCH can be a performance "
+    "hit even if the clients don't use them.")
+
+TYPED_PREPROCESSOROPT(
+    bool, SingleFileParseMode,
+    "When enabled, preprocessor is in a mode for parsing a single "
+    "file only. Disables #includes of other files and if there are "
+    "unresolved identifiers in preprocessor directive conditions "
+    "it causes all blocks to be parsed so that the client can get "
+    "the maximum amount of information from the parser.")
+
+TYPED_PREPROCESSOROPT(
+    bool, LexEditorPlaceholders,
+    "When enabled, the preprocessor will construct editor placeholder tokens.")
+
+TYPED_PREPROCESSOROPT(
+    bool, RemappedFilesKeepOriginalName,
+    "True if the SourceManager should report the original file name for "
+    "contents of files that were remapped to other files. Defaults to true.")
+
+TYPED_PREPROCESSOROPT(
+    RemappedFilesTy, RemappedFiles,
+    "The set of file remappings, which take existing files on the system (the "
+    "first part of each pair) and gives them the contents of other files on "
+    "the system (the second part of each pair).")
+
+TYPED_PREPROCESSOROPT(
+    RemappedFileBuffersTy, RemappedFileBuffers,
+    "The set of file-to-buffer remappings, which take existing files on the "
+    "system (the first part of each pair) and gives them the contents of the "
+    "specified memory buffer (the second part of each pair).")
+
+TYPED_PREPROCESSOROPT(
+    bool, RetainRemappedFileBuffers,
+    "Whether the compiler instance should retain (i.e., not free) "
+    "the buffers associated with remapped files. This flag "
+    "defaults to false; it can be set true only through direct "
+    "manipulation of the compiler invocation object, in cases "
+    "where the compiler invocation and its buffers will be reused.")
+
+TYPED_PREPROCESSOROPT(
+    bool, RetainExcludedConditionalBlocks,
+    "When enabled, excluded conditional blocks retain in the main file.")
+
+TYPED_PREPROCESSOROPT(
+    ObjCXXARCStandardLibraryKind, ObjCXXARCStandardLibrary,
+    "The Objective-C++ ARC standard library that we should support, by "
+    "providing appropriate definitions to retrofit the standard library with "
+    "support for lifetime-qualified pointers.")
+
+TYPED_PREPROCESSOROPT(std::shared_ptr<FailedModulesSet>, FailedModules, "")
+
+TYPED_PREPROCESSOROPT(MacroPrefixMapTy, MacroPrefixMap,
+                      "A prefix map for __FILE__ and __BASE_FILE__.")
+
+TYPED_PREPROCESSOROPT(
+    ExcludedPreprocessorDirectiveSkipMapping *,
+    ExcludedConditionalDirectiveSkipMappings,
+    "Contains the currently active skipped range mappings for "
+    "skipping excluded conditional directives. The pointer is "
+    "passed to the Preprocessor when it's constructed. The pointer "
+    "is unowned, the client is responsible for its lifetime.")
+
+TYPED_PREPROCESSOROPT(bool, SetUpStaticAnalyzer,
+                      "Set up preprocessor for RunAnalysis action.")
+
+TYPED_PREPROCESSOROPT(
+    bool, DisablePragmaDebugCrash,
+    "Prevents intended crashes when using #pragma clang __debug. For testing.")
+
+#undef TYPED_PREPROCESSOROPT

diff  --git a/clang/include/clang/Lex/PreprocessorOptions.h b/clang/include/clang/Lex/PreprocessorOptions.h
index c551f87e0d7b..f379d5053228 100644
--- a/clang/include/clang/Lex/PreprocessorOptions.h
+++ b/clang/include/clang/Lex/PreprocessorOptions.h
@@ -44,114 +44,13 @@ enum ObjCXXARCStandardLibraryKind {
 /// used in preprocessor initialization to InitializePreprocessor().
 class PreprocessorOptions {
 public:
-  std::vector<std::pair<std::string, bool/*isUndef*/>> Macros;
-  std::vector<std::string> Includes;
-  std::vector<std::string> MacroIncludes;
-
-  /// Initialize the preprocessor with the compiler and target specific
-  /// predefines.
-  bool UsePredefines = true;
-
-  /// Whether we should maintain a detailed record of all macro
-  /// definitions and expansions.
-  bool DetailedRecord = false;
-
-  /// When true, we are creating or using a PCH where a #pragma hdrstop is
-  /// expected to indicate the beginning or end of the PCH.
-  bool PCHWithHdrStop = false;
-
-  /// When true, we are creating a PCH or creating the PCH object while
-  /// expecting a #pragma hdrstop to separate the two.  Allow for a
-  /// missing #pragma hdrstop, which generates a PCH for the whole file,
-  /// and creates an empty PCH object.
-  bool PCHWithHdrStopCreate = false;
-
-  /// If non-empty, the filename used in an #include directive in the primary
-  /// source file (or command-line preinclude) that is used to implement
-  /// MSVC-style precompiled headers. When creating a PCH, after the #include
-  /// of this header, the PCH generation stops. When using a PCH, tokens are
-  /// skipped until after an #include of this header is seen.
-  std::string PCHThroughHeader;
-
-  /// The implicit PCH included at the start of the translation unit, or empty.
-  std::string ImplicitPCHInclude;
-
-  /// Headers that will be converted to chained PCHs in memory.
-  std::vector<std::string> ChainedIncludes;
-
-  /// When true, disables most of the normal validation performed on
-  /// precompiled headers.
-  bool DisablePCHValidation = false;
-
-  /// When true, a PCH with compiler errors will not be rejected.
-  bool AllowPCHWithCompilerErrors = false;
-
-  /// Dump declarations that are deserialized from PCH, for testing.
-  bool DumpDeserializedPCHDecls = false;
-
-  /// This is a set of names for decls that we do not want to be
-  /// deserialized, and we emit an error if they are; for testing purposes.
-  std::set<std::string> DeserializedPCHDeclsToErrorOn;
-
-  /// If non-zero, the implicit PCH include is actually a precompiled
-  /// preamble that covers this number of bytes in the main source file.
-  ///
-  /// The boolean indicates whether the preamble ends at the start of a new
-  /// line.
-  std::pair<unsigned, bool> PrecompiledPreambleBytes;
-
-  /// True indicates that a preamble is being generated.
-  ///
-  /// When the lexer is done, one of the things that need to be preserved is the
-  /// conditional #if stack, so the ASTWriter/ASTReader can save/restore it when
-  /// processing the rest of the file.
-  bool GeneratePreamble = false;
-
-  /// Whether to write comment locations into the PCH when building it.
-  /// Reading the comments from the PCH can be a performance hit even if the
-  /// clients don't use them.
-  bool WriteCommentListToPCH = true;
-
-  /// When enabled, preprocessor is in a mode for parsing a single file only.
-  ///
-  /// Disables #includes of other files and if there are unresolved identifiers
-  /// in preprocessor directive conditions it causes all blocks to be parsed so
-  /// that the client can get the maximum amount of information from the parser.
-  bool SingleFileParseMode = false;
-
-  /// When enabled, the preprocessor will construct editor placeholder tokens.
-  bool LexEditorPlaceholders = true;
-
-  /// True if the SourceManager should report the original file name for
-  /// contents of files that were remapped to other files. Defaults to true.
-  bool RemappedFilesKeepOriginalName = true;
-
-  /// The set of file remappings, which take existing files on
-  /// the system (the first part of each pair) and gives them the
-  /// contents of other files on the system (the second part of each
-  /// pair).
-  std::vector<std::pair<std::string, std::string>> RemappedFiles;
-
-  /// The set of file-to-buffer remappings, which take existing files
-  /// on the system (the first part of each pair) and gives them the contents
-  /// of the specified memory buffer (the second part of each pair).
-  std::vector<std::pair<std::string, llvm::MemoryBuffer *>> RemappedFileBuffers;
-
-  /// Whether the compiler instance should retain (i.e., not free)
-  /// the buffers associated with remapped files.
-  ///
-  /// This flag defaults to false; it can be set true only through direct
-  /// manipulation of the compiler invocation object, in cases where the
-  /// compiler invocation and its buffers will be reused.
-  bool RetainRemappedFileBuffers = false;
-
-  /// When enabled, excluded conditional blocks retain in the main file.
-  bool RetainExcludedConditionalBlocks = false;
-
-  /// The Objective-C++ ARC standard library that we should support,
-  /// by providing appropriate definitions to retrofit the standard library
-  /// with support for lifetime-qualified pointers.
-  ObjCXXARCStandardLibraryKind ObjCXXARCStandardLibrary = ARCXX_nolib;
+  using MacrosTy = std::vector<std::pair<std::string, bool>>;
+  using PrecompiledPreambleBytesTy = std::pair<unsigned, bool>;
+  using RemappedFilesTy = std::vector<std::pair<std::string, std::string>>;
+  using RemappedFileBuffersTy =
+      std::vector<std::pair<std::string, llvm::MemoryBuffer *>>;
+  using MacroPrefixMapTy =
+      std::map<std::string, std::string, std::greater<std::string>>;
 
   /// Records the set of modules
   class FailedModulesSet {
@@ -167,33 +66,21 @@ class PreprocessorOptions {
     }
   };
 
-  /// The set of modules that failed to build.
-  ///
-  /// This pointer will be shared among all of the compiler instances created
-  /// to (re)build modules, so that once a module fails to build anywhere,
-  /// other instances will see that the module has failed and won't try to
-  /// build it again.
-  std::shared_ptr<FailedModulesSet> FailedModules;
-
-  /// A prefix map for __FILE__ and __BASE_FILE__.
-  std::map<std::string, std::string, std::greater<std::string>> MacroPrefixMap;
-
-  /// Contains the currently active skipped range mappings for skipping excluded
-  /// conditional directives.
-  ///
-  /// The pointer is passed to the Preprocessor when it's constructed. The
-  /// pointer is unowned, the client is responsible for its lifetime.
-  ExcludedPreprocessorDirectiveSkipMapping
-      *ExcludedConditionalDirectiveSkipMappings = nullptr;
-
-  /// Set up preprocessor for RunAnalysis action.
-  bool SetUpStaticAnalyzer = false;
-
-  /// Prevents intended crashes when using #pragma clang __debug. For testing.
-  bool DisablePragmaDebugCrash = false;
-
-public:
-  PreprocessorOptions() : PrecompiledPreambleBytes(0, false) {}
+#define TYPED_PREPROCESSOROPT(Type, Name, Description) Type Name;
+#include "clang/Lex/PreprocessorOptions.def"
+
+  PreprocessorOptions()
+      : UsePredefines(true), DetailedRecord(false), PCHWithHdrStop(false),
+        PCHWithHdrStopCreate(false), DisablePCHValidation(false),
+        AllowPCHWithCompilerErrors(false), DumpDeserializedPCHDecls(false),
+        PrecompiledPreambleBytes(0, false), GeneratePreamble(false),
+        WriteCommentListToPCH(true), SingleFileParseMode(false),
+        LexEditorPlaceholders(true), RemappedFilesKeepOriginalName(true),
+        RetainRemappedFileBuffers(false),
+        RetainExcludedConditionalBlocks(false),
+        ObjCXXARCStandardLibrary(ARCXX_nolib),
+        ExcludedConditionalDirectiveSkipMappings(nullptr),
+        SetUpStaticAnalyzer(false), DisablePragmaDebugCrash(false) {}
 
   void addMacroDef(StringRef Name) {
     Macros.emplace_back(std::string(Name), false);

diff  --git a/clang/include/clang/Sema/CodeCompleteOptions.def b/clang/include/clang/Sema/CodeCompleteOptions.def
new file mode 100644
index 000000000000..dab8027929e5
--- /dev/null
+++ b/clang/include/clang/Sema/CodeCompleteOptions.def
@@ -0,0 +1,51 @@
+//===--- CodeCompleteOptions.def - FileSystem option database ----*- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the CodeComplete options.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TYPED_CODE_COMPLETEOPT
+#define TYPED_CODE_COMPLETEOPT(Type, Name, Description)
+#endif
+
+#ifndef CODE_COMPLETEOPT
+#define CODE_COMPLETEOPT(Name, Bits, Description)                              \
+  TYPED_CODE_COMPLETEOPT(unsigned, Name, Description);
+#endif
+
+CODE_COMPLETEOPT(IncludeMacros, 1, "Show macros in code completion results.")
+
+CODE_COMPLETEOPT(IncludeCodePatterns, 1,
+                 "Show code patterns in code completion results.")
+
+CODE_COMPLETEOPT(IncludeGlobals, 1,
+                 "Show top-level decls in code completion results.")
+
+CODE_COMPLETEOPT(IncludeNamespaceLevelDecls, 1,
+                 "Show decls in namespace (including the global namespace) in "
+                 "code completion results. If this is 0, `IncludeGlobals` will "
+                 "be ignored. Currently, this only works when completing "
+                 "qualified IDs (i.e. `Sema::CodeCompleteQualifiedId`). FIXME: "
+                 "consider supporting more completion cases with this option.")
+
+CODE_COMPLETEOPT(
+    IncludeBriefComments, 1,
+    "Show brief documentation comments in code completion results.")
+
+CODE_COMPLETEOPT(LoadExternal, 1,
+                 "Hint whether to load data from the external AST to provide "
+                 "full results. If false, namespace-level declarations and "
+                 "macros from the preamble may be omitted.")
+
+CODE_COMPLETEOPT(IncludeFixIts, 1,
+                 "Include results after corrections (small fix-its), e.g. "
+                 "change '.' to '->' on member access, etc.")
+
+#undef TYPED_CODE_COMPLETEOPT
+#undef CODE_COMPLETEOPT
\ No newline at end of file

diff  --git a/clang/include/clang/Sema/CodeCompleteOptions.h b/clang/include/clang/Sema/CodeCompleteOptions.h
index a3403b01dcde..28cbc94fc84c 100644
--- a/clang/include/clang/Sema/CodeCompleteOptions.h
+++ b/clang/include/clang/Sema/CodeCompleteOptions.h
@@ -14,39 +14,14 @@ namespace clang {
 /// Options controlling the behavior of code completion.
 class CodeCompleteOptions {
 public:
-  /// Show macros in code completion results.
-  unsigned IncludeMacros : 1;
-
-  /// Show code patterns in code completion results.
-  unsigned IncludeCodePatterns : 1;
-
-  /// Show top-level decls in code completion results.
-  unsigned IncludeGlobals : 1;
-
-  /// Show decls in namespace (including the global namespace) in code
-  /// completion results. If this is 0, `IncludeGlobals` will be ignored.
-  ///
-  /// Currently, this only works when completing qualified IDs (i.e.
-  /// `Sema::CodeCompleteQualifiedId`).
-  /// FIXME: consider supporting more completion cases with this option.
-  unsigned IncludeNamespaceLevelDecls : 1;
-
-  /// Show brief documentation comments in code completion results.
-  unsigned IncludeBriefComments : 1;
-
-  /// Hint whether to load data from the external AST to provide full results.
-  /// If false, namespace-level declarations and macros from the preamble may be
-  /// omitted.
-  unsigned LoadExternal : 1;
-
-  /// Include results after corrections (small fix-its), e.g. change '.' to '->'
-  /// on member access, etc.
-  unsigned IncludeFixIts : 1;
+#define CODE_COMPLETEOPT(Name, Bits, Description) unsigned Name : Bits;
+#define TYPED_CODE_COMPLETEOPT(Type, Name, Description) Type Name;
+#include "clang/Sema/CodeCompleteOptions.def"
 
   CodeCompleteOptions()
       : IncludeMacros(0), IncludeCodePatterns(0), IncludeGlobals(1),
-        IncludeNamespaceLevelDecls(1), IncludeBriefComments(0),
-        LoadExternal(1), IncludeFixIts(0) {}
+        IncludeNamespaceLevelDecls(1), IncludeBriefComments(0), LoadExternal(1),
+        IncludeFixIts(0) {}
 };
 
 } // namespace clang

diff  --git a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
index f0359d2dbb3c..ff253ca15c0e 100644
--- a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
+++ b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
@@ -6,7 +6,10 @@
 //
 //===----------------------------------------------------------------------===//
 //
-//  This file defines the analyzer options avaible with -analyzer-config.
+//  This file defines the analyzer options avaible with -analyzer-config, using
+//  the ANLAYZER_OPTION and ANALYZER_OPTION_DEPENDS_ON_USER_MODE macros.
+//  Other analyzer options use the simpler ANALYZEROPT and TYPED_ANALYZEROPT
+//  macro.
 //
 //===----------------------------------------------------------------------===//
 
@@ -29,6 +32,15 @@ define both 'ANALYZER_OPTION' and 'ANALYZER_OPTION_DEPENDS_ON_USER_MODE' macros!
 #endif
 #endif
 
+#ifndef TYPED_ANALYZEROPT
+#define TYPED_ANALYZEROPT(TYPE, NAME, DESCRIPTION)
+#endif
+
+#ifndef ANALYZEROPT
+#define ANALYZEROPT(NAME, BITS, DESCRIPTION)                                   \
+  TYPED_ANALYZEROPT(unsigned, NAME, DESCRITPTION)
+#endif
+
 #ifndef ANALYZER_OPTION
 /// Create a new analyzer option, but dont generate a method for it in
 /// AnalyzerOptions.
@@ -42,7 +54,8 @@ define both 'ANALYZER_OPTION' and 'ANALYZER_OPTION_DEPENDS_ON_USER_MODE' macros!
 ///             (-analyzer-config CMDFLAG=VALUE)
 ///   DESC - Description of the flag.
 ///   DEFAULT_VAL - The default value for CMDFLAG.
-#define ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, DEFAULT_VAL)
+#define ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, DEFAULT_VAL)                \
+  TYPED_ANALYZEROPT(TYPE, NAME, DESC)
 #endif
 
 #ifndef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
@@ -62,7 +75,8 @@ define both 'ANALYZER_OPTION' and 'ANALYZER_OPTION_DEPENDS_ON_USER_MODE' macros!
 ///   DEEP_VAL - The default value for CMDFLAG, when "user-mode" was set to
 ///              "deep".
 #define ANALYZER_OPTION_DEPENDS_ON_USER_MODE(TYPE, NAME, CMDFLAG, DESC,        \
-                                             SHALLOW_VAL, DEEP_VAL)
+                                             SHALLOW_VAL, DEEP_VAL)            \
+  TYPED_ANALYZEROPT(TYPE, NAME, DESC)
 #endif
 
 //===----------------------------------------------------------------------===//
@@ -435,5 +449,79 @@ ANALYZER_OPTION_DEPENDS_ON_USER_MODE(
     "\"basic-inlining\", \"inlining\", \"dynamic\", \"dynamic-bifurcate\".",
     /* SHALLOW_VAL */ "inlining", /* DEEP_VAL */ "dynamic-bifurcate")
 
+//===----------------------------------------------------------------------===//
+// Other analyzer options.
+//===----------------------------------------------------------------------===//
+
+TYPED_ANALYZEROPT(CheckersAndPackagesTy, CheckersAndPackages,
+                  "Pairs of checker/package name and enable/disable.")
+
+TYPED_ANALYZEROPT(
+    std::vector<std::string>, SilencedCheckersAndPackages,
+    "Vector of checker/package names which will not emit warnings.")
+
+TYPED_ANALYZEROPT(ConfigTable, Config,
+                  "A key-value table of use-specified configuration values.")
+TYPED_ANALYZEROPT(AnalysisStores, AnalysisStoreOpt, "")
+TYPED_ANALYZEROPT(AnalysisConstraints, AnalysisConstraintsOpt, "")
+TYPED_ANALYZEROPT(AnalysisDiagClients, AnalysisDiagOpt, "")
+TYPED_ANALYZEROPT(AnalysisPurgeMode, AnalysisPurgeOpt, "")
+
+TYPED_ANALYZEROPT(std::string, AnalyzeSpecificFunction, "")
+
+TYPED_ANALYZEROPT(std::string, DumpExplodedGraphTo,
+                  "File path to which the exploded graph should be dumped.")
+
+TYPED_ANALYZEROPT(std::string, FullCompilerInvocation,
+                  "Store full compiler invocation for reproducible "
+                  "instructions in the generated report.")
+
+TYPED_ANALYZEROPT(unsigned, maxBlockVisitOnPath,
+                  "The maximum number of times the analyzer visits a block.")
+
+ANALYZEROPT(
+    DisableAllCheckers, 1,
+    "Disable all analyzer checkers. This flag allows one to disable analyzer "
+    "checkers on the code processed by the given analysis consumer. Note, the "
+    "code will get parsed and the command-line options will get checked.")
+
+ANALYZEROPT(ShowCheckerHelp, 1, "")
+ANALYZEROPT(ShowCheckerHelpAlpha, 1, "")
+ANALYZEROPT(ShowCheckerHelpDeveloper, 1, "")
+
+ANALYZEROPT(ShowCheckerOptionList, 1, "")
+ANALYZEROPT(ShowCheckerOptionAlphaList, 1, "")
+ANALYZEROPT(ShowCheckerOptionDeveloperList, 1, "")
+
+ANALYZEROPT(ShowEnabledCheckerList, 1, "")
+ANALYZEROPT(ShowConfigOptionsList, 1, "")
+ANALYZEROPT(ShouldEmitErrorsOnInvalidConfigValue, 1, "")
+ANALYZEROPT(AnalyzeAll, 1, "")
+ANALYZEROPT(AnalyzerDisplayProgress, 1, "")
+ANALYZEROPT(AnalyzeNestedBlocks, 1, "")
+
+ANALYZEROPT(eagerlyAssumeBinOpBifurcation, 1, "")
+
+ANALYZEROPT(TrimGraph, 1, "")
+ANALYZEROPT(visualizeExplodedGraphWithGraphViz, 1, "")
+ANALYZEROPT(UnoptimizedCFG, 1, "")
+ANALYZEROPT(PrintStats, 1, "")
+
+ANALYZEROPT(
+    NoRetryExhausted, 1,
+    "Do not re-analyze paths leading to exhausted nodes with a 
diff erent "
+    "strategy. We get better code coverage when retry is enabled.")
+
+ANALYZEROPT(AnalyzerWerror, 1, "Emit analyzer warnings as errors.")
+
+TYPED_ANALYZEROPT(unsigned, InlineMaxStackDepth,
+                  "The inlining stack depth limit. Cap the stack depth at 4 "
+                  "calls (5 stack frames, base + 4 calls).")
+
+TYPED_ANALYZEROPT(AnalysisInliningMode, InliningMode,
+                  "The mode of function selection used during inlining.")
+
 #undef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
 #undef ANALYZER_OPTION
+#undef TYPED_ANALYZEROPT
+#undef ANALYZEROPT

diff  --git a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
index 4907b0757a8a..8d81f9029417 100644
--- a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -162,6 +162,7 @@ enum UserModeKind {
 class AnalyzerOptions : public RefCountedBase<AnalyzerOptions> {
 public:
   using ConfigTable = llvm::StringMap<std::string>;
+  using CheckersAndPackagesTy = std::vector<std::pair<std::string, bool>>;
 
   /// Retrieves the list of checkers generated from Checkers.td. This doesn't
   /// contain statically linked but non-generated checkers and plugin checkers!
@@ -195,86 +196,9 @@ class AnalyzerOptions : public RefCountedBase<AnalyzerOptions> {
                                   size_t InitialPad, size_t EntryWidth,
                                   size_t MinLineWidth = 0);
 
-  /// Pairs of checker/package name and enable/disable.
-  std::vector<std::pair<std::string, bool>> CheckersAndPackages;
-
-  /// Vector of checker/package names which will not emit warnings.
-  std::vector<std::string> SilencedCheckersAndPackages;
-
-  /// A key-value table of use-specified configuration values.
-  // TODO: This shouldn't be public.
-  ConfigTable Config;
-  AnalysisStores AnalysisStoreOpt = RegionStoreModel;
-  AnalysisConstraints AnalysisConstraintsOpt = RangeConstraintsModel;
-  AnalysisDiagClients AnalysisDiagOpt = PD_HTML;
-  AnalysisPurgeMode AnalysisPurgeOpt = PurgeStmt;
-
-  std::string AnalyzeSpecificFunction;
-
-  /// File path to which the exploded graph should be dumped.
-  std::string DumpExplodedGraphTo;
-
-  /// Store full compiler invocation for reproducible instructions in the
-  /// generated report.
-  std::string FullCompilerInvocation;
-
-  /// The maximum number of times the analyzer visits a block.
-  unsigned maxBlockVisitOnPath;
-
-  /// Disable all analyzer checkers.
-  ///
-  /// This flag allows one to disable analyzer checkers on the code processed by
-  /// the given analysis consumer. Note, the code will get parsed and the
-  /// command-line options will get checked.
-  unsigned DisableAllCheckers : 1;
-
-  unsigned ShowCheckerHelp : 1;
-  unsigned ShowCheckerHelpAlpha : 1;
-  unsigned ShowCheckerHelpDeveloper : 1;
-
-  unsigned ShowCheckerOptionList : 1;
-  unsigned ShowCheckerOptionAlphaList : 1;
-  unsigned ShowCheckerOptionDeveloperList : 1;
-
-  unsigned ShowEnabledCheckerList : 1;
-  unsigned ShowConfigOptionsList : 1;
-  unsigned ShouldEmitErrorsOnInvalidConfigValue : 1;
-  unsigned AnalyzeAll : 1;
-  unsigned AnalyzerDisplayProgress : 1;
-  unsigned AnalyzeNestedBlocks : 1;
-
-  unsigned eagerlyAssumeBinOpBifurcation : 1;
-
-  unsigned TrimGraph : 1;
-  unsigned visualizeExplodedGraphWithGraphViz : 1;
-  unsigned UnoptimizedCFG : 1;
-  unsigned PrintStats : 1;
-
-  /// Do not re-analyze paths leading to exhausted nodes with a 
diff erent
-  /// strategy. We get better code coverage when retry is enabled.
-  unsigned NoRetryExhausted : 1;
-
-  /// Emit analyzer warnings as errors.
-  unsigned AnalyzerWerror : 1;
-
-  /// The inlining stack depth limit.
-  // Cap the stack depth at 4 calls (5 stack frames, base + 4 calls).
-  unsigned InlineMaxStackDepth = 5;
-
-  /// The mode of function selection used during inlining.
-  AnalysisInliningMode InliningMode = NoRedundancy;
-
-  // Create a field for each -analyzer-config option.
-#define ANALYZER_OPTION_DEPENDS_ON_USER_MODE(TYPE, NAME, CMDFLAG, DESC,        \
-                                             SHALLOW_VAL, DEEP_VAL)            \
-  ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, SHALLOW_VAL)
-
-#define ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, DEFAULT_VAL)                \
-  TYPE NAME;
-
+#define ANALYZEROPT(NAME, BITS, DESCRIPTION) unsigned NAME : BITS;
+#define TYPED_ANALYZEROPT(TYPE, NAME, DESCRIPTION) TYPE NAME;
 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.def"
-#undef ANALYZER_OPTION
-#undef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
 
   // Create an array of all -analyzer-config command line options. Sort it in
   // the constructor.
@@ -299,15 +223,19 @@ class AnalyzerOptions : public RefCountedBase<AnalyzerOptions> {
   }
 
   AnalyzerOptions()
-      : DisableAllCheckers(false), ShowCheckerHelp(false),
-        ShowCheckerHelpAlpha(false), ShowCheckerHelpDeveloper(false),
-        ShowCheckerOptionList(false), ShowCheckerOptionAlphaList(false),
+      : AnalysisStoreOpt(RegionStoreModel),
+        AnalysisConstraintsOpt(RangeConstraintsModel), AnalysisDiagOpt(PD_HTML),
+        AnalysisPurgeOpt(PurgeStmt), DisableAllCheckers(false),
+        ShowCheckerHelp(false), ShowCheckerHelpAlpha(false),
+        ShowCheckerHelpDeveloper(false), ShowCheckerOptionList(false),
+        ShowCheckerOptionAlphaList(false),
         ShowCheckerOptionDeveloperList(false), ShowEnabledCheckerList(false),
         ShowConfigOptionsList(false), AnalyzeAll(false),
         AnalyzerDisplayProgress(false), AnalyzeNestedBlocks(false),
         eagerlyAssumeBinOpBifurcation(false), TrimGraph(false),
         visualizeExplodedGraphWithGraphViz(false), UnoptimizedCFG(false),
-        PrintStats(false), NoRetryExhausted(false), AnalyzerWerror(false) {
+        PrintStats(false), NoRetryExhausted(false), AnalyzerWerror(false),
+        InlineMaxStackDepth(5), InliningMode(NoRedundancy) {
     llvm::sort(AnalyzerConfigCmdFlags);
   }
 

diff  --git a/clang/lib/Basic/CodeGenOptions.cpp b/clang/lib/Basic/CodeGenOptions.cpp
index 4fc7a535c9eb..9e04b5ced2bb 100644
--- a/clang/lib/Basic/CodeGenOptions.cpp
+++ b/clang/lib/Basic/CodeGenOptions.cpp
@@ -10,8 +10,9 @@
 #include <string.h>
 
 namespace clang {
-
-CodeGenOptions::CodeGenOptions() {
+CodeGenOptions::CodeGenOptions()
+    : FPDenormalMode(llvm::DenormalMode::getIEEE()),
+      FP32DenormalMode(llvm::DenormalMode::getIEEE()), Argv0(nullptr) {
 #define CODEGENOPT(Name, Bits, Default) Name = Default;
 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) set##Name(Default);
 #include "clang/Basic/CodeGenOptions.def"

diff  --git a/clang/lib/Basic/LangOptions.cpp b/clang/lib/Basic/LangOptions.cpp
index c08670c87fb6..344d326a92e4 100644
--- a/clang/lib/Basic/LangOptions.cpp
+++ b/clang/lib/Basic/LangOptions.cpp
@@ -14,7 +14,8 @@
 
 using namespace clang;
 
-LangOptions::LangOptions() {
+LangOptions::LangOptions()
+    : CFRuntime(CoreFoundationABI::Unspecified), IsHeaderFile(false) {
 #define LANGOPT(Name, Bits, Default, Description) Name = Default;
 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) set##Name(Default);
 #include "clang/Basic/LangOptions.def"


        


More information about the cfe-commits mailing list