@@ -477,6 +477,11 @@ static bool clangSupportsPragmaAttributeWithSwiftAttr() {
477
477
return swiftAttrParsedInfo.IsSupportedByPragmaAttribute ;
478
478
}
479
479
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
+
480
485
void
481
486
importer::getNormalInvocationArguments (
482
487
std::vector<std::string> &invocationArgStrs,
@@ -487,8 +492,7 @@ importer::getNormalInvocationArguments(
487
492
ClangImporterOptions &importerOpts = ctx.ClangImporterOpts ;
488
493
auto languageVersion = ctx.LangOpts .EffectiveLanguageVersion ;
489
494
490
- if (llvm::sys::path::extension (importerOpts.BridgingHeader )
491
- .endswith (file_types::getExtension (file_types::TY_PCH))) {
495
+ if (isPCHFilenameExtension (importerOpts.BridgingHeader )) {
492
496
invocationArgStrs.insert (invocationArgStrs.end (), {
493
497
" -include-pch" , importerOpts.BridgingHeader
494
498
});
@@ -922,8 +926,7 @@ bool ClangImporter::canReadPCH(StringRef PCHFilename) {
922
926
Optional<std::string>
923
927
ClangImporter::getPCHFilename (const ClangImporterOptions &ImporterOptions,
924
928
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 )) {
927
930
isExplicit = true ;
928
931
return ImporterOptions.BridgingHeader ;
929
932
}
@@ -1083,8 +1086,7 @@ ClangImporter::create(ASTContext &ctx,
1083
1086
1084
1087
1085
1088
1086
- if (llvm::sys::path::extension (importerOpts.BridgingHeader )
1087
- .endswith (file_types::getExtension (file_types::TY_PCH))) {
1089
+ if (isPCHFilenameExtension (importerOpts.BridgingHeader )) {
1088
1090
importer->Impl .setSinglePCHImport (importerOpts.BridgingHeader );
1089
1091
importer->Impl .IsReadingBridgingPCH = true ;
1090
1092
if (tracker) {
@@ -1510,8 +1512,7 @@ bool ClangImporter::importBridgingHeader(StringRef header, ModuleDecl *adapter,
1510
1512
SourceLoc diagLoc,
1511
1513
bool trackParsedSymbols,
1512
1514
bool implicitImport) {
1513
- if (llvm::sys::path::extension (header)
1514
- .endswith (file_types::getExtension (file_types::TY_PCH))) {
1515
+ if (isPCHFilenameExtension (header)) {
1515
1516
Impl.ImportedHeaderOwners .push_back (adapter);
1516
1517
// We already imported this with -include-pch above, so we should have
1517
1518
// collected a bunch of PCH-encoded module imports that we just need to
0 commit comments