@@ -477,6 +477,11 @@ static bool clangSupportsPragmaAttributeWithSwiftAttr() {
477477 return swiftAttrParsedInfo.IsSupportedByPragmaAttribute ;
478478}
479479
480+ static inline bool isPCHFilenameExtension (StringRef path) {
481+ return llvm::sys::path::extension (path)
482+ .endswith (file_types::getExtension (file_types::TY_PCH));
483+ }
484+
480485void
481486importer::getNormalInvocationArguments (
482487 std::vector<std::string> &invocationArgStrs,
@@ -487,8 +492,7 @@ importer::getNormalInvocationArguments(
487492 ClangImporterOptions &importerOpts = ctx.ClangImporterOpts ;
488493 auto languageVersion = ctx.LangOpts .EffectiveLanguageVersion ;
489494
490- if (llvm::sys::path::extension (importerOpts.BridgingHeader )
491- .endswith (file_types::getExtension (file_types::TY_PCH))) {
495+ if (isPCHFilenameExtension (importerOpts.BridgingHeader )) {
492496 invocationArgStrs.insert (invocationArgStrs.end (), {
493497 " -include-pch" , importerOpts.BridgingHeader
494498 });
@@ -922,8 +926,7 @@ bool ClangImporter::canReadPCH(StringRef PCHFilename) {
922926Optional<std::string>
923927ClangImporter::getPCHFilename (const ClangImporterOptions &ImporterOptions,
924928 StringRef SwiftPCHHash, bool &isExplicit) {
925- if (llvm::sys::path::extension (ImporterOptions.BridgingHeader )
926- .endswith (file_types::getExtension (file_types::TY_PCH))) {
929+ if (isPCHFilenameExtension (ImporterOptions.BridgingHeader )) {
927930 isExplicit = true ;
928931 return ImporterOptions.BridgingHeader ;
929932 }
@@ -1083,8 +1086,7 @@ ClangImporter::create(ASTContext &ctx,
10831086
10841087
10851088
1086- if (llvm::sys::path::extension (importerOpts.BridgingHeader )
1087- .endswith (file_types::getExtension (file_types::TY_PCH))) {
1089+ if (isPCHFilenameExtension (importerOpts.BridgingHeader )) {
10881090 importer->Impl .setSinglePCHImport (importerOpts.BridgingHeader );
10891091 importer->Impl .IsReadingBridgingPCH = true ;
10901092 if (tracker) {
@@ -1510,8 +1512,7 @@ bool ClangImporter::importBridgingHeader(StringRef header, ModuleDecl *adapter,
15101512 SourceLoc diagLoc,
15111513 bool trackParsedSymbols,
15121514 bool implicitImport) {
1513- if (llvm::sys::path::extension (header)
1514- .endswith (file_types::getExtension (file_types::TY_PCH))) {
1515+ if (isPCHFilenameExtension (header)) {
15151516 Impl.ImportedHeaderOwners .push_back (adapter);
15161517 // We already imported this with -include-pch above, so we should have
15171518 // collected a bunch of PCH-encoded module imports that we just need to
0 commit comments