Skip to content
Closed
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/modules/RootNewMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ function(ROOT_GENERATE_DICTIONARY dictionary)

if(cpp_module_file)
set(newargs -cxxmodule ${newargs})
set(pcm_name)
endif()

#---what rootcling command to use--------------------------
Expand Down
2 changes: 1 addition & 1 deletion core/clingutils/res/TClingUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ bool hasOpaqueTypedef(const AnnotatedRecordDecl &cl, const cling::Interpreter &i
bool HasResetAfterMerge(clang::CXXRecordDecl const*, const cling::Interpreter&);

//______________________________________________________________________________
bool NeedDestructor(clang::CXXRecordDecl const*);
bool NeedDestructor(clang::CXXRecordDecl const*, const cling::Interpreter&);

//______________________________________________________________________________
bool NeedTemplateKeyword(clang::CXXRecordDecl const*);
Expand Down
16 changes: 9 additions & 7 deletions core/clingutils/src/TClingUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1116,12 +1116,14 @@ bool ROOT::TMetaUtils::HasIOConstructor(const clang::CXXRecordDecl *cl,

////////////////////////////////////////////////////////////////////////////////

bool ROOT::TMetaUtils::NeedDestructor(const clang::CXXRecordDecl *cl)
bool ROOT::TMetaUtils::NeedDestructor(const clang::CXXRecordDecl *cl,
const cling::Interpreter& interp)
{
if (!cl) return false;

if (cl->hasUserDeclaredDestructor()) {

cling::Interpreter::PushTransactionRAII clingRAII(const_cast<cling::Interpreter*>(&interp));
clang::CXXDestructorDecl *dest = cl->getDestructor();
if (dest) {
return (dest->getAccess() == clang::AS_public);
Expand Down Expand Up @@ -1678,7 +1680,7 @@ void ROOT::TMetaUtils::WriteClassInit(std::ostream& finalString,
if (HasIOConstructor(decl, args, ctorTypes, interp)) {
finalString << " static void *new_" << mappedname.c_str() << "(void *p = 0);" << "\n";

if (args.size()==0 && NeedDestructor(decl))
if (args.size()==0 && NeedDestructor(decl, interp))
{
finalString << " static void *newArray_";
finalString << mappedname.c_str();
Expand All @@ -1687,7 +1689,7 @@ void ROOT::TMetaUtils::WriteClassInit(std::ostream& finalString,
}
}

if (NeedDestructor(decl)) {
if (NeedDestructor(decl, interp)) {
finalString << " static void delete_" << mappedname.c_str() << "(void *p);" << "\n" << " static void deleteArray_" << mappedname.c_str() << "(void *p);" << "\n" << " static void destruct_" << mappedname.c_str() << "(void *p);" << "\n";
}
if (HasDirectoryAutoAdd(decl, interp)) {
Expand Down Expand Up @@ -1864,10 +1866,10 @@ void ROOT::TMetaUtils::WriteClassInit(std::ostream& finalString,
finalString << "isa_proxy, " << rootflag << "," << "\n" << " sizeof(" << csymbol << ") );" << "\n";
if (HasIOConstructor(decl, args, ctorTypes, interp)) {
finalString << " instance.SetNew(&new_" << mappedname.c_str() << ");" << "\n";
if (args.size()==0 && NeedDestructor(decl))
if (args.size()==0 && NeedDestructor(decl, interp))
finalString << " instance.SetNewArray(&newArray_" << mappedname.c_str() << ");" << "\n";
}
if (NeedDestructor(decl)) {
if (NeedDestructor(decl, interp)) {
finalString << " instance.SetDelete(&delete_" << mappedname.c_str() << ");" << "\n" << " instance.SetDeleteArray(&deleteArray_" << mappedname.c_str() << ");" << "\n" << " instance.SetDestructor(&destruct_" << mappedname.c_str() << ");" << "\n";
}
if (HasDirectoryAutoAdd(decl, interp)) {
Expand Down Expand Up @@ -2334,7 +2336,7 @@ void ROOT::TMetaUtils::WriteAuxFunctions(std::ostream& finalString,
finalString << "new " << classname.c_str() << args << ";" << "\n";
finalString << " }" << "\n";

if (args.size()==0 && NeedDestructor(decl)) {
if (args.size()==0 && NeedDestructor(decl, interp)) {
// Can not can newArray if the destructor is not public.
finalString << " static void *newArray_";
finalString << mappedname.c_str();
Expand All @@ -2359,7 +2361,7 @@ void ROOT::TMetaUtils::WriteAuxFunctions(std::ostream& finalString,
}
}

if (NeedDestructor(decl)) {
if (NeedDestructor(decl, interp)) {
finalString << " // Wrapper around operator delete" << "\n" << " static void delete_" << mappedname.c_str() << "(void *p) {" << "\n" << " delete ((" << classname.c_str() << "*)p);" << "\n" << " }" << "\n" << " static void deleteArray_" << mappedname.c_str() << "(void *p) {" << "\n" << " delete [] ((" << classname.c_str() << "*)p);" << "\n" << " }" << "\n" << " static void destruct_" << mappedname.c_str() << "(void *p) {" << "\n" << " typedef " << classname.c_str() << " current_t;" << "\n" << " ((current_t*)p)->~current_t();" << "\n" << " }" << "\n";
}

Expand Down
28 changes: 15 additions & 13 deletions core/dictgen/src/rootcling_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2841,8 +2841,8 @@ int CheckClassesForInterpreterOnlyDicts(cling::Interpreter &interp,
////////////////////////////////////////////////////////////////////////////////
/// Make up for skipping RegisterModule, now that dictionary parsing
/// is done and these headers cannot be selected anymore.

int FinalizeStreamerInfoWriting(cling::Interpreter &interp, bool writeEmptyRootPCM=false)
///
int EmitROOTPCM(cling::Interpreter &interp, bool writeEmptyRootPCM=false)
{
if (!gDriverConfig->fCloseStreamerInfoROOTFile)
return 0;
Expand Down Expand Up @@ -2881,7 +2881,8 @@ int GenerateFullDict(std::ostream &dictStream,
const ROOT::TMetaUtils::RConstructorTypes &ctorTypes,
bool isSplit,
bool isGenreflex,
bool writeEmptyRootPCM)
bool writeEmptyRootPCM,
bool hasCxxModule)
{
ROOT::TMetaUtils::TNormalizedCtxt normCtxt(interp.getLookupHelper());

Expand Down Expand Up @@ -2993,12 +2994,12 @@ int GenerateFullDict(std::ostream &dictStream,
// coverity[fun_call_w_exception] - that's just fine.
ROOT::Internal::RStl::Instance().WriteClassInit(dictStream, interp, normCtxt, ctorTypes, needsCollectionProxy, EmitStreamerInfo);

if (!gDriverConfig->fBuildingROOTStage1) {
if (!hasCxxModule && !gDriverConfig->fBuildingROOTStage1) {
EmitTypedefs(scan.fSelectedTypedefs);
EmitEnums(scan.fSelectedEnums);
// Make up for skipping RegisterModule, now that dictionary parsing
// is done and these headers cannot be selected anymore.
int finRetCode = FinalizeStreamerInfoWriting(interp, writeEmptyRootPCM);
int finRetCode = EmitROOTPCM(interp, writeEmptyRootPCM);
if (finRetCode != 0) return finRetCode;
}

Expand Down Expand Up @@ -4858,17 +4859,18 @@ int RootClingMain(int argc,
rootclingRetCode += CheckClassesForInterpreterOnlyDicts(interp, scan);
// generate an empty pcm nevertheless for consistency
// Negate as true is 1 and true is returned in case of success.
if (!gDriverConfig->fBuildingROOTStage1) {
rootclingRetCode += FinalizeStreamerInfoWriting(interp);
if (!cxxmodule && !gDriverConfig->fBuildingROOTStage1) {
rootclingRetCode += EmitROOTPCM(interp);
}
} else {
rootclingRetCode += GenerateFullDict(splitDictStream,
interp,
scan,
constructorTypes,
doSplit,
isGenreflex,
writeEmptyRootPCM);
interp,
scan,
constructorTypes,
doSplit,
isGenreflex,
writeEmptyRootPCM,
cxxmodule);
}

if (rootclingRetCode != 0) {
Expand Down
2 changes: 1 addition & 1 deletion core/metacling/src/TCling.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1973,7 +1973,7 @@ void TCling::RegisterModule(const char* modulename,

if (gIgnoredPCMNames.find(modulename) == gIgnoredPCMNames.end()) {
TString pcmFileName(ROOT::TMetaUtils::GetModuleFileName(modulename).c_str());
if (!LoadPCM(pcmFileName, headers, triggerFunc)) {
if (!hasCxxModule && !LoadPCM(pcmFileName, headers, triggerFunc)) {
::Error("TCling::RegisterModule", "cannot find dictionary module %s",
ROOT::TMetaUtils::GetModuleFileName(modulename).c_str());
}
Expand Down