Skip to content

Update ROOT and Cling to LLVM20 #19242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
8 changes: 4 additions & 4 deletions core/clingutils/src/TClingUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ static const clang::FieldDecl *GetDataMemberFromAllParents(clang::Sema &SemaR, c
clang::DeclarationName DName = &SemaR.Context.Idents.get(what);
clang::LookupResult R(SemaR, DName, clang::SourceLocation(),
clang::Sema::LookupOrdinaryName,
clang::Sema::ForExternalRedeclaration);
RedeclarationKind::ForExternalRedeclaration);
SemaR.LookupInSuper(R, &const_cast<clang::CXXRecordDecl&>(cl));
if (R.empty())
return nullptr;
Expand Down Expand Up @@ -2827,7 +2827,7 @@ void ROOT::TMetaUtils::foreachHeaderInModule(const clang::Module &module,
// We want to check for all headers except the list of excluded headers here.
for (auto HK : {clang::Module::HK_Normal, clang::Module::HK_Textual, clang::Module::HK_Private,
clang::Module::HK_PrivateTextual}) {
auto &headerList = m->Headers[HK];
const auto &headerList = m->getHeaders(HK);
for (const clang::Module::Header &moduleHeader : headerList) {
closure(moduleHeader);
}
Expand Down Expand Up @@ -3735,7 +3735,7 @@ static bool areEqualTypes(const clang::TemplateArgument& tArg,
if (!ttpdPtr->hasDefaultArgument()) return false; // we should not be here in this case, but we protect us.

// Try the fast solution
QualType tParQualType = ttpdPtr->getDefaultArgument();
QualType tParQualType = ttpdPtr->getDefaultArgument().getArgument().getAsType();
const QualType tArgQualType = tArg.getAsType();

// Now the equality tests for non template specialisations.
Expand Down Expand Up @@ -3835,7 +3835,7 @@ static bool areEqualValues(const clang::TemplateArgument& tArg,

// 64 bits wide and signed (non unsigned, that is why "false")
llvm::APSInt defaultValueAPSInt(64, false);
if (Expr* defArgExpr = nttpd.getDefaultArgument()) {
if (Expr* defArgExpr = nttpd.getDefaultArgument().getArgument().getAsExpr()) {
const ASTContext& astCtxt = nttpdPtr->getASTContext();
if (auto Value = defArgExpr->getIntegerConstantExpr(astCtxt))
defaultValueAPSInt = *Value;
Expand Down
4 changes: 2 additions & 2 deletions core/dictgen/src/rootcling_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2018,7 +2018,7 @@ static bool WriteAST(llvm::StringRef fileName, clang::CompilerInstance *compiler

compilerInstance->getFrontendOpts().RelocatablePCH = true;

writer.WriteAST(compilerInstance->getSema(), fileName.str(), module, iSysRoot);
writer.WriteAST(&compilerInstance->getSema(), fileName.str(), module, iSysRoot);

// Write the generated bitstream to "Out".
out->write(&buffer.front(), buffer.size());
Expand Down Expand Up @@ -3493,7 +3493,7 @@ class TRootClingCallbacks : public cling::InterpreterCallbacks {
void InclusionDirective(clang::SourceLocation /*HashLoc*/, const clang::Token & /*IncludeTok*/,
llvm::StringRef FileName, bool IsAngled, clang::CharSourceRange /*FilenameRange*/,
clang::OptionalFileEntryRef /*File*/, llvm::StringRef /*SearchPath*/,
llvm::StringRef /*RelativePath*/, const clang::Module * /*Imported*/,
llvm::StringRef /*RelativePath*/, const clang::Module * /*Imported*/, bool /*ModuleImported*/,
clang::SrcMgr::CharacteristicKind /*FileType*/) override
{
if (isLocked) return;
Expand Down
9 changes: 4 additions & 5 deletions core/metacling/src/TCling.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4864,7 +4864,7 @@ TInterpreter::DeclId_t TCling::GetDataMember(ClassInfo_t *opaque_cl, const char
DeclarationName DName = &SemaR.Context.Idents.get(name);

LookupResult R(SemaR, DName, SourceLocation(), Sema::LookupOrdinaryName,
Sema::ForExternalRedeclaration);
RedeclarationKind::ForExternalRedeclaration);

cling::utils::Lookup::Named(&SemaR, R);

Expand Down Expand Up @@ -5138,8 +5138,8 @@ void TCling::GetFunctionOverloads(ClassInfo_t *cl, const char *funcname,
}

// NotForRedeclaration: we want to find names in inline namespaces etc.
clang::LookupResult R(S, DName, clang::SourceLocation(),
Sema::LookupOrdinaryName, clang::Sema::NotForRedeclaration);
clang::LookupResult R(S, DName, clang::SourceLocation(), Sema::LookupOrdinaryName,
RedeclarationKind::NotForRedeclaration);
R.suppressDiagnostics(); // else lookup with NotForRedeclaration will check access etc
S.LookupQualifiedName(R, const_cast<DeclContext*>(DeclCtx));
if (R.empty()) return;
Expand Down Expand Up @@ -7007,8 +7007,7 @@ void TCling::InvalidateCachedDecl(const std::tuple<TListOfDataMembers*,
InvalidateCachedDecl(Lists, I);

// For NamespaceDecl (redeclarable), only invalidate this redecl.
if (D->getKind() != Decl::Namespace
|| cast<NamespaceDecl>(D)->isOriginalNamespace())
if (D->getKind() != Decl::Namespace || cast<NamespaceDecl>(D)->isFirstDecl())
C->ResetClassInfo();
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/metacling/src/TClingCallFunc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -914,9 +914,9 @@ void TClingCallFunc::make_narg_call_with_return(const unsigned N, const string &
if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(FD)) {
if (N <= 1 && llvm::isa<UsingShadowDecl>(GetFunctionOrShadowDecl())) {
auto SpecMemKind = fInterp->getSema().getSpecialMember(CD);
if ((N == 0 && SpecMemKind == clang::Sema::CXXDefaultConstructor) ||
if ((N == 0 && SpecMemKind == clang::CXXSpecialMemberKind::DefaultConstructor) ||
(N == 1 &&
(SpecMemKind == clang::Sema::CXXCopyConstructor || SpecMemKind == clang::Sema::CXXMoveConstructor))) {
(SpecMemKind == clang::CXXSpecialMemberKind::CopyConstructor || SpecMemKind == clang::CXXSpecialMemberKind::MoveConstructor))) {
// Using declarations cannot inject special members; do not call them
// as such. This might happen by using `Base(Base&, int = 12)`, which
// is fine to be called as `Derived d(someBase, 42)` but not as
Expand Down
2 changes: 2 additions & 0 deletions core/metacling/src/TClingCallbacks.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "clang/Serialization/GlobalModuleIndex.h"
#include "clang/Basic/DiagnosticSema.h"

#include "llvm/ExecutionEngine/Orc/AbsoluteSymbols.h"
#include "llvm/ExecutionEngine/Orc/Core.h"

#include "llvm/Support/Error.h"
Expand Down Expand Up @@ -178,6 +179,7 @@ void TClingCallbacks::InclusionDirective(clang::SourceLocation sLoc/*HashLoc*/,
llvm::StringRef /*SearchPath*/,
llvm::StringRef /*RelativePath*/,
const clang::Module * Imported,
bool ModuleImported,
clang::SrcMgr::CharacteristicKind FileType) {
// We found a module. Do not try to do anything else.
Sema &SemaR = m_Interpreter->getSema();
Expand Down
2 changes: 1 addition & 1 deletion core/metacling/src/TClingCallbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class TClingCallbacks : public cling::InterpreterCallbacks {
llvm::StringRef FileName, bool /*IsAngled*/, clang::CharSourceRange /*FilenameRange*/,
clang::OptionalFileEntryRef /*File*/, llvm::StringRef /*SearchPath*/,
llvm::StringRef /*RelativePath*/, const clang::Module * /*Imported*/,
clang::SrcMgr::CharacteristicKind /*FileType*/) override;
bool /*ModuleImported*/, clang::SrcMgr::CharacteristicKind /*FileType*/) override;

// Preprocessor callbacks used to handle special cases like for example:
// #include "myMacro.C+"
Expand Down
15 changes: 7 additions & 8 deletions core/metacling/src/TClingMethodInfo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ bool TClingCXXRecMethIter::ShouldSkip(const clang::Decl *D) const
if (const auto *RD = llvm::dyn_cast<clang::RecordDecl>(FD->getDeclContext())) {
if (const auto *CXXMD = llvm::dyn_cast<clang::CXXMethodDecl>(FD)) {
if (RD->isAnonymousStructOrUnion() &&
GetInterpreter()->getSema().getSpecialMember(CXXMD) != clang::Sema::CXXInvalid) {
GetInterpreter()->getSema().getSpecialMember(CXXMD) != clang::CXXSpecialMemberKind::Invalid) {
// Do not enumerate special members of anonymous structs.
return true;
}
Expand All @@ -108,14 +108,14 @@ bool TClingCXXRecMethIter::ShouldSkip(const clang::UsingShadowDecl *USD) const
if (auto *FD = llvm::dyn_cast<clang::FunctionDecl>(USD->getTargetDecl())) {
if (const auto *CXXMD = llvm::dyn_cast<clang::CXXMethodDecl>(FD)) {
auto SpecMemKind = GetInterpreter()->getSema().getSpecialMember(CXXMD);
if ((SpecMemKind == clang::Sema::CXXDefaultConstructor && CXXMD->getNumParams() == 0) ||
((SpecMemKind == clang::Sema::CXXCopyConstructor || SpecMemKind == clang::Sema::CXXMoveConstructor) &&
if ((SpecMemKind == clang::CXXSpecialMemberKind::DefaultConstructor && CXXMD->getNumParams() == 0) ||
((SpecMemKind == clang::CXXSpecialMemberKind::CopyConstructor || SpecMemKind == clang::CXXSpecialMemberKind::MoveConstructor) &&
CXXMD->getNumParams() == 1)) {
// This is a special member pulled in through a using decl. Special
// members of derived classes cannot be replaced; ignore this using decl,
// and keep only the (still possibly compiler-generated) special member of the
// derived class.
// NOTE that e.g. `Klass(int = 0)` has SpecMemKind == clang::Sema::CXXDefaultConstructor,
// NOTE that e.g. `Klass(int = 0)` has SpecMemKind == clang::CXXSpecialMemberKind::DefaultConstructor,
// yet this signature must be exposed, so check the argument count.
return true;
}
Expand Down Expand Up @@ -172,11 +172,11 @@ TClingCXXRecMethIter::InstantiateTemplateWithDefaults(const clang::RedeclarableT
} else if (auto TTP = dyn_cast<TemplateTypeParmDecl>(templateParm)) {
if (!TTP->hasDefaultArgument())
return nullptr;
defaultTemplateArgs.emplace_back(TTP->getDefaultArgument());
defaultTemplateArgs.emplace_back(TTP->getDefaultArgument().getArgument());
} else if (auto NTTP = dyn_cast<NonTypeTemplateParmDecl>(templateParm)) {
if (!NTTP->hasDefaultArgument())
return nullptr;
defaultTemplateArgs.emplace_back(NTTP->getDefaultArgument());
defaultTemplateArgs.emplace_back(NTTP->getDefaultArgument().getArgument());
} else if (auto TTP = dyn_cast<TemplateTemplateParmDecl>(templateParm)) {
if (!TTP->hasDefaultArgument())
return nullptr;
Expand Down Expand Up @@ -204,8 +204,7 @@ TClingCXXRecMethIter::InstantiateTemplateWithDefaults(const clang::RedeclarableT

// Collect the function arguments of the templated function, substituting
// dependent types as possible.
TemplateArgumentList templArgList(TemplateArgumentList::OnStack, defaultTemplateArgs);
MultiLevelTemplateArgumentList MLTAL{FTD, templArgList.asArray(), /*Final=*/false};
MultiLevelTemplateArgumentList MLTAL{FTD, defaultTemplateArgs, /*Final=*/false};
for (const clang::ParmVarDecl *param : templatedDecl->parameters()) {
QualType paramType = param->getOriginalType();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ namespace cling {
llvm::StringRef SearchPath,
llvm::StringRef RelativePath,
const clang::Module *Imported,
bool ModuleImported,
clang::SrcMgr::CharacteristicKind FileType) override;
void TransactionCommitted(const Transaction& T) override;

Expand Down
3 changes: 2 additions & 1 deletion interpreter/cling/include/cling/Interpreter/CIFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ namespace cling {
clang::CompilerInstance*
createCI(llvm::StringRef Code, const InvocationOptions& Opts,
const char* LLVMDir, std::unique_ptr<clang::ASTConsumer> consumer,
const ModuleFileExtensions& moduleExtensions);
const ModuleFileExtensions& moduleExtensions,
bool AutoComplete = false);

clang::CompilerInstance*
createCI(MemBufPtr_t Buffer, int Argc, const char* const* Argv,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

using namespace clang;

namespace clang {
class CompilerInstance;
}

namespace cling {
/// \brief Create a new printing code-completion consumer that prints its
/// results to the given raw output stream.
Expand Down Expand Up @@ -50,6 +54,28 @@ namespace cling {
completions = m_Completions;
}
};

struct ClingCodeCompleter {
ClingCodeCompleter() = default;
std::string Prefix;

/// \param InterpCI [in] The compiler instance that is used to trigger code
/// completion

/// \param Content [in] The string where code completion is triggered.

/// \param Line [in] The line number of the code completion point.

/// \param Col [in] The column number of the code completion point.

/// \param ParentCI [in] The running interpreter compiler instance that
/// provides ASTContexts.

/// \param CCResults [out] The completion results.
void codeComplete(CompilerInstance* InterpCI, llvm::StringRef Content,
unsigned Line, unsigned Col, CompilerInstance* ParentCI,
std::vector<std::string>& CCResults);
};
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ namespace cling {
llvm::StringRef /*SearchPath*/,
llvm::StringRef /*RelativePath*/,
const clang::Module* /*Imported*/,
bool /*ModuleImported*/,
clang::SrcMgr::CharacteristicKind /*FileType*/) {}
virtual void EnteredSubmodule(clang::Module* /*M*/,
clang::SourceLocation /*ImportLoc*/,
Expand Down
1 change: 1 addition & 0 deletions interpreter/cling/lib/Interpreter/AutoloadCallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ namespace cling {
llvm::StringRef /*SearchPath*/,
llvm::StringRef /*RelativePath*/,
const clang::Module */*Imported*/,
bool /*ModuleImported*/,
clang::SrcMgr::CharacteristicKind /*FileType*/) {
// If File is 0 this means that the #included file doesn't exist.
if (!File)
Expand Down
Loading
Loading