@@ -3267,6 +3267,16 @@ static bool ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
32673267 return Diags.getNumErrors () == NumErrorsBefore;
32683268}
32693269
3270+ static void GenerateAPINotesArgs (const APINotesOptions &Opts,
3271+ ArgumentConsumer Consumer) {
3272+ if (!Opts.SwiftVersion .empty ())
3273+ GenerateArg (Consumer, OPT_fapinotes_swift_version,
3274+ Opts.SwiftVersion .getAsString ());
3275+
3276+ for (const auto &Path : Opts.ModuleSearchPaths )
3277+ GenerateArg (Consumer, OPT_iapinotes_modules, Path);
3278+ }
3279+
32703280static void ParseAPINotesArgs (APINotesOptions &Opts, ArgList &Args,
32713281 DiagnosticsEngine &diags) {
32723282 if (const Arg *A = Args.getLastArg (OPT_fapinotes_swift_version)) {
@@ -4746,6 +4756,18 @@ std::string CompilerInvocation::getModuleHash() const {
47464756 for (const auto &ext : getFrontendOpts ().ModuleFileExtensions )
47474757 ext->hashExtension (HBuilder);
47484758
4759+ // Extend the signature with the Swift version for API notes.
4760+ const APINotesOptions &APINotesOpts = getAPINotesOpts ();
4761+ if (!APINotesOpts.SwiftVersion .empty ()) {
4762+ HBuilder.add (APINotesOpts.SwiftVersion .getMajor ());
4763+ if (auto Minor = APINotesOpts.SwiftVersion .getMinor ())
4764+ HBuilder.add (*Minor);
4765+ if (auto Subminor = APINotesOpts.SwiftVersion .getSubminor ())
4766+ HBuilder.add (*Subminor);
4767+ if (auto Build = APINotesOpts.SwiftVersion .getBuild ())
4768+ HBuilder.add (*Build);
4769+ }
4770+
47494771 // When compiling with -gmodules, also hash -fdebug-prefix-map as it
47504772 // affects the debug info in the PCM.
47514773 if (getCodeGenOpts ().DebugTypeExtRefs )
@@ -4776,6 +4798,7 @@ void CompilerInvocationBase::generateCC1CommandLine(
47764798 GenerateFrontendArgs (getFrontendOpts (), Consumer, getLangOpts ().IsHeaderFile );
47774799 GenerateTargetArgs (getTargetOpts (), Consumer);
47784800 GenerateHeaderSearchArgs (getHeaderSearchOpts (), Consumer);
4801+ GenerateAPINotesArgs (getAPINotesOpts (), Consumer);
47794802 GenerateLangArgs (getLangOpts (), Consumer, T, getFrontendOpts ().DashX );
47804803 GenerateCodeGenArgs (getCodeGenOpts (), Consumer, T,
47814804 getFrontendOpts ().OutputFile , &getLangOpts ());
0 commit comments