aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorEgor Zhdan <e_zhdan@apple.com>2023-11-01 17:56:39 +0000
committerGitHub <noreply@github.com>2023-11-01 17:56:39 +0000
commitc0a1857928c557400af0ed53d198cc9f3f185f9a (patch)
tree381f1c860a8c449d3bb4a1ad9dcc2dbd2cb959eb /clang/lib/Frontend/CompilerInvocation.cpp
parent3e6d7c6d983dd5896e3a03857584654eb1360fda (diff)
downloadllvm-c0a1857928c557400af0ed53d198cc9f3f185f9a.zip
llvm-c0a1857928c557400af0ed53d198cc9f3f185f9a.tar.gz
llvm-c0a1857928c557400af0ed53d198cc9f3f185f9a.tar.bz2
[APINotes] Upstream APINotesOptions
This upstreams more of the Clang API Notes functionality that is currently implemented in the Apple fork: https://github.com/apple/llvm-project/tree/next/clang/lib/APINotes This adds the first compiler options related to API Notes to the upstream Clang: `-iapinotes-modules` and `-fapinotes-swift-version=`. However, this does not add the `-fapinotes` flag that enables API Notes, since the feature is not fully functional yet.
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index fd6c250..140feb0 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3261,6 +3261,17 @@ static bool ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
return Diags.getNumErrors() == NumErrorsBefore;
}
+static void ParseAPINotesArgs(APINotesOptions &Opts, ArgList &Args,
+ DiagnosticsEngine &diags) {
+ if (const Arg *A = Args.getLastArg(OPT_fapinotes_swift_version)) {
+ if (Opts.SwiftVersion.tryParse(A->getValue()))
+ diags.Report(diag::err_drv_invalid_value)
+ << A->getAsString(Args) << A->getValue();
+ }
+ for (const Arg *A : Args.filtered(OPT_iapinotes_modules))
+ Opts.ModuleSearchPaths.push_back(A->getValue());
+}
+
/// Check if input file kind and language standard are compatible.
static bool IsInputCompatibleWithStandard(InputKind IK,
const LangStandard &S) {
@@ -4538,6 +4549,7 @@ bool CompilerInvocation::CreateFromArgsImpl(
llvm::Triple T(Res.getTargetOpts().Triple);
ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), Args, Diags,
Res.getFileSystemOpts().WorkingDir);
+ ParseAPINotesArgs(Res.getAPINotesOpts(), Args, Diags);
ParseLangArgs(LangOpts, Args, DashX, T, Res.getPreprocessorOpts().Includes,
Diags);