SuccessChanges

Summary

  1. [clang][cli] NFC: Decrease the scope of ParseLangArgs parameters (details)
  2. [clang][cli] NFC: Decrease the scope of ParseCodeGenArgs parameters (details)
  3. [clang][cli] Specify KeyPath prefixes via TableGen classes (details)
Commit c495dfe0268bc2be8737725d657411baa1399e9d by jan_svoboda
[clang][cli] NFC: Decrease the scope of ParseLangArgs parameters

Instead of passing the whole `TargetOptions` and `PreprocessorOptions` to `ParseLangArgs` give it only the necessary members.
This makes tracking the dependencies between various parsers and option groups easier.

Reviewed By: Bigcheese

Differential Revision: https://reviews.llvm.org/D94674
The file was modifiedclang/include/clang/Frontend/CompilerInvocation.h
The file was modifiedclang/lib/Frontend/CompilerInvocation.cpp
Commit 1a49944b59dbbfd62bd860b564919087f274a5bf by jan_svoboda
[clang][cli] NFC: Decrease the scope of ParseCodeGenArgs parameters

Instead of passing the whole `TargetOptions` and `FrontendOptions` to `ParseCodeGenArgs` give it only the necessary members.
This makes tracking the dependencies between various parsers and option groups easier.

Reviewed By: Bigcheese

Differential Revision: https://reviews.llvm.org/D94675
The file was modifiedclang/lib/Frontend/CompilerInvocation.cpp
Commit b6575bfd0eeb5a364dd2e4f4a2e461679da1f8a9 by jan_svoboda
[clang][cli] Specify KeyPath prefixes via TableGen classes

It turns out we need to handle `LangOptions` separately from the rest of the options. `LangOptions` used to be conditionally parsed only when `!(DashX.getFormat() == InputKind::Precompiled || DashX.getLanguage() == Language::LLVM_IR)` and we need to restore this order (for more info, see D94682).

We could do this similarly to how `DiagnosticOptions` are handled: via a counterpart to the `IsDiag` mix-in (e.g. `IsLang`). These mix-ins would prefix the option key path with the appropriate `CompilerInvocation::XxxOpts` member. However, this solution would be problematic, as we'd now have two kinds of options (`Lang` and `Diag`) with seemingly incomplete key paths in the same file. To understand what `CompilerInvocation` member an option affects, one would need to read the whole option definition and notice the `IsDiag` or `IsLang` class.

Instead, this patch introduces more robust way to handle different kinds of options separately: via the `KeyPathAndMacroPrefix` class. We have one specialization of that class per `CompilerInvocation` member (e.g. `LangOpts`, `DiagnosticOpts`, etc.). Now, instead of specifying a key path with `"LangOpts->UndefPrefixes"`, we use `LangOpts<"UndefPrefixes">`. This keeps the readability intact (you don't have to look for the `IsLang` mix-in, the key path is complete on its own) and allows us to specify a custom macro prefix within `LangOpts`.

Reviewed By: Bigcheese

Differential Revision: https://reviews.llvm.org/D94676
The file was modifiedllvm/unittests/Option/Opts.td
The file was modifiedclang/lib/Frontend/CompilerInvocation.cpp
The file was modifiedllvm/include/llvm/Option/OptParser.td
The file was modifiedclang/include/clang/Driver/Options.td
The file was modifiedllvm/unittests/Option/OptionMarshallingTest.cpp