2323#include " swift/Basic/JSONSerialization.h"
2424#include " swift/Basic/SourceManager.h"
2525#include " swift/Frontend/FrontendOptions.h"
26+ #include " swift/Frontend/ModuleInterfaceSupport.h"
2627#include " swift/IDE/SourceEntityWalker.h"
2728
2829#include " clang/AST/DeclObjC.h"
@@ -819,6 +820,7 @@ bool swift::emitLoadedModuleTraceIfNeeded(ModuleDecl *mainModule,
819820const static unsigned OBJC_METHOD_TRACE_FILE_FORMAT_VERSION = 1 ;
820821
821822class ObjcMethodReferenceCollector : public SourceEntityWalker {
823+ std::string compilerVer;
822824 std::string target;
823825 std::string targetVariant;
824826 SmallVector<StringRef, 32 > FilePaths;
@@ -855,6 +857,8 @@ class ObjcMethodReferenceCollector: public SourceEntityWalker {
855857 }
856858public:
857859 ObjcMethodReferenceCollector (ModuleDecl *MD) {
860+ compilerVer =
861+ getSwiftInterfaceCompilerVersionForCurrentCompiler (MD->getASTContext ());
858862 auto &Opts = MD->getASTContext ().LangOpts ;
859863 target = Opts.Target .str ();
860864 targetVariant = Opts.TargetVariant .has_value () ?
@@ -868,6 +872,7 @@ class ObjcMethodReferenceCollector: public SourceEntityWalker {
868872 void serializeAsJson (llvm::raw_ostream &OS) {
869873 llvm::json::OStream out (OS, /* IndentSize=*/ 4 );
870874 out.object ([&] {
875+ out.attribute (" swift-compiler-version" , compilerVer);
871876 out.attribute (" format-vesion" , OBJC_METHOD_TRACE_FILE_FORMAT_VERSION);
872877 out.attribute (" target" , target);
873878 if (!targetVariant.empty ())
0 commit comments