Skip to content

Commit

Permalink
Merge pull request #15696 from devajithvs/dev.llvm18
Browse files Browse the repository at this point in the history
Update ROOT and Cling to LLVM18
  • Loading branch information
dpiparo authored Sep 11, 2024
2 parents 3e03f78 + a52d34d commit 7f00674
Show file tree
Hide file tree
Showing 6,343 changed files with 686,909 additions and 336,626 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
3 changes: 2 additions & 1 deletion .github/workflows/root-ci-config/build_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,11 @@ def dump_requested_config(options):
@github_log_group("Build")
def cmake_build(buildtype):
generator_flags = "-- '-verbosity:minimal'" if WINDOWS else ""
parallel_jobs = "4" if WINDOWS else str(os.cpu_count())

builddir = os.path.join(WORKDIR, "build")
result = subprocess_with_log(f"""
cmake --build '{builddir}' --config '{buildtype}' --parallel '{os.cpu_count()}' {generator_flags}
cmake --build '{builddir}' --config '{buildtype}' --parallel '{parallel_jobs}' {generator_flags}
""")

if result != 0:
Expand Down
12 changes: 9 additions & 3 deletions core/clingutils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,15 @@ if (runtime_cxxmodules)
set(custom_modulemaps ${custom_modulemaps} vc.modulemap)

# We need to override the default modulemap because instead of producing a
# single std.pcm, produces hundreds of pcms. This changed with sdk 15.3.
if (CMAKE_SYSTEM_NAME MATCHES Darwin AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15.0.0.15000309)
set(custom_modulemaps ${custom_modulemaps} std_darwin.modulemap)
# single std.pcm, produces hundreds of pcms. This changed with MacOSX14.4.sdk
# To support macOS 13 with LLVM 18, we need to patch the modulemap from
# MacOSX14.2.sdk
if (APPLE)
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0.0.15000309)
set(custom_modulemaps ${custom_modulemaps} std_darwin.MacOSX14.2.sdk.modulemap)
else()
set(custom_modulemaps ${custom_modulemaps} std_darwin.modulemap)
endif()
endif()

if (NOT libcxx)
Expand Down
13 changes: 7 additions & 6 deletions core/clingutils/src/TClingUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3094,7 +3094,7 @@ clang::QualType ROOT::TMetaUtils::AddDefaultParameters(clang::QualType instanceT

if (!prefix_changed && !mightHaveChanged) return originalType;
if (prefix) {
instanceType = Ctx.getElaboratedType(clang::ETK_None,prefix,instanceType);
instanceType = Ctx.getElaboratedType(clang::ElaboratedTypeKeyword::None, prefix, instanceType);
instanceType = Ctx.getQualifiedType(instanceType,prefix_qualifiers);
}
return instanceType;
Expand Down Expand Up @@ -3388,7 +3388,7 @@ std::string ROOT::TMetaUtils::GetFileName(const clang::Decl& decl,
= HdrSearch.LookupFile(llvm::sys::path::filename(headerFE->getName()),
SourceLocation(),
true /*isAngled*/, nullptr/*FromDir*/, foundDir,
ArrayRef<std::pair<const FileEntry *, const DirectoryEntry *>>(),
ArrayRef<std::pair<OptionalFileEntryRef, DirectoryEntryRef>>(),
nullptr/*Searchpath*/, nullptr/*RelPath*/,
nullptr/*SuggestedModule*/, nullptr/*RequestingModule*/,
nullptr/*IsMapped*/, nullptr /*IsFrameworkFound*/,
Expand Down Expand Up @@ -3448,7 +3448,7 @@ std::string ROOT::TMetaUtils::GetFileName(const clang::Decl& decl,
ConstSearchDirIterator* FoundDir = nullptr;
FELong = HdrSearch.LookupFile(trailingPart, SourceLocation(),
true /*isAngled*/, nullptr/*FromDir*/, FoundDir,
ArrayRef<std::pair<const FileEntry *, const DirectoryEntry *>>(),
ArrayRef<std::pair<OptionalFileEntryRef, DirectoryEntryRef>>(),
nullptr/*Searchpath*/, nullptr/*RelPath*/,
nullptr/*SuggestedModule*/, nullptr/*RequestingModule*/,
nullptr/*IsMapped*/, nullptr /*IsFrameworkFound*/);
Expand All @@ -3474,7 +3474,7 @@ std::string ROOT::TMetaUtils::GetFileName(const clang::Decl& decl,
// (or are we back to the previously found spelling, which is fine, too)
if (HdrSearch.LookupFile(trailingPart, SourceLocation(),
true /*isAngled*/, nullptr/*FromDir*/, FoundDir,
ArrayRef<std::pair<const FileEntry *, const DirectoryEntry *>>(),
ArrayRef<std::pair<OptionalFileEntryRef, DirectoryEntryRef>>(),
nullptr/*Searchpath*/, nullptr/*RelPath*/,
nullptr/*SuggestedModule*/, nullptr/*RequestingModule*/,
nullptr/*IsMapped*/, nullptr /*IsFrameworkFound*/) == FELong) {
Expand Down Expand Up @@ -4007,7 +4007,7 @@ static void KeepNParams(clang::QualType& normalizedType,
// Here we have (prefix_changed==true || mightHaveChanged), in both case
// we need to reconstruct the type.
if (prefix) {
normalizedType = astCtxt.getElaboratedType(clang::ETK_None,prefix,normalizedType);
normalizedType = astCtxt.getElaboratedType(clang::ElaboratedTypeKeyword::None, prefix, normalizedType);
normalizedType = astCtxt.getQualifiedType(normalizedType,prefix_qualifiers);
}

Expand Down Expand Up @@ -4633,7 +4633,8 @@ clang::QualType ROOT::TMetaUtils::ReSubstTemplateArg(clang::QualType input, cons
clang::NestedNameSpecifier *scope = ReSubstTemplateArgNNS(Ctxt,etype->getQualifier(),instance);
clang::QualType subTy = ReSubstTemplateArg(clang::QualType(etype->getNamedType().getTypePtr(),0),instance);

if (scope) subTy = Ctxt.getElaboratedType(clang::ETK_None,scope,subTy);
if (scope)
subTy = Ctxt.getElaboratedType(clang::ElaboratedTypeKeyword::None, scope, subTy);
subTy = Ctxt.getQualifiedType(subTy,scope_qualifiers);
return subTy;
}
Expand Down
2 changes: 1 addition & 1 deletion core/dictgen/src/DictSelectionReader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ bool DictSelectionReader::SecondPass(const clang::RecordDecl &recordDecl)
userDefinedProperty = propNames::comment + propNames::separator + "||";
}
if (!userDefinedProperty.empty()) {
fieldPtr->addAttr(clang::AnnotateAttr::CreateImplicit(C, userDefinedProperty));
fieldPtr->addAttr(clang::AnnotateAttr::CreateImplicit(C, userDefinedProperty, nullptr, 0));
userDefinedProperty = "";
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/dictgen/src/LinkdefReader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ bool LinkdefReader::Parse(SelectionRules &sr, llvm::StringRef code, const std::v
clang::Token tok;
do {
PP.Lex(tok);
} while (tok.isNot(clang::tok::eof));
} while (tok.isNot(clang::tok::annot_repl_input_end));

fSelectionRules = nullptr;
return 0 == DClient.getNumErrors();
Expand Down
1 change: 1 addition & 0 deletions core/dictgen/src/Scanner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <iostream>
#include <sstream> // class ostringstream
#include "llvm/ADT/StringExtras.h"

#include "SelectionRules.h"

Expand Down
8 changes: 4 additions & 4 deletions core/dictgen/src/TModuleGenerator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ TModuleGenerator::GetSourceFileKind(const char *filename) const
auto hdrFileEntry
= HdrSearch.LookupFile(filename, clang::SourceLocation(),
true /*isAngled*/, nullptr /*FromDir*/, CurDir,
clang::ArrayRef<std::pair<const clang::FileEntry*,
const clang::DirectoryEntry*>>(),
clang::ArrayRef<std::pair<clang::OptionalFileEntryRef,
clang::DirectoryEntryRef>>(),
nullptr /*SearchPath*/,/*RelativePath*/ nullptr,
nullptr /*RequestingModule*/, nullptr /*SuggestedModule*/,
nullptr /*IsMapped*/, nullptr /*IsFrameworkFound*/);
Expand Down Expand Up @@ -581,8 +581,8 @@ bool TModuleGenerator::FindHeader(const std::string &hdrName, std::string &hdrFu
if (auto hdrFileEntry
= HdrSearch.LookupFile(hdrName, clang::SourceLocation(),
true /*isAngled*/, nullptr /*FromDir*/, CurDir,
clang::ArrayRef<std::pair<const clang::FileEntry*,
const clang::DirectoryEntry*>>(),
clang::ArrayRef<std::pair<clang::OptionalFileEntryRef,
clang::DirectoryEntryRef>>(),
nullptr /*SearchPath*/, nullptr /*RelativePath*/,
nullptr /*RequestingModule*/, nullptr/*SuggestedModule*/,
nullptr /*IsMapped*/, nullptr /*IsFrameworkFound*/)) {
Expand Down
15 changes: 7 additions & 8 deletions core/dictgen/src/rootcling_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ static void AnnotateFieldDecl(clang::FieldDecl &decl,
// before persisting the ProtoClasses in the root pcms.
// BEGIN ROOT PCMS
if (name == propNames::comment) {
decl.addAttr(clang::AnnotateAttr::CreateImplicit(C, value));
decl.addAttr(clang::AnnotateAttr::CreateImplicit(C, value, nullptr, 0));
}
// END ROOT PCMS

Expand All @@ -308,16 +308,15 @@ static void AnnotateFieldDecl(clang::FieldDecl &decl,
// This next line is here to use the root pcms. Indeed we need to annotate the AST
// before persisting the ProtoClasses in the root pcms.
// BEGIN ROOT PCMS
decl.addAttr(clang::AnnotateAttr::CreateImplicit(C, "!"));
decl.addAttr(clang::AnnotateAttr::CreateImplicit(C, "!", nullptr, 0));
// END ROOT PCMS
// The rest of the lines are not changed to leave in place the system which
// works with bulk header parsing on library load.
} else {
userDefinedProperty = name + propNames::separator + value;
}
ROOT::TMetaUtils::Info(nullptr, "%s %s\n", varName.c_str(), userDefinedProperty.c_str());
decl.addAttr(clang::AnnotateAttr::CreateImplicit(C, userDefinedProperty));

decl.addAttr(clang::AnnotateAttr::CreateImplicit(C, userDefinedProperty, nullptr, 0));
}
}
}
Expand Down Expand Up @@ -362,7 +361,7 @@ void AnnotateDecl(clang::CXXRecordDecl &CXXRD,
const std::string &value = attr.second;
userDefinedProperty = name + ROOT::TMetaUtils::propNames::separator + value;
if (genreflex::verbose) std::cout << " * " << userDefinedProperty << std::endl;
CXXRD.addAttr(AnnotateAttr::CreateImplicit(C, userDefinedProperty));
CXXRD.addAttr(AnnotateAttr::CreateImplicit(C, userDefinedProperty, nullptr, 0));
}
}

Expand All @@ -389,14 +388,14 @@ void AnnotateDecl(clang::CXXRecordDecl &CXXRD,
if (comment.size()) {
// The ClassDef annotation is for the class itself
if (isClassDefMacro) {
CXXRD.addAttr(AnnotateAttr::CreateImplicit(C, comment.str()));
CXXRD.addAttr(AnnotateAttr::CreateImplicit(C, comment.str(), nullptr, 0));
} else if (!isGenreflex) {
// Here we check if we are in presence of a selection file so that
// the comment does not ends up as a decoration in the AST,
// Nevertheless, w/o PCMS this has no effect, since the headers
// are parsed at runtime and the information in the AST dumped by
// rootcling is not relevant.
(*I)->addAttr(AnnotateAttr::CreateImplicit(C, comment.str()));
(*I)->addAttr(AnnotateAttr::CreateImplicit(C, comment.str(), nullptr, 0));
}
}
// Match decls with sel rules if we are in presence of a selection file
Expand Down Expand Up @@ -3909,7 +3908,7 @@ static bool ModuleContainsHeaders(TModuleGenerator &modGen, clang::HeaderSearch
header, clang::SourceLocation(),
/*isAngled*/ false,
/*FromDir*/ 0, CurDir,
clang::ArrayRef<std::pair<const clang::FileEntry *, const clang::DirectoryEntry *>>(),
clang::ArrayRef<std::pair<clang::OptionalFileEntryRef, clang::DirectoryEntryRef>>(),
/*SearchPath*/ 0,
/*RelativePath*/ 0,
/*RequestingModule*/ 0, &SuggestedModule,
Expand Down
9 changes: 5 additions & 4 deletions core/metacling/src/TCling.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3236,8 +3236,8 @@ Bool_t TCling::IsLoaded(const char* filename) const
clang::SourceLocation(),
/*isAngled*/ false,
/*FromDir*/ nullptr, CurDir,
clang::ArrayRef<std::pair<const clang::FileEntry *,
const clang::DirectoryEntry *>>(),
clang::ArrayRef<std::pair<clang::OptionalFileEntryRef,
clang::DirectoryEntryRef>>(),
/*SearchPath*/ nullptr,
/*RelativePath*/ nullptr,
/*RequestingModule*/ nullptr,
Expand Down Expand Up @@ -7034,6 +7034,7 @@ static std::string GetClassSharedLibsForModule(const char *cls, cling::LookupHel
case TemplateArgument::Integral:
case TemplateArgument::Pack:
case TemplateArgument::NullPtr:
case TemplateArgument::StructuralValue:
case TemplateArgument::Expression:
case TemplateArgument::Template:
case TemplateArgument::TemplateExpansion: return;
Expand Down Expand Up @@ -8723,7 +8724,7 @@ void TCling::SetDeclAttr(DeclId_t declId, const char* attribute)
{
Decl* decl = static_cast<Decl*>(const_cast<void*>(declId));
ASTContext &C = decl->getASTContext();
decl->addAttr(AnnotateAttr::CreateImplicit(C, attribute));
decl->addAttr(AnnotateAttr::CreateImplicit(C, attribute, nullptr, 0));
}

//______________________________________________________________________________
Expand Down Expand Up @@ -8902,7 +8903,7 @@ Long_t TCling::FuncTempInfo_Property(FuncTempInfo_t *ft_info) const
if (md->isVirtual()) {
property |= kIsVirtual;
}
if (md->isPure()) {
if (md->isPureVirtual()) {
property |= kIsPureVirtual;
}
if (const clang::CXXConstructorDecl *cd =
Expand Down
7 changes: 3 additions & 4 deletions core/metacling/src/TClingCallbacks.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ class AutoloadLibraryMU : public llvm::orc::MaterializationUnit {
}

if (addr) {
loadedSymbols[symbol] =
llvm::JITEvaluatedSymbol(llvm::pointerToJITTargetAddress(addr), llvm::JITSymbolFlags::Exported);
loadedSymbols[symbol] = {llvm::orc::ExecutorAddr::fromPtr(addr), llvm::JITSymbolFlags::Exported};
} else {
// Collect all failing symbols, delegate their responsibility and then
// fail their materialization. R->defineNonExistent() sounds like it
Expand Down Expand Up @@ -858,7 +857,7 @@ bool TClingCallbacks::tryResolveAtRuntimeInternal(LookupResult &R, Scope *S) {
// is a gross hack, because TClingCallbacks shouldn't know about
// EvaluateTSynthesizer at all!

Wrapper->addAttr(AnnotateAttr::CreateImplicit(C, "__ResolveAtRuntime"));
Wrapper->addAttr(AnnotateAttr::CreateImplicit(C, "__ResolveAtRuntime", nullptr, 0));

// Here we have the scope but we cannot do Sema::PushDeclContext, because
// on pop it will try to go one level up, which we don't want.
Expand Down Expand Up @@ -995,7 +994,7 @@ bool TClingCallbacks::tryInjectImplicitAutoKeyword(LookupResult &R, Scope *S) {
// Annotate the decl to give a hint in cling.
// FIXME: We should move this in cling, when we implement turning it on
// and off.
Result->addAttr(AnnotateAttr::CreateImplicit(C, "__Auto"));
Result->addAttr(AnnotateAttr::CreateImplicit(C, "__Auto", nullptr, 0));

R.addDecl(Result);

Expand Down
17 changes: 9 additions & 8 deletions core/metacling/src/TClingDataMemberInfo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -397,16 +397,17 @@ Longptr_t TClingDataMemberInfo::Offset()
// clang there is misbehaviour in MangleContext::shouldMangleDeclName.
// enum constants are essentially numbers and don't get addresses. However
// ROOT expects the address to the enum constant initializer to be returned.
else if (const EnumConstantDecl *ECD = dyn_cast<EnumConstantDecl>(D))
else if (const EnumConstantDecl *ECD = dyn_cast<EnumConstantDecl>(D)) {
// The raw data is stored as a long long, so we need to find the 'long'
// part.
#ifdef R__BYTESWAP
// In this case at the beginning.
return reinterpret_cast<Longptr_t>(ECD->getInitVal().getRawData());
#else
// In this case in the second part.
return reinterpret_cast<Longptr_t>(((char*)ECD->getInitVal().getRawData())+sizeof(Longptr_t) );
#endif

// The memory leak for `EnumConstantDecl` was fixed in:
// https://github.com/llvm/llvm-project/pull/78311
// We were relying on the leak to provide the address for EnumConstantDecl.
// Now store the data value as a member instead.
fEnumValue = ECD->getInitVal().getExtValue();
return reinterpret_cast<Longptr_t>(&fEnumValue);
}
return -1L;
}

Expand Down
1 change: 1 addition & 0 deletions core/metacling/src/TClingDataMemberInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class TClingDataMemberInfo final : public TClingDeclInfo {
TClingDataMemberIter fIter; // Current decl.
std::string fTitle; // The meta info for the member.
bool fFirstTime = true; // We need to skip the first increment to support the cint Next() semantics.
int64_t fEnumValue; // Special case to handle enums

mutable std::string fIoType;
mutable std::string fIoName;
Expand Down
4 changes: 2 additions & 2 deletions core/metacling/src/TClingMethodArgInfo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ const char *TClingMethodArgInfo::DefaultValue() const
if (!IsValid()) {
return nullptr;
}
// Could deserialize / create instantiated decls.
cling::Interpreter::PushTransactionRAII RAII(fInterp);
const clang::ParmVarDecl *pvd = GetDecl();
// Instantiate default arg if needed
if (pvd->hasUninstantiatedDefaultArg()) {
// Could deserialize / create instantiated decls.
cling::Interpreter::PushTransactionRAII RAII(fInterp);
auto fd = llvm::cast_or_null<clang::FunctionDecl>(TClingDeclInfo::GetDecl());
fInterp->getSema().BuildCXXDefaultArgExpr(clang::SourceLocation(),
const_cast<clang::FunctionDecl*>(fd),
Expand Down
2 changes: 1 addition & 1 deletion core/metacling/src/TClingMethodInfo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ long TClingMethodInfo::Property() const
if (md->isVirtual()) {
property |= kIsVirtual;
}
if (md->isPure()) {
if (md->isPureVirtual()) {
property |= kIsPureVirtual;
}
if (const clang::CXXConstructorDecl *cd =
Expand Down
6 changes: 3 additions & 3 deletions core/sanitizer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ set_property(GLOBAL APPEND PROPERTY ROOT_EXPORTED_TARGETS ${library})
add_library(ROOT::${library} ALIAS ${library})

# Now sanitize executables that are not created with ROOT_EXECUTABLE():
set_property(TARGET llvm-tblgen clang-tblgen
APPEND PROPERTY LINK_LIBRARIES ${library})
add_dependencies(llvm-tblgen ROOTStaticSanitizerConfig)
foreach(target llvm-min-tblgen llvm-tblgen clang-tblgen)
target_link_libraries(${target} PRIVATE ${library})
endforeach()
2 changes: 1 addition & 1 deletion interpreter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if (NOT builtin_clang)
endif()

#--Set the LLVM version required for ROOT-----------------------------------------------------------
set(ROOT_LLVM_VERSION_REQUIRED_MAJOR 16)
set(ROOT_LLVM_VERSION_REQUIRED_MAJOR 18)

#---Define the way we want to build and what of llvm/clang/cling------------------------------------
set(LLVM_ENABLE_RTTI ON CACHE BOOL "")
Expand Down
1 change: 1 addition & 0 deletions interpreter/cling/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ endif()

if(MSVC)
add_definitions(/DNOMINMAX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:preprocessor")
endif()

if (APPLE)
Expand Down
5 changes: 3 additions & 2 deletions interpreter/cling/include/cling/Interpreter/ClingOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
#ifndef CLING_CLINGOPTIONS_H
#define CLING_CLINGOPTIONS_H

#include "llvm/Option/OptTable.h"

namespace cling {
namespace driver {
namespace clingoptions {
enum ID {
OPT_INVALID = 0, // This is not an option ID.
#define PREFIX(NAME, VALUE)
#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
HELPTEXT, METAVAR, VALUES) OPT_##ID,
#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__),
#include "cling/Interpreter/ClingOptions.inc"
LastOption
#undef OPTION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include "clang/Basic/CodeGenOptions.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/Triple.h"
#include "llvm/TargetParser/Triple.h"

#include <string>
#include <vector>
Expand Down Expand Up @@ -121,7 +121,7 @@ namespace cling {
///\param [in] hostTriple - The llvm triple of the host system
void setCuArgs(const clang::LangOptions& langOpts,
const cling::InvocationOptions& invocationOptions,
const clang::codegenoptions::DebugInfoKind debugInfo,
const llvm::codegenoptions::DebugInfoKind debugInfo,
const llvm::Triple hostTriple);

public:
Expand Down
1 change: 1 addition & 0 deletions interpreter/cling/include/cling/Utils/ParserStateRAII.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "clang/Basic/SourceLocation.h"
#include "clang/Parse/Parser.h"
#include "clang/Sema/EnterExpressionEvaluationContext.h"

namespace clang {
class Preprocessor;
Expand Down
Loading

0 comments on commit 7f00674

Please sign in to comment.