@@ -994,6 +994,41 @@ std::string ClangImporter::getBridgingHeaderContents(StringRef headerPath,
994
994
return result;
995
995
}
996
996
997
+ bool
998
+ ClangImporter::emitBridgingPCH (StringRef headerPath,
999
+ StringRef outputPCHPath) {
1000
+ llvm::IntrusiveRefCntPtr<clang::CompilerInvocation> invocation{
1001
+ new clang::CompilerInvocation (*Impl.Invocation )
1002
+ };
1003
+ invocation->getFrontendOpts ().DisableFree = false ;
1004
+ invocation->getFrontendOpts ().Inputs .clear ();
1005
+ invocation->getFrontendOpts ().Inputs .push_back (
1006
+ clang::FrontendInputFile (headerPath, clang::IK_ObjC));
1007
+ invocation->getFrontendOpts ().OutputFile = outputPCHPath;
1008
+ invocation->getPreprocessorOpts ().resetNonModularOptions ();
1009
+
1010
+ clang::CompilerInstance emitInstance (
1011
+ Impl.Instance ->getPCHContainerOperations ());
1012
+ emitInstance.setInvocation (&*invocation);
1013
+ emitInstance.createDiagnostics (&Impl.Instance ->getDiagnosticClient (),
1014
+ false );
1015
+
1016
+ clang::FileManager &fileManager = Impl.Instance ->getFileManager ();
1017
+ emitInstance.setFileManager (&fileManager);
1018
+ emitInstance.createSourceManager (fileManager);
1019
+ emitInstance.setTarget (&Impl.Instance ->getTarget ());
1020
+
1021
+ clang::GeneratePCHAction action;
1022
+ emitInstance.ExecuteAction (action);
1023
+ if (emitInstance.getDiagnostics ().hasErrorOccurred ()) {
1024
+ Impl.SwiftContext .Diags .diagnose ({},
1025
+ diag::bridging_header_pch_error,
1026
+ outputPCHPath, headerPath);
1027
+ return true ;
1028
+ }
1029
+ return false ;
1030
+ }
1031
+
997
1032
void ClangImporter::collectSubModuleNames (
998
1033
ArrayRef<std::pair<Identifier, SourceLoc>> path,
999
1034
std::vector<std::string> &names) {
0 commit comments