[clang] [InstallAPI] Add installapi specific options & diagnostics (PR #85100)
Juergen Ributzka via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 13 13:45:38 PDT 2024
================
@@ -126,9 +178,77 @@ bool Options::processFrontendOptions(InputArgList &Args) {
return true;
}
+std::vector<const char *>
+Options::processAndFilterOutInstallAPIOptions(ArrayRef<const char *> Args) {
+ std::unique_ptr<llvm::opt::OptTable> Table;
+ Table.reset(createDriverOptTable());
+
+ unsigned MissingArgIndex, MissingArgCount;
+ auto ParsedArgs = Table->ParseArgs(Args.slice(1), MissingArgIndex,
+ MissingArgCount, Visibility());
+
+ // Capture InstallAPI only driver options.
+ DriverOpts.Demangle = ParsedArgs.hasArg(OPT_demangle);
+
+ if (auto *A = ParsedArgs.getLastArg(OPT_filetype)) {
+ DriverOpts.OutFT = TextAPIWriter::parseFileType(A->getValue());
+ if (DriverOpts.OutFT == FileType::Invalid) {
+ Diags->Report(clang::diag::err_drv_invalid_value)
+ << A->getAsString(ParsedArgs) << A->getValue();
+ return {};
+ }
+ }
+
+ if (const Arg *A = ParsedArgs.getLastArg(OPT_verify_mode_EQ)) {
+ DriverOpts.VerifyMode =
+ StringSwitch<VerificationMode>(A->getValue())
+ .Case("ErrorsOnly", VerificationMode::ErrorsOnly)
+ .Case("ErrorsAndWarnings", VerificationMode::ErrorsAndWarnings)
+ .Case("Pedantic", VerificationMode::Pedantic)
+ .Default(VerificationMode::Invalid);
+
+ if (DriverOpts.VerifyMode == VerificationMode::Invalid) {
+ Diags->Report(clang::diag::err_drv_invalid_value)
+ << A->getAsString(ParsedArgs) << A->getValue();
+ return {};
+ }
+ }
+
+ if (const Arg *A = ParsedArgs.getLastArg(OPT_verify_against))
+ DriverOpts.DylibToVerify = A->getValue();
+
+ /// Any unclaimed arguments should be forwarded to the clang driver.
+ std::vector<const char *> StringList(ParsedArgs.size());
----------------
ributzka wrote:
`StringList` is a very generic variable name for a list of arguments. How about `ClangDriverArgs` or `FilteredArgs` instead?
https://github.com/llvm/llvm-project/pull/85100
More information about the cfe-commits
mailing list