Skip to content
Merged
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.
15 changes: 10 additions & 5 deletions core/clingutils/src/TClingUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,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 @@ -2828,7 +2828,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 @@ -3105,7 +3105,12 @@ clang::QualType ROOT::TMetaUtils::AddDefaultParameters(clang::QualType instanceT
llvm::SmallVector<clang::TemplateArgument, 4> canonArgs;
llvm::ArrayRef<clang::TemplateArgument> template_arguments = TST->template_arguments();
unsigned int Idecl = 0, Edecl = TSTdecl->getTemplateArgs().size();
unsigned int maxAddArg = TSTdecl->getTemplateArgs().size() - dropDefault;
// If we have more arguments than the TSTdecl, it is a variadic template
// and we want all template arguments.
if (template_arguments.size() > Edecl) {
Edecl = template_arguments.size();
}
unsigned int maxAddArg = Edecl - dropDefault;
for (const clang::TemplateArgument *I = template_arguments.begin(), *E = template_arguments.end(); Idecl != Edecl;
I != E ? ++I : nullptr, ++Idecl, ++Param) {

Expand Down Expand Up @@ -3736,7 +3741,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 @@ -3836,7 +3841,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 @@ -2011,7 +2011,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 @@ -3477,7 +3477,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
7 changes: 6 additions & 1 deletion core/meta/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
# For the list of contributors see $ROOTSYS/README/CREDITS.

ROOT_ADD_GTEST(testStatusBitsChecker testStatusBitsChecker.cxx LIBRARIES Core)
ROOT_ADD_GTEST(testHashRecursiveRemove testHashRecursiveRemove.cxx LIBRARIES Core)
# Currently doesn't work on Windows after the update to LLVM20.
# Related to static initialization during JIT-ing on windows.
# Need to investigate.
if(NOT MSVC OR win_broken_tests)
ROOT_ADD_GTEST(testHashRecursiveRemove testHashRecursiveRemove.cxx LIBRARIES Core)
endif()
ROOT_ADD_GTEST(testTClass testTClass.cxx LIBRARIES Core GenVector)
ROOT_ADD_GTEST(testTDataType testTDataType.cxx LIBRARIES Core)
ROOT_ADD_GTEST(testTEnum testTEnum.cxx LIBRARIES Core)
Expand Down
55 changes: 55 additions & 0 deletions core/meta/test/testTClass.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,58 @@ TEST(TClass, ReSubstTemplateArg)
auto c = TClass::GetClass("One<std::string>");
c->BuildRealData();
}

// This is a test case for an issue that arises when template names are not desugared
// (specifically when default template arguments are involved).
// In this case, __pool will not be fully qualified (it will be missing the
// `test__gnu_cxx` prefix). We need to desugar it before fully qualifying the template names.
TEST(TClass, TemplateTemplate)
{
gInterpreter->ProcessLine(R"(
namespace test__gnu_cxx {
// This can be any template type, given we change the template parameters
// for __common_pool_policy
template<typename T>
class __pool {};

template<template<typename> class _PoolTp>
struct __common_pool_policy {};
template<typename _Poolp = __common_pool_policy<__pool> >
class __mt_alloc {};
}

namespace double32t_test__gnu_cxx {
template<typename T>
class __pool {};

template<template<typename> class _PoolTp, typename T>
struct __common_pool_policy {};
template<typename _Poolp = __common_pool_policy<__pool, Double32_t> >
class __mt_alloc {};
}

namespace test_LHCb {
template <typename ALLOC = test__gnu_cxx::__mt_alloc<>>
struct FastAllocVector {};

template <typename ALLOC = double32t_test__gnu_cxx::__mt_alloc<>>
struct FastAllocVectorDouble32 {};
}
)");

TClass *fastAllocVecClass = TClass::GetClass("test_LHCb::FastAllocVector<>");
ASSERT_NE(fastAllocVecClass, nullptr);
EXPECT_NE(strstr(fastAllocVecClass->GetName(), "test__gnu_cxx::__pool"), nullptr);
// EXPECT_EQ(strcmp(fastAllocVecClass->GetName(),
// "test_LHCb::FastAllocVector<test__gnu_cxx::__mt_alloc<test__gnu_cxx::__common_"
// "pool_policy<test__gnu_cxx::__pool> > >"),
// 0);

TClass *fastAllocVecD32Class = TClass::GetClass("test_LHCb::FastAllocVectorDouble32<>");
ASSERT_NE(fastAllocVecD32Class, nullptr);
EXPECT_NE(strstr(fastAllocVecD32Class->GetName(), "double32t_test__gnu_cxx::__pool"), nullptr);
// EXPECT_EQ(strcmp(fastAllocVecD32Class->GetName(),
// "test_LHCb::FastAllocVectorDouble32<double32t_test__gnu_cxx::__mt_alloc<double32t_test_"
// "_gnu_cxx::__common_pool_policy<double32t_test__gnu_cxx::__pool,Double32_t> > >"),
// 0);
}
9 changes: 4 additions & 5 deletions core/metacling/src/TCling.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4873,7 +4873,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 @@ -5147,8 +5147,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 @@ -7016,8 +7016,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 @@ -36,6 +36,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 @@ -179,6 +180,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
1 change: 1 addition & 0 deletions interpreter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ if(MSVC)
# replace dashes in the -EH* and -GR* flags with slashes (/EH* /GR*)
string(REPLACE " -EH" " /EH" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE " -GR" " /GR" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D CLANG_EXPORTS=1")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ignore:4049,4206,4217,4221")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /ignore:4049,4206,4217,4221")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /ignore:4049,4206,4217,4221")
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
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