Merge pull request #65985 from cachemeifyoucan/eng/PR-109411245

[ObjcHeader] Fix objc header generation when pch is explicited passed
This commit is contained in:
Steven Wu
2023-05-18 10:30:44 -07:00
committed by GitHub
9 changed files with 68 additions and 6 deletions

View File

@@ -818,6 +818,26 @@ SourceFile *CompilerInstance::getIDEInspectionFile() const {
return evaluateOrDefault(eval, IDEInspectionFileRequest{mod}, nullptr);
}
static inline bool isPCHFilenameExtension(StringRef path) {
return llvm::sys::path::extension(path)
.endswith(file_types::getExtension(file_types::TY_PCH));
}
std::string CompilerInstance::getBridgingHeaderPath() const {
const FrontendOptions &opts = Invocation.getFrontendOptions();
if (!isPCHFilenameExtension(opts.ImplicitObjCHeaderPath))
return opts.ImplicitObjCHeaderPath;
auto clangImporter =
static_cast<ClangImporter *>(getASTContext().getClangModuleLoader());
// No clang importer created. Report error?
if (!clangImporter)
return std::string();
return clangImporter->getOriginalSourceFile(opts.ImplicitObjCHeaderPath);
}
bool CompilerInstance::setUpInputs() {
// Adds to InputSourceCodeBufferIDs, so may need to happen before the
// per-input setup.