Adapt llvmorg-15-init-7692-gd79ad2f1dbc2: PPCallbacks::InclusionDirective parameter

This commit is contained in:
Fangrui Song 2022-04-16 22:29:02 -07:00
parent 790daca4b2
commit 74458915b3
2 changed files with 18 additions and 2 deletions

View File

@ -1096,10 +1096,18 @@ public:
} }
void InclusionDirective(SourceLocation hashLoc, const Token &tok, void InclusionDirective(SourceLocation hashLoc, const Token &tok,
StringRef included, bool isAngled, StringRef included, bool isAngled,
CharSourceRange filenameRange, const FileEntry *file, CharSourceRange filenameRange,
#if LLVM_VERSION_MAJOR >= 15 // llvmorg-15-init-7692-gd79ad2f1dbc2
llvm::Optional<FileEntryRef> fileRef,
#else
const FileEntry *file,
#endif
StringRef searchPath, StringRef relativePath, StringRef searchPath, StringRef relativePath,
const Module *imported, const Module *imported,
SrcMgr::CharacteristicKind fileType) override { SrcMgr::CharacteristicKind fileType) override {
#if LLVM_VERSION_MAJOR >= 15 // llvmorg-15-init-7692-gd79ad2f1dbc2
const FileEntry *file = fileRef ? &fileRef->getFileEntry() : nullptr;
#endif
if (!file) if (!file)
return; return;
auto spell = fromCharSourceRange(sm, param.ctx->getLangOpts(), auto spell = fromCharSourceRange(sm, param.ctx->getLangOpts(),

View File

@ -178,11 +178,19 @@ public:
: sm(sm), out(out) {} : sm(sm), out(out) {}
void InclusionDirective(SourceLocation hashLoc, const Token &includeTok, void InclusionDirective(SourceLocation hashLoc, const Token &includeTok,
StringRef fileName, bool isAngled, StringRef fileName, bool isAngled,
CharSourceRange filenameRange, const FileEntry *file, CharSourceRange filenameRange,
#if LLVM_VERSION_MAJOR >= 15 // llvmorg-15-init-7692-gd79ad2f1dbc2
llvm::Optional<FileEntryRef> fileRef,
#else
const FileEntry *file,
#endif
StringRef searchPath, StringRef relativePath, StringRef searchPath, StringRef relativePath,
const clang::Module *imported, const clang::Module *imported,
SrcMgr::CharacteristicKind fileKind) override { SrcMgr::CharacteristicKind fileKind) override {
(void)sm; (void)sm;
#if LLVM_VERSION_MAJOR >= 15 // llvmorg-15-init-7692-gd79ad2f1dbc2
const FileEntry *file = fileRef ? &fileRef->getFileEntry() : nullptr;
#endif
if (file && seen.insert(file).second) if (file && seen.insert(file).second)
out.emplace_back(pathFromFileEntry(*file), file->getModificationTime()); out.emplace_back(pathFromFileEntry(*file), file->getModificationTime());
} }