Skip to content

Commit

Permalink
Use getFileEntryRefForID for llvm 15.
Browse files Browse the repository at this point in the history
Signed-off-by: Konstantin Romanov <[email protected]>
  • Loading branch information
ksromanov committed Jun 13, 2023
1 parent 22b23b6 commit 1302d31
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/collectors/definitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,19 @@ class DefinitionsDataAppender : public MatchFinder::MatchCallback {

clang::SourceManager *sm = r.SourceManager;
const clang::FileID fid = sm->getFileID(e->getLocation());
const clang::FileEntry *entry = sm->getFileEntryForID(fid);
#if LLVM_VERSION_MAJOR >= 15
if (!entry) {
const llvm::Optional<clang::FileEntryRef> entry = sm->getFileEntryRefForID(fid);
if (!entry.has_value()) {
return;
}
const types::FileUID fuid = entry.value().getUID();
#else
const clang::FileEntry *entry = sm->getFileEntryForID(fid);
if (!(entry && entry->isValid())) {
#endif
return;
}
const types::FileUID fuid = entry->getUID();
#endif

data->defs.insert(
std::pair<types::FileUID, const clang::NamedDecl *>(fuid, e));
Expand Down

0 comments on commit 1302d31

Please sign in to comment.