diff --git a/cgcollector/lib/include/MetaCollector.h b/cgcollector/lib/include/MetaCollector.h index 6f3a139..ed61b69 100644 --- a/cgcollector/lib/include/MetaCollector.h +++ b/cgcollector/lib/include/MetaCollector.h @@ -81,12 +81,20 @@ class FilePropertyCollector : public MetaCollector { const auto sourceLocation = decl->getLocation(); auto& astCtx = decl->getASTContext(); const auto fullSrcLoc = astCtx.getFullLoc(sourceLocation); - const auto fileEntry = fullSrcLoc.getFileEntry(); - if (!fileEntry) { - return result; + std::string fileNameStr = ""; + if (fullSrcLoc.isValid()) { +#if LLVM_VERSION_MAJOR >= 18 + const auto fileEntry = fullSrcLoc.getFileEntryRef(); +#else + const auto fileEntry = fullSrcLoc.getFileEntry(); +#endif + if (!fileEntry) { + return result; + } + + const auto fileName = fileEntry->getName(); + fileNameStr = fileName.str(); } - const auto fileName = fileEntry->getName(); - std::string fileNameStr = fileName.str(); result->isFromSystemInclude = astCtx.getSourceManager().isInSystemHeader(sourceLocation); diff --git a/cgcollector/lib/src/AAUSR.cpp b/cgcollector/lib/src/AAUSR.cpp index 90099fd..b317069 100644 --- a/cgcollector/lib/src/AAUSR.cpp +++ b/cgcollector/lib/src/AAUSR.cpp @@ -42,7 +42,7 @@ bool implementation::printLoc(llvm::raw_ostream& OS, SourceLocation BeginLoc, So const auto EndLocOffset = SM.getDecomposedLoc(EndLocExpansion).second; const std::pair& Decomposed = SM.getDecomposedLoc(BeginLocExpansion); if (PrintFilename) { - const FileEntry* FE = SM.getFileEntryForID(Decomposed.first); + auto FE = SM.getFileEntryRefForID(Decomposed.first); if (FE) { OS << llvm::sys::path::filename(FE->getName()); } else { diff --git a/cgcollector/lib/src/AliasAnalysis.cpp b/cgcollector/lib/src/AliasAnalysis.cpp index 93494d0..b3af019 100644 --- a/cgcollector/lib/src/AliasAnalysis.cpp +++ b/cgcollector/lib/src/AliasAnalysis.cpp @@ -822,8 +822,16 @@ bool ASTInformationExtractor::TraverseConstructorInitializer(clang::CXXCtorIniti return RecursiveASTVisitor::TraverseConstructorInitializer(CtorInit); } +[[nodiscard]] inline bool isUnnamedBitField(clang::FieldDecl* FD) { +#if LLVM_VERSION_MAJOR < 19 + return FD->isUnnamedBitfield(); +#else + return FD->isUnnamedBitField(); +#endif +} + bool ASTInformationExtractor::VisitFieldDecl(clang::FieldDecl* FD) { - if (FD->isUnnamedBitfield()) { + if (isUnnamedBitField(FD)) { // Unnamed bitfields can not be referenced return true; } diff --git a/cgcollector/lib/src/CallGraph.cpp b/cgcollector/lib/src/CallGraph.cpp index 19e265e..50cab33 100644 --- a/cgcollector/lib/src/CallGraph.cpp +++ b/cgcollector/lib/src/CallGraph.cpp @@ -957,7 +957,9 @@ class CGBuilder : public StmtVisitor { // std::cout << "Visiting the lambda expression: " << LEstr.front() << " @ " << LE->getCallOperator() << // std::endl; auto lambdaStaticInvoker = LE->getLambdaClass()->getLambdaStaticInvoker(); - addCalledDecl(lambdaStaticInvoker, LE->getCallOperator(), nullptr); + if (lambdaStaticInvoker) { + addCalledDecl(lambdaStaticInvoker, LE->getCallOperator(), nullptr); + } for (auto conversionIt = LE->getLambdaClass()->conversion_begin(); conversionIt != LE->getLambdaClass()->conversion_end(); ++conversionIt) { if (auto conv = *conversionIt) { @@ -1165,6 +1167,14 @@ CallGraph::CallGraph() : Root(getOrInsertNode(nullptr)) {} CallGraph::~CallGraph() = default; +[[nodiscard]] inline bool starts_with(llvm::StringRef Str, llvm::StringRef Prefix) { +#if LLVM_VERSION_MAJOR < 17 + return Str.startswith(Prefix); +#else + return Str.starts_with(Prefix); +#endif +} + bool CallGraph::includeInGraph(const Decl* D) { assert(D); @@ -1184,7 +1194,7 @@ bool CallGraph::includeInGraph(const Decl* D) { IdentifierInfo* II = FD->getIdentifier(); // TODO not sure whether we want to include __inline marked functions - if (II && II->getName().startswith("__inline")) { + if (II && starts_with(II->getName(), "__inline")) { return true; } } diff --git a/cmake/ClangLLVM.cmake b/cmake/ClangLLVM.cmake index d19bfd9..36ef085 100644 --- a/cmake/ClangLLVM.cmake +++ b/cmake/ClangLLVM.cmake @@ -35,7 +35,8 @@ function(test_llvm_major_version version_string) endif() if(NOT ${valid_version}) - message(SEND_ERROR "LLVM/Clang version 10, 13, 14, 15, 16, 17, and 18 are supported and tested") + message(WARNING "Support for LLVM Version ${version_string} is not tested! Proceed with care.") + message(WARNING "LLVM/Clang version 10, 13, 14, 15, 16, 17, 18 are supported and tested") endif() endfunction() diff --git a/graph/include/CgNode.h b/graph/include/CgNode.h index dc33c40..0facf55 100644 --- a/graph/include/CgNode.h +++ b/graph/include/CgNode.h @@ -106,7 +106,7 @@ class CgNode { } auto nmd = new T(args...); - this->template addMetaData(nmd); + this->addMetaData(nmd); return nmd; } diff --git a/graph/include/metadata/MetaData.h b/graph/include/metadata/MetaData.h index 506f326..ea00ef3 100644 --- a/graph/include/metadata/MetaData.h +++ b/graph/include/metadata/MetaData.h @@ -36,8 +36,8 @@ class MetaDataFactory { template static CRTPBase* create(const std::string& s, const nlohmann::json& j) { if (data().find(s) == data().end()) { - MCGLogger::instance().getErrConsole()->template warn( - "Could not create: {}, the Metadata is unknown in you application", s); + MCGLogger::instance().getErrConsole()->warn("Could not create: {}, the Metadata is unknown in you application", + s); return nullptr; } return data().at(s)(j); @@ -48,7 +48,7 @@ class MetaDataFactory { friend T; static bool registerT() { - MCGLogger::instance().getConsole()->template trace("Registering {} \n", T::key); + MCGLogger::instance().getConsole()->trace("Registering {} \n", T::key); const auto name = T::key; MetaDataFactory::data()[name] = [](const nlohmann::json& j) -> CRTPBase* { return new T(j); }; return true; diff --git a/pgis/lib/include/MetaData/CgNodeMetaData.h b/pgis/lib/include/MetaData/CgNodeMetaData.h index 8d824f8..ad69156 100644 --- a/pgis/lib/include/MetaData/CgNodeMetaData.h +++ b/pgis/lib/include/MetaData/CgNodeMetaData.h @@ -240,15 +240,15 @@ class PiraOneData : public metacg::MetaData::Registrar { template inline void setPiraOneData(T node, int numStmts = 0, bool hasBody = false, bool dominantRuntime = false, bool inPrevProfile = false) { - const auto& [has, data] = node->template checkAndGet(); - if (has) { - data->setNumberOfStatements(numStmts); - data->setHasBody(hasBody); - data->setDominantRuntime(dominantRuntime); - data->setComesFromCube(inPrevProfile); - } else { - assert_pira_one_data(); - } + const auto& [has, data] = node->template checkAndGet(); + if (has) { + data->setNumberOfStatements(numStmts); + data->setHasBody(hasBody); + data->setDominantRuntime(dominantRuntime); + data->setComesFromCube(inPrevProfile); + } else { + assert_pira_one_data(); + } } /**