@@ -3267,6 +3267,16 @@ static bool ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
3267
3267
return Diags.getNumErrors () == NumErrorsBefore;
3268
3268
}
3269
3269
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
+
3270
3280
static void ParseAPINotesArgs (APINotesOptions &Opts, ArgList &Args,
3271
3281
DiagnosticsEngine &diags) {
3272
3282
if (const Arg *A = Args.getLastArg (OPT_fapinotes_swift_version)) {
@@ -4746,6 +4756,18 @@ std::string CompilerInvocation::getModuleHash() const {
4746
4756
for (const auto &ext : getFrontendOpts ().ModuleFileExtensions )
4747
4757
ext->hashExtension (HBuilder);
4748
4758
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
+
4749
4771
// When compiling with -gmodules, also hash -fdebug-prefix-map as it
4750
4772
// affects the debug info in the PCM.
4751
4773
if (getCodeGenOpts ().DebugTypeExtRefs )
@@ -4776,6 +4798,7 @@ void CompilerInvocationBase::generateCC1CommandLine(
4776
4798
GenerateFrontendArgs (getFrontendOpts (), Consumer, getLangOpts ().IsHeaderFile );
4777
4799
GenerateTargetArgs (getTargetOpts (), Consumer);
4778
4800
GenerateHeaderSearchArgs (getHeaderSearchOpts (), Consumer);
4801
+ GenerateAPINotesArgs (getAPINotesOpts (), Consumer);
4779
4802
GenerateLangArgs (getLangOpts (), Consumer, T, getFrontendOpts ().DashX );
4780
4803
GenerateCodeGenArgs (getCodeGenOpts (), Consumer, T,
4781
4804
getFrontendOpts ().OutputFile , &getLangOpts ());
0 commit comments