aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorEgor Zhdan <e_zhdan@apple.com>2023-11-23 19:52:27 +0100
committerGitHub <noreply@github.com>2023-11-23 18:52:27 +0000
commit07d799f08fec4cb9ceb14a43cc134dee7f1621fc (patch)
treeffd33ea978dc0016451d84ab89f29695ad697255 /clang/lib/Frontend/CompilerInvocation.cpp
parent258631fc0c640b5091950a3323e2c51545c3f0a9 (diff)
downloadllvm-07d799f08fec4cb9ceb14a43cc134dee7f1621fc.zip
llvm-07d799f08fec4cb9ceb14a43cc134dee7f1621fc.tar.gz
llvm-07d799f08fec4cb9ceb14a43cc134dee7f1621fc.tar.bz2
[APINotes] Upstream Driver and Frontend options that enable API Notes
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
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 3f4ca02..3b92cc1 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3267,6 +3267,16 @@ static bool ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
return Diags.getNumErrors() == NumErrorsBefore;
}
+static void GenerateAPINotesArgs(const APINotesOptions &Opts,
+ ArgumentConsumer Consumer) {
+ if (!Opts.SwiftVersion.empty())
+ GenerateArg(Consumer, OPT_fapinotes_swift_version,
+ Opts.SwiftVersion.getAsString());
+
+ for (const auto &Path : Opts.ModuleSearchPaths)
+ GenerateArg(Consumer, OPT_iapinotes_modules, Path);
+}
+
static void ParseAPINotesArgs(APINotesOptions &Opts, ArgList &Args,
DiagnosticsEngine &diags) {
if (const Arg *A = Args.getLastArg(OPT_fapinotes_swift_version)) {
@@ -4746,6 +4756,18 @@ std::string CompilerInvocation::getModuleHash() const {
for (const auto &ext : getFrontendOpts().ModuleFileExtensions)
ext->hashExtension(HBuilder);
+ // Extend the signature with the Swift version for API notes.
+ const APINotesOptions &APINotesOpts = getAPINotesOpts();
+ if (!APINotesOpts.SwiftVersion.empty()) {
+ HBuilder.add(APINotesOpts.SwiftVersion.getMajor());
+ if (auto Minor = APINotesOpts.SwiftVersion.getMinor())
+ HBuilder.add(*Minor);
+ if (auto Subminor = APINotesOpts.SwiftVersion.getSubminor())
+ HBuilder.add(*Subminor);
+ if (auto Build = APINotesOpts.SwiftVersion.getBuild())
+ HBuilder.add(*Build);
+ }
+
// When compiling with -gmodules, also hash -fdebug-prefix-map as it
// affects the debug info in the PCM.
if (getCodeGenOpts().DebugTypeExtRefs)
@@ -4776,6 +4798,7 @@ void CompilerInvocationBase::generateCC1CommandLine(
GenerateFrontendArgs(getFrontendOpts(), Consumer, getLangOpts().IsHeaderFile);
GenerateTargetArgs(getTargetOpts(), Consumer);
GenerateHeaderSearchArgs(getHeaderSearchOpts(), Consumer);
+ GenerateAPINotesArgs(getAPINotesOpts(), Consumer);
GenerateLangArgs(getLangOpts(), Consumer, T, getFrontendOpts().DashX);
GenerateCodeGenArgs(getCodeGenOpts(), Consumer, T,
getFrontendOpts().OutputFile, &getLangOpts());