diff --git a/.travis.yml b/.travis.yml index 40e5b89..40f25c2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,3 +30,9 @@ matrix: language: cpp sudo: true script: docker build --build-arg TARGET_LLVM_VERSION=14 --build-arg BASE_IMAGE=ubuntu:22.04 --build-arg GCC_VERSION=9 --build-arg IMAGE_REPO=jammy . + - os: linux + dist: jammy + compiler: gcc + language: cpp + sudo: true + script: docker build --build-arg TARGET_LLVM_VERSION=15 --build-arg BASE_IMAGE=ubuntu:22.04 --build-arg GCC_VERSION=9 --build-arg IMAGE_REPO=jammy . diff --git a/src/collectors/definitions.cpp b/src/collectors/definitions.cpp index 250c753..a651e5f 100644 --- a/src/collectors/definitions.cpp +++ b/src/collectors/definitions.cpp @@ -25,11 +25,19 @@ class DefinitionsDataAppender : public MatchFinder::MatchCallback { clang::SourceManager *sm = r.SourceManager; const clang::FileID fid = sm->getFileID(e->getLocation()); +#if LLVM_VERSION_MAJOR >= 15 + const llvm::Optional 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())) { return; } const types::FileUID fuid = entry->getUID(); +#endif data->defs.insert( std::pair(fuid, e)); diff --git a/src/collectors/include_graph/include_finder.cpp b/src/collectors/include_graph/include_finder.cpp index 98ee85d..2717583 100644 --- a/src/collectors/include_graph/include_finder.cpp +++ b/src/collectors/include_graph/include_finder.cpp @@ -35,6 +35,8 @@ #include #include #include + +#include #include #include @@ -53,15 +55,29 @@ using clangmetatool::types::MacroReferenceInfo; void IncludeFinder::InclusionDirective( clang::SourceLocation hashLoc, const clang::Token &includeToken, llvm::StringRef filename, bool isAngled, +#if LLVM_VERSION_MAJOR >= 15 + clang::CharSourceRange filenameRange, llvm::Optional file, +#else clang::CharSourceRange filenameRange, const clang::FileEntry *file, +#endif llvm::StringRef searchPath, llvm::StringRef relativePath, const clang::Module *imported, clang::SrcMgr::CharacteristicKind FileType_) { + // The filetype characteristic is unused for now, hence marked with // a trailing '_'. We are recording all filetypes +#if LLVM_VERSION_MAJOR >= 15 + if(file.has_value()) { + add_include_statement(ci, data, hashLoc, includeToken, filename, isAngled, + filenameRange, &file.value().getFileEntry(), + searchPath, relativePath, + imported); + } +#else add_include_statement(ci, data, hashLoc, includeToken, filename, isAngled, filenameRange, file, searchPath, relativePath, imported); +#endif } void IncludeFinder::MacroExpands(const clang::Token ¯oUsage, diff --git a/src/collectors/include_graph/include_finder.h b/src/collectors/include_graph/include_finder.h index da9699d..2fd157d 100644 --- a/src/collectors/include_graph/include_finder.h +++ b/src/collectors/include_graph/include_finder.h @@ -35,7 +35,11 @@ class IncludeFinder : public clang::PPCallbacks { InclusionDirective(clang::SourceLocation hashLoc, const clang::Token &includeToken, llvm::StringRef filename, bool isAngled, clang::CharSourceRange filenameRange, +#if LLVM_VERSION_MAJOR >= 15 + llvm::Optional File, llvm::StringRef SearchPath, +#else const clang::FileEntry *file, llvm::StringRef searchPath, +#endif llvm::StringRef relativePath, const clang::Module *imported, clang::SrcMgr::CharacteristicKind FileType_) override; diff --git a/src/collectors/include_graph/include_graph_util.cpp b/src/collectors/include_graph/include_graph_util.cpp index 937871c..a1159f2 100644 --- a/src/collectors/include_graph/include_graph_util.cpp +++ b/src/collectors/include_graph/include_graph_util.cpp @@ -58,7 +58,11 @@ static std::pair get_fileuid(clang::CompilerInstance *ci, clang::SourceManager &sm = ci->getSourceManager(); const clang::FileEntry *entry = sm.getFileEntryForID(fid); +#if LLVM_VERSION_MAJOR >= 15 + if (!entry) +#else if (!(entry && entry->isValid())) +#endif return std::pair(0, false); FileUID fuid = entry->getUID(); @@ -101,7 +105,11 @@ void add_include_statement(clang::CompilerInstance *ci, IncludeGraphData *data, const clang::Module *imported) { std::string include = (std::string)relativePath; +#if LLVM_VERSION_MAJOR >= 15 + if (file) { +#else if (file && file->isValid()) { +#endif FileUID fuid = file->getUID(); data->fuid2entry.emplace(fuid, file); diff --git a/src/tool_application_support.cpp b/src/tool_application_support.cpp index 7a92ab0..57b4595 100644 --- a/src/tool_application_support.cpp +++ b/src/tool_application_support.cpp @@ -47,7 +47,11 @@ std::string getExecutablePathFromArgv(const std::string &argv0) { if (!llvm::sys::path::has_parent_path(exePath)) { llvm::Optional maybeExePath = llvm::sys::Process::FindInEnvPath("PATH", argv0); +#if LLVM_VERSION_MAJOR >= 15 + exePath = maybeExePath.value_or(""); +#else exePath = maybeExePath.getValueOr(""); +#endif } } return !exePath.empty() ? getRealpath(exePath) : "";