Updated to support llvm 20 (#1868)
Some checks failed
Linux Python 2 / build (clang-devel gcc gcc-c++ java-11-openjdk-devel libxml2-devel llvm-devel llvm-static ncurses-devel openmotif openmotif-devel perl perl-Digest-MD5 udunits2 udunits2-devel which zlib-devel python2-devel python3-devel, map[arch:rhel]) (push) Has been cancelled
Linux Python 2 / build (map[], echo package manager already configured, bison clang flex git llvm make maven cmake zip, install -y, echo gtest already installed) (push) Has been cancelled
Linux Python 2 / build (map[arch:debian arch_ver:12 os:ubuntu tag:22.04], 2) (push) Has been cancelled
Linux Python 2 / build (map[arch:rhel arch_ver:7], yum -y install epel-release yum -y update , libX11-devel libXt-devel swig3 gtest-devel, yum) (push) Has been cancelled
Linux Python 2 / build (map[arch:rhel arch_ver:8 os:oraclelinux tag:8], 2) (push) Has been cancelled
Linux Python 2 / build (map[arch:rhel arch_ver:8 os:rockylinux tag:8], 2) (push) Has been cancelled
Linux Python 2 / build (map[arch:rhel arch_ver:8], dnf -y install epel-release dnf -y update dnf install -y 'dnf-command(config-manager)' , dnf config-manager --enable powertools dnf install -y gtest-devel , dnf, swig diffutils) (push) Has been cancelled
Linux Python 2 / build (map[os:oraclelinux], dnf config-manager --enable ol8_codeready_builder dnf install -y gtest-devel ) (push) Has been cancelled
Linux Python 2 / build (swig curl g++ libx11-dev libxml2-dev libxt-dev libmotif-common libmotif-dev zlib1g-dev llvm-dev libclang-dev libudunits2-dev libgtest-dev default-jdk python2.7-dev python3-dev python3-pip python3-venv, map[arch:debian], apt-get update, apt-get i… (push) Has been cancelled
32-bit Oracle / trick_32bit_oracle (push) Has been cancelled
Test Docker Hub Images / latest (trick_ubuntu1804) (push) Has been cancelled
More Linux / build (clang-devel gcc gcc-c++ java-11-openjdk-devel libxml2-devel llvm-devel llvm-static ncurses-devel openmotif openmotif-devel perl perl-Digest-MD5 udunits2 udunits2-devel which zlib-devel python2-devel python3-devel, map[arch:rhel]) (push) Has been cancelled
More Linux / build (map[], echo package manager already configured, bison clang flex git llvm make maven cmake zip, install -y, echo gtest already installed) (push) Has been cancelled
More Linux / build (map[arch:debian arch_ver:10 os:debian tag:10], 2) (push) Has been cancelled
More Linux / build (map[arch:debian arch_ver:10 os:debian tag:10], 3) (push) Has been cancelled
More Linux / build (map[arch:debian arch_ver:10], apt-get install -y libgtest-dev cd /usr/src/gtest cmake . make cp libgtest* /usr/lib/ ) (push) Has been cancelled
More Linux / build (map[arch:debian arch_ver:11 os:debian tag:11], 2) (push) Has been cancelled
More Linux / build (map[arch:debian arch_ver:11 os:debian tag:11], 3) (push) Has been cancelled
More Linux / build (map[arch:debian arch_ver:11 os:ubuntu tag:20.04], 2) (push) Has been cancelled
More Linux / build (map[arch:debian arch_ver:11 os:ubuntu tag:20.04], 3) (push) Has been cancelled
More Linux / build (map[arch:debian arch_ver:11], export DEBIAN_FRONTEND=noninteractive apt-get update apt-get install -y tzdata ) (push) Has been cancelled
More Linux / build (map[arch:debian arch_ver:12 os:debian tag:bookworm], 2) (push) Has been cancelled
More Linux / build (map[arch:debian arch_ver:12 os:debian tag:bookworm], 3) (push) Has been cancelled
More Linux / build (map[arch:debian], 2, python2.7-dev) (push) Has been cancelled
More Linux / build (map[arch:rhel arch_ver:8 os:almalinux tag:8], 2) (push) Has been cancelled
More Linux / build (map[arch:rhel arch_ver:8 os:almalinux tag:8], 3) (push) Has been cancelled
More Linux / build (map[arch:rhel arch_ver:8], dnf -y install epel-release dnf -y update dnf install -y 'dnf-command(config-manager)' , dnf config-manager --enable powertools dnf install -y gtest-devel , dnf, swig diffutils) (push) Has been cancelled
More Linux / build (swig curl g++ libx11-dev libxml2-dev libxt-dev libmotif-common libmotif-dev zlib1g-dev llvm-dev libclang-dev libudunits2-dev libgtest-dev default-jdk python3-dev python3-pip python3-venv, map[arch:debian], apt-get update, apt-get install -y libg… (push) Has been cancelled

Updated to support llvm 20
This commit is contained in:
Hong Chen 2025-04-02 15:38:32 -05:00 committed by GitHub
parent ec4d6d1b7b
commit 46b4817413
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 0 deletions

View File

@ -218,7 +218,12 @@ bool FieldVisitor::VisitFieldDecl( clang::FieldDecl *field ) {
if ( field->isBitField()) {
fdes->setBitField(true) ;
#if (LIBCLANG_MAJOR >= 20)
// llvm 20+ gets the bit width directly from the FieldDecl without needing the ASTContext argument
fdes->setBitFieldWidth(field->getBitWidthValue()) ;
#else
fdes->setBitFieldWidth(field->getBitWidthValue(field->getASTContext())) ;
#endif
unsigned int field_offset_bits = field->getASTContext().getFieldOffset(field) + fdes->getBaseClassOffset() * 8 ;
fdes->setBitFieldStart( 32 - (field_offset_bits % 32) - fdes->getBitFieldWidth()) ;
fdes->setBitFieldByteOffset((field_offset_bits / 32) * 4 ) ;

View File

@ -14,6 +14,10 @@
#endif
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/raw_ostream.h"
// Ensure to include VFS header for libclang versions >= 20 for createDiagnostics call
#if (LIBCLANG_MAJOR >= 20)
#include "llvm/Support/VirtualFileSystem.h"
#endif
#include "clang/Basic/Builtins.h"
#include "clang/Frontend/CompilerInstance.h"
@ -187,7 +191,20 @@ int main(int argc, char * argv[]) {
clang::CompilerInvocation::setLangDefaults(ci.getLangOpts() , clang::IK_CXX) ;
#endif
#if (LIBCLANG_MAJOR >= 20)
// Create a virtual file system
// This is required for llvm 20+ to create diagnostics properly
// llvm::IntrusiveRefCntPtr is LLVM's reference counting smart pointer
// The smart pointer is used to manage objects that require reference counting such as VFS
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> vfs = llvm::vfs::getRealFileSystem();
// createDiagnostics(llvm::vfs::FileSystem &VFS,
// DiagnosticConsumer * Client = nullptr,
// bool ShouldOwnClient = true)
// DiagnosticConsumer is set later in the code to our ICGDiagnosticConsumer and here is nullptr
ci.createDiagnostics(*vfs); // Create diagnostics for clang 20+
#else
ci.createDiagnostics();
#endif
ci.getDiagnosticOpts().ShowColors = 1 ;
ci.getDiagnostics().setIgnoreAllWarnings(true) ;
set_lang_opts(ci);