Skip to content

Commit

Permalink
Support LLVM 18
Browse files Browse the repository at this point in the history
  • Loading branch information
mgehre committed Mar 12, 2024
1 parent e59adae commit 3fd1818
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: C/C++ CI

on: [push, pull_request]
on:
push:
branches: main
pull_request:

jobs:
llvm:
Expand All @@ -9,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: [13, 14, 15, 16, 17]
version: [13, 14, 15, 16, 17, 18]
os: [ubuntu-22.04]

steps:
Expand All @@ -34,5 +37,5 @@ jobs:
run: |
mkdir build
cd build
cmake -DLLVM_VERSION_REQUIRED=${{ matrix.version }} ..
cmake
make
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")

if (LLVM_VERSION_MAJOR GREATER_EQUAL 16)
find_package(Clang ${LLVM_VERSION_MAJOR} CONFIG REQUIRED)
if (LLVM_VERSION_MAJOR GREATER_EQUAL 18)
find_package(Clang ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR} CONFIG REQUIRED)
else()
find_package(Clang ${LLVM_VERSION_MAJOR} CONFIG REQUIRED)
endif()
message(STATUS "Using ClangConfig.cmake in: ${Clang_DIR}")
endif (LLVM_VERSION_MAJOR GREATER_EQUAL 16)

Expand Down
16 changes: 8 additions & 8 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Basic/Version.h"
#include "clang/Driver/Options.h"
#include "clang/Frontend/ASTConsumers.h"
#include "clang/Frontend/FrontendActions.h"
Expand Down Expand Up @@ -113,13 +114,6 @@ class FunctionDeclMatchHandler : public MatchFinder::MatchCallback {
std::set_difference(Uses.begin(), Uses.end(), Defs.begin(), Defs.end(),
std::back_inserter(ExternalUses));

/*for (auto *F : Uses) {
llvm::errs() << "Uses: " << F << " " << F->getNameAsString() << "\n";
}
for (auto *F : Defs) {
llvm::errs() << "Defs: " << F << " " << F->getNameAsString() << "\n";
}*/

for (auto *F : ExternalUses) {
// llvm::errs() << "ExternalUses: " << F->getNameAsString() << "\n";
std::string USR;
Expand Down Expand Up @@ -175,7 +169,13 @@ class FunctionDeclMatchHandler : public MatchFinder::MatchCallback {

auto *MD = dyn_cast<CXXMethodDecl>(F);
if (MD) {
if (MD->isVirtual() && !MD->isPure() && MD->size_overridden_methods())
if (MD->isVirtual()
#if CLANG_VERSION_MAJOR >= 18
&& !MD->isPureVirtual()
#else
&& !MD->isPure()
#endif
&& MD->size_overridden_methods())
return; // overriding method
if (isa<CXXDestructorDecl>(MD))
return; // We don't see uses of destructors.
Expand Down

0 comments on commit 3fd1818

Please sign in to comment.