From 36a7534c223355544512423e0b5aaa966b07414c Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Fri, 22 Jul 2022 15:31:39 +0200 Subject: [PATCH 01/18] [TCling] Use string,vector instead of std. This prevents clashes e.g. of `std::data` ands `data` variables and alike. --- core/metacling/src/TCling.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index 707934b68ae5a..69bd3cf854576 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -1330,7 +1330,9 @@ static void RegisterPreIncludedHeaders(cling::Interpreter &clingInterp) #ifndef R__WIN32 PreIncludes += "#include \n"; #endif - PreIncludes += "using namespace std;\n"; + PreIncludes += "#include \n" + "#include \n" + "using std::string; using std::vector;\n"; clingInterp.declare(PreIncludes); } From 9670fe81718a163521bf2c8a4ccb199f09c555ed Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Tue, 9 May 2023 09:23:16 -0400 Subject: [PATCH 02/18] [test] Remove legacy using namespace std/stdext. --- test/TBench.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/TBench.h b/test/TBench.h index d7f232053532a..17288b1d0d908 100644 --- a/test/TBench.h +++ b/test/TBench.h @@ -9,7 +9,6 @@ namespace stdext {} #include #include -#ifndef WIN32 using std::vector; using std::list; using std::deque; @@ -17,10 +16,6 @@ using std::set; using std::multiset; using std::map; using std::multimap; -#else -using namespace std; -using namespace stdext; -#endif //------------------------------------------------------------- class THit { From 38a0341683775f389053ec5c9bcc154f68e36bd4 Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Tue, 9 May 2023 09:23:57 -0400 Subject: [PATCH 03/18] [proof] Remove unnecessary `using namespace std` in header. --- proof/xrdinc/XrdClient/XrdClientInputBuffer.hh | 2 -- 1 file changed, 2 deletions(-) diff --git a/proof/xrdinc/XrdClient/XrdClientInputBuffer.hh b/proof/xrdinc/XrdClient/XrdClientInputBuffer.hh index 971fe2eba2620..84c8316f53781 100644 --- a/proof/xrdinc/XrdClient/XrdClientInputBuffer.hh +++ b/proof/xrdinc/XrdClient/XrdClientInputBuffer.hh @@ -45,8 +45,6 @@ #include "XrdOuc/XrdOucHash.hh" #include "XrdClient/XrdClientVector.hh" -using namespace std; - class XrdClientInputBuffer { private: From 1395866275f46fb0d371b394d7d9acbbd3989d3e Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Tue, 9 May 2023 09:24:40 -0400 Subject: [PATCH 04/18] [foundation] Add doc to some TClassEdit functions (NFC). --- core/foundation/src/TClassEdit.cxx | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/core/foundation/src/TClassEdit.cxx b/core/foundation/src/TClassEdit.cxx index 2c648bdd6a4d2..e8919b59c6028 100644 --- a/core/foundation/src/TClassEdit.cxx +++ b/core/foundation/src/TClassEdit.cxx @@ -1744,14 +1744,13 @@ static void ResolveTypedefImpl(const char *tname, //////////////////////////////////////////////////////////////////////////////// +/// Return the name of type 'tname' with all its typedef components replaced +/// by the actual type its points to +/// For example for `typedef MyObj MyObjTypedef;` +/// `vector` return `vector` string TClassEdit::ResolveTypedef(const char *tname, bool /* resolveAll */) { - // Return the name of type 'tname' with all its typedef components replaced - // by the actual type its points to - // For example for "typedef MyObj MyObjTypedef;" - // vector return vector - // if (!tname || *tname == 0) return ""; @@ -1780,14 +1779,12 @@ string TClassEdit::ResolveTypedef(const char *tname, bool /* resolveAll */) //////////////////////////////////////////////////////////////////////////////// +/// Return the name of type 'tname' with all STL classes prepended by "std::". +/// For example for `vector > >` return +/// std::vector > >` string TClassEdit::InsertStd(const char *tname) { - // Return the name of type 'tname' with all STL classes prepended by "std::". - // For example for "vector > >" it returns - // "std::vector > >" - // - static const char* sSTLtypes[] = { "allocator", "auto_ptr", @@ -1963,7 +1960,7 @@ string TClassEdit::InsertStd(const char *tname) } //////////////////////////////////////////////////////////////////////////////// -/// An helper class to dismount the name and remount it changed whenever +/// A helper class to dismount the name and remount it changed whenever /// necessary class NameCleanerForIO { From 7c7a1d5fb2da9c76e9a71f816ad0da2e57298006 Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Tue, 9 May 2023 09:26:03 -0400 Subject: [PATCH 05/18] [dictgen] Make gOptNoGlobalUsingStd the default and only way. --- core/dictgen/src/rootcling_impl.cxx | 30 +---------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/core/dictgen/src/rootcling_impl.cxx b/core/dictgen/src/rootcling_impl.cxx index f56ce23b7ac0c..acaabe74acf8e 100644 --- a/core/dictgen/src/rootcling_impl.cxx +++ b/core/dictgen/src/rootcling_impl.cxx @@ -2827,8 +2827,6 @@ void CreateDictHeader(std::ostream &dictStream, const std::string &main_dictname void AddNamespaceSTDdeclaration(std::ostream &dictStream) { - dictStream << "// The generated code does not explicitly qualify STL entities\n" - << "namespace std {} using namespace std;\n\n"; } //////////////////////////////////////////////////////////////////////////////// @@ -4446,7 +4444,7 @@ int RootClingMain(int argc, if (interp.declare("#include \n" // For the list of 'opaque' typedef to also include string. "#include \n" // For initializing TNormalizedCtxt. - "namespace std {} using namespace std;") != cling::Interpreter::kSuccess) { + ) != cling::Interpreter::kSuccess) { ROOT::TMetaUtils::Error(nullptr, "Error loading the default header files.\n"); return 1; } @@ -4657,16 +4655,6 @@ int RootClingMain(int argc, CreateDictHeader(dictStream, main_dictname); if (gOptSplit) CreateDictHeader(*splitDictStream, main_dictname); - - if (!gOptNoGlobalUsingStd) { - // ACLiC'ed macros might rely on `using namespace std` in front of user headers - if (isACLiC) { - AddNamespaceSTDdeclaration(dictStream); - if (gOptSplit) { - AddNamespaceSTDdeclaration(*splitDictStream); - } - } - } } //--------------------------------------------------------------------------- @@ -4884,15 +4872,6 @@ int RootClingMain(int argc, GenerateNecessaryIncludes(*splitDictStream, includeForSource, extraIncludes); } } - if (!gOptNoGlobalUsingStd) { - // ACLiC'ed macros might have relied on `using namespace std` in front of user headers - if (!isACLiC) { - AddNamespaceSTDdeclaration(dictStream); - if (gOptSplit) { - AddNamespaceSTDdeclaration(*splitDictStream); - } - } - } if (gDriverConfig->fInitializeStreamerInfoROOTFile) { gDriverConfig->fInitializeStreamerInfoROOTFile(modGen.GetModuleFileName().c_str()); } @@ -4906,13 +4885,6 @@ int RootClingMain(int argc, constructorTypes.emplace_back("", interp); } } - if (!gOptIgnoreExistingDict && gOptNoGlobalUsingStd) { - AddNamespaceSTDdeclaration(dictStream); - - if (gOptSplit && splitDictStream) { - AddNamespaceSTDdeclaration(*splitDictStream); - } - } if (gOptGeneratePCH) { AnnotateAllDeclsForPCH(interp, scan); From 6a2a6a773fad9b847e54d71cbd84464af8c54476 Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Wed, 10 May 2023 16:01:52 -0400 Subject: [PATCH 06/18] [dictgen] Remove unused var; add using decls for std types. --- core/dictgen/src/rootcling_impl.cxx | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/core/dictgen/src/rootcling_impl.cxx b/core/dictgen/src/rootcling_impl.cxx index acaabe74acf8e..87ffd3875cc6e 100644 --- a/core/dictgen/src/rootcling_impl.cxx +++ b/core/dictgen/src/rootcling_impl.cxx @@ -4434,8 +4434,24 @@ int RootClingMain(int argc, // ROOTCINT uses to define a few header implicitly, we need to do it explicitly. if (interp.declare("#include \n" "#include \"Rtypes.h\"\n" - "#include \"TObject.h\"") != cling::Interpreter::kSuccess - ) { + "#include \"TObject.h\"\n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "using std::allocator; using std::bitset; using std::default_delete; using " + "std::forward_list; using std::list; using std::map; using std::multimap; using " + "std::multiset; using std::pair; using std::set; using std::shared_ptr; using std::string; " + "using std::unique_ptr; using std::unordered_multimap; using std::unordered_map; using " + "std::unordered_multiset; using std::unordered_set; using std::vector;") != + cling::Interpreter::kSuccess) { // There was an error. ROOT::TMetaUtils::Error(nullptr, "Error loading the default rootcling header files.\n"); return 1; @@ -4633,8 +4649,6 @@ int RootClingMain(int argc, } std::ostream &dictStream = (!gOptIgnoreExistingDict && !gOptDictionaryFileName.empty()) ? fileout : std::cout; - bool isACLiC = gOptDictionaryFileName.getValue().find("_ACLiC_dict") != std::string::npos; - if (!gOptIgnoreExistingDict) { // Now generate a second stream for the split dictionary if it is necessary if (gOptSplit) { From d9edba9e35c961e9362def2655c2991d9465540a Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Wed, 10 May 2023 16:03:09 -0400 Subject: [PATCH 07/18] [core] In generated dict code, always prefix std classes with "std": This is backward compatible and avoids having to inject a "using namespace std". --- core/clingutils/src/TClingUtils.cxx | 26 +++++----- core/dictgen/src/rootcling_impl.cxx | 48 ++++++++++++------- core/foundation/src/RConversionRuleParser.cxx | 15 +++--- 3 files changed, 51 insertions(+), 38 deletions(-) diff --git a/core/clingutils/src/TClingUtils.cxx b/core/clingutils/src/TClingUtils.cxx index 983a02072dab6..69319d38af45d 100644 --- a/core/clingutils/src/TClingUtils.cxx +++ b/core/clingutils/src/TClingUtils.cxx @@ -1715,13 +1715,11 @@ void ROOT::TMetaUtils::WriteClassInit(std::ostream& finalString, std::string csymbol = classname; std::string args; - if ( ! TClassEdit::IsStdClass( classname.c_str() ) ) { + csymbol = TClassEdit::InsertStd(csymbol.c_str()); - // Prefix the full class name with '::' except for the STL - // containers and std::string. This is to request the - // real class instead of the class in the namespace ROOT::Shadow - csymbol.insert(0,"::"); - } + // Prefix the full class name with '::', to refert to the + // real class instead of the class in the namespace ROOT::Shadow + csymbol.insert(0,"::"); int stl = TClassEdit::IsSTLCont(classname); bool bset = TClassEdit::IsSTLBitset(classname.c_str()); @@ -1988,7 +1986,8 @@ void ROOT::TMetaUtils::WriteClassInit(std::ostream& finalString, // FIXME Workaround: for the moment we do not generate coll proxies with unique ptrs since // they imply copies and therefore do not compile. auto classNameForIO = TClassEdit::GetNameForIO(classname); - finalString << " instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::" << methodTCP << "< " << classNameForIO.c_str() << " >()));" << "\n"; + classNameForIO = TClassEdit::InsertStd(classNameForIO.c_str()); + finalString << " instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::" << methodTCP << "< " << classNameForIO << " >()));" << "\n"; needCollectionProxy = true; } @@ -2378,15 +2377,12 @@ void ROOT::TMetaUtils::WriteAuxFunctions(std::ostream& finalString, // operator delete // operator delete[] - ROOT::TMetaUtils::GetCppName(mappedname,classname.c_str()); - - if ( ! TClassEdit::IsStdClass( classname.c_str() ) ) { + classname = TClassEdit::InsertStd(classname.c_str()); - // Prefix the full class name with '::' except for the STL - // containers and std::string. This is to request the - // real class instead of the class in the namespace ROOT::Shadow - classname.insert(0,"::"); - } + // Prefix the full class name with '::' except for the STL + // containers and std::string. This is to request the + // real class instead of the class in the namespace ROOT::Shadow + classname.insert(0,"::"); finalString << "namespace ROOT {" << "\n"; diff --git a/core/dictgen/src/rootcling_impl.cxx b/core/dictgen/src/rootcling_impl.cxx index 87ffd3875cc6e..a5494717d4356 100644 --- a/core/dictgen/src/rootcling_impl.cxx +++ b/core/dictgen/src/rootcling_impl.cxx @@ -859,6 +859,7 @@ int STLContainerStreamer(const clang::FieldDecl &m, if (!tmplt_specialization) return 0; string stlType(ROOT::TMetaUtils::ShortTypeName(mTypename.c_str())); + stlType = TClassEdit::InsertStd(stlType.c_str()); string stlName; stlName = ROOT::TMetaUtils::ShortTypeName(m.getName().str().c_str()); @@ -1171,6 +1172,8 @@ void WriteClassFunctions(const clang::CXXRecordDecl *cl, std::ostream &dictStrea enclSpaceNesting = ROOT::TMetaUtils::WriteNamespaceHeader(dictStream, cl); } + clsname = TClassEdit::InsertStd(clsname.c_str()); + if (autoLoad) dictStream << "#include \"TInterpreter.h\"\n"; @@ -1189,16 +1192,22 @@ void WriteClassFunctions(const clang::CXXRecordDecl *cl, std::ostream &dictStrea dictStream << "//_______________________________________" << "_______________________________________" << std::endl; if (add_template_keyword) dictStream << "template <> "; - dictStream << "const char *" << clsname << "::ImplFileName()" << std::endl << "{" << std::endl - << " return ::ROOT::GenerateInitInstanceLocal((const ::" << fullname - << "*)nullptr)->GetImplFileName();" << std::endl << "}" << std::endl << std::endl + dictStream << "const char *" << clsname << "::ImplFileName()" << std::endl + << "{" << std::endl + << " return ::ROOT::GenerateInitInstanceLocal((const ::" << clsname << "*)nullptr)->GetImplFileName();" + << std::endl + << "}" << std::endl + << std::endl << "//_______________________________________" << "_______________________________________" << std::endl; if (add_template_keyword) dictStream << "template <> "; - dictStream << "int " << clsname << "::ImplFileLine()" << std::endl << "{" << std::endl - << " return ::ROOT::GenerateInitInstanceLocal((const ::" << fullname - << "*)nullptr)->GetImplFileLine();" << std::endl << "}" << std::endl << std::endl + dictStream << "int " << clsname << "::ImplFileLine()" << std::endl + << "{" << std::endl + << " return ::ROOT::GenerateInitInstanceLocal((const ::" << clsname << "*)nullptr)->GetImplFileLine();" + << std::endl + << "}" << std::endl + << std::endl << "//_______________________________________" << "_______________________________________" << std::endl; @@ -1208,20 +1217,21 @@ void WriteClassFunctions(const clang::CXXRecordDecl *cl, std::ostream &dictStrea // Trigger autoloading if dictionary is split if (autoLoad) dictStream << " gInterpreter->AutoLoad(\"" << fullname << "\");\n"; - dictStream << " fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::" << fullname - << "*)nullptr)->GetClass();" << std::endl - << " return fgIsA;\n" - << "}" << std::endl << std::endl + dictStream << " fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::" << clsname << "*)nullptr)->GetClass();" + << std::endl + << " return fgIsA;\n" + << "}" << std::endl + << std::endl - << "//_______________________________________" - << "_______________________________________" << std::endl; + << "//_______________________________________" + << "_______________________________________" << std::endl; if (add_template_keyword) dictStream << "template <> "; dictStream << "TClass *" << clsname << "::Class()" << std::endl << "{" << std::endl; if (autoLoad) { dictStream << " Dictionary();\n"; } else { dictStream << " if (!fgIsA.load()) { R__LOCKGUARD(gInterpreterMutex); fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::"; - dictStream << fullname << "*)nullptr)->GetClass(); }" << std::endl; + dictStream << clsname << "*)nullptr)->GetClass(); }" << std::endl; } dictStream << " return fgIsA;" << std::endl << "}" << std::endl << std::endl; @@ -1386,6 +1396,7 @@ void WriteStreamer(const ROOT::TMetaUtils::AnnotatedRecordDecl &cl, if (ROOT::TMetaUtils::GetNameWithinNamespace(fullname, clsname, nsname, clxx)) { enclSpaceNesting = ROOT::TMetaUtils::WriteNamespaceHeader(dictStream, cl); } + clsname = TClassEdit::InsertStd(clsname.c_str()); dictStream << "//_______________________________________" << "_______________________________________" << std::endl; @@ -1788,19 +1799,22 @@ void WriteAutoStreamer(const ROOT::TMetaUtils::AnnotatedRecordDecl &cl, if (ROOT::TMetaUtils::GetNameWithinNamespace(fullname, clsname, nsname, clxx)) { enclSpaceNesting = ROOT::TMetaUtils::WriteNamespaceHeader(dictStream, cl); } + clsname = TClassEdit::InsertStd(clsname.c_str()); dictStream << "//_______________________________________" << "_______________________________________" << std::endl; if (add_template_keyword) dictStream << "template <> "; dictStream << "void " << clsname << "::Streamer(TBuffer &R__b)" << std::endl << "{" << std::endl - << " // Stream an object of class " << fullname << "." << std::endl << std::endl + << " // Stream an object of class " << fullname << "." << std::endl + << std::endl << " if (R__b.IsReading()) {" << std::endl - << " R__b.ReadClassBuffer(" << fullname << "::Class(),this);" << std::endl + << " R__b.ReadClassBuffer(" << clsname << "::Class(),this);" << std::endl << " } else {" << std::endl - << " R__b.WriteClassBuffer(" << fullname << "::Class(),this);" << std::endl + << " R__b.WriteClassBuffer(" << clsname << "::Class(),this);" << std::endl << " }" << std::endl - << "}" << std::endl << std::endl; + << "}" << std::endl + << std::endl; while (enclSpaceNesting) { dictStream << "} // namespace " << nsname << std::endl; diff --git a/core/foundation/src/RConversionRuleParser.cxx b/core/foundation/src/RConversionRuleParser.cxx index 59fead341afd2..c0121006e56ff 100644 --- a/core/foundation/src/RConversionRuleParser.cxx +++ b/core/foundation/src/RConversionRuleParser.cxx @@ -475,10 +475,11 @@ namespace ROOT static void WriteAutoVariables( const std::list& target, const SourceTypeList_t& source, - MembersTypeMap_t& members, - std::string& className, std::string& mappedName, + const MembersTypeMap_t& members, + std::string className, const std::string& mappedName, std::ostream& output ) { + className = TClassEdit::InsertStd(className.c_str()); if (!source.empty()) { Bool_t start = true; SourceTypeList_t::const_iterator it; @@ -616,18 +617,20 @@ namespace ROOT std::list::const_iterator it; for( it = target.begin(); it != target.end(); ++it ) { - Internal::TSchemaType memData = members[*it]; + const Internal::TSchemaType &memData = members.find(*it)->second; output << " static Long_t offset_" << *it << " = "; output << "cls->GetDataMemberOffset(\"" << *it << "\");"; output << std::endl; + std::string memDataType = TClassEdit::InsertStd(memData.fType.c_str()); if (memData.fDimensions.size()) { - output << " typedef " << memData.fType << " " << *it << "_t" << memData.fDimensions << ";" << std::endl; + output << " typedef " << memDataType << " " << *it << "_t" << memData.fDimensions << ";" + << std::endl; output << " " << *it << "_t& " << *it << " = "; output << "*(" << *it << "_t *)(target+offset_" << *it; output << ");" << std::endl; } else { - output << " " << memData.fType << "& " << *it << " = "; - output << "*(" << memData.fType << "*)(target+offset_" << *it; + output << " " << memDataType << "& " << *it << " = "; + output << "*(" << memDataType << "*)(target+offset_" << *it; output << ");" << std::endl; } } From 859bfeb6ddb9ae21650eeb5044abfdfb623a224e Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Wed, 10 May 2023 17:02:19 -0400 Subject: [PATCH 08/18] [mathcore] Do not generate a dict for vector iters: Commit 8d706441be44ee21792aeaffb6c00c07545c067c claims that such a type might be a target of an I/O rule - but then that dictionary should be generated there, and it is not obvious whether the dictionary is actually needed for I/O rule targets. --- math/mathcore/inc/LinkDef2.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/math/mathcore/inc/LinkDef2.h b/math/mathcore/inc/LinkDef2.h index 4ac1d929c146b..7882bfd16b524 100644 --- a/math/mathcore/inc/LinkDef2.h +++ b/math/mathcore/inc/LinkDef2.h @@ -22,10 +22,6 @@ //#pragma link C++ class ROOT::Math; #endif -#pragma link C++ class std::vector::iterator; -#pragma link C++ class std::vector::const_iterator; -#pragma link C++ class std::vector::reverse_iterator; - #pragma link C++ global gRandom; #pragma link C++ class TRandom+; From f1065cb435b952ec925190a0fde6e966d0e8ecb7 Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Wed, 10 May 2023 23:06:34 -0400 Subject: [PATCH 09/18] [foundation] TClassEdit::InsertStd: add PRNG types to std type list. --- core/foundation/src/TClassEdit.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/foundation/src/TClassEdit.cxx b/core/foundation/src/TClassEdit.cxx index e8919b59c6028..1ee901832726e 100644 --- a/core/foundation/src/TClassEdit.cxx +++ b/core/foundation/src/TClassEdit.cxx @@ -1785,7 +1785,7 @@ string TClassEdit::ResolveTypedef(const char *tname, bool /* resolveAll */) string TClassEdit::InsertStd(const char *tname) { - static const char* sSTLtypes[] = { + static const char *sSTLtypes[] = { "allocator", "auto_ptr", "bad_alloc", @@ -1819,6 +1819,7 @@ string TClassEdit::InsertStd(const char *tname) "ctype_byname", "ctype", "deque", + "discard_block_engine", "divides", "domain_error", "equal_to", @@ -1853,6 +1854,7 @@ string TClassEdit::InsertStd(const char *tname) "mask_array", "mem_fun", "mem_fun_ref", + "mersenne_twister_engine", "messages", "messages_byname", "minus", @@ -1893,6 +1895,7 @@ string TClassEdit::InsertStd(const char *tname) "string", "strstream", "strstreambuf", + "subtract_with_carry_engine", "time_get_byname", "time_get", "time_put_byname", From c6ec9009e58996d0fdc58cbf6896117f9fdff7da Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Thu, 11 May 2023 08:11:51 -0400 Subject: [PATCH 10/18] Do not generate dicts for iterators: We do not want to do I/O on those, and we cannot identify their base classes etc as stdlib classes, causing a missing "std::" in dictionaries. --- core/base/inc/LinkDef2.h | 8 -------- core/cont/inc/LinkDef.h | 3 --- core/dictgen/src/rootcling_impl.cxx | 16 ++++++++++------ graf3d/eve/inc/LinkDef1.h | 7 ------- graf3d/eve/src/TEveChunkManager.cxx | 1 - graf3d/eve7/inc/LinkDef.h | 1 - roofit/roofit/inc/LinkDef1.h | 1 - 7 files changed, 10 insertions(+), 27 deletions(-) diff --git a/core/base/inc/LinkDef2.h b/core/base/inc/LinkDef2.h index bdaa1013c5f46..1626f6271c82a 100644 --- a/core/base/inc/LinkDef2.h +++ b/core/base/inc/LinkDef2.h @@ -12,8 +12,6 @@ #ifdef __CLING__ #include -#pragma link C++ class string::iterator; -#pragma link C++ class string::const_iterator; #else #include "dll_stl/str.h" #endif @@ -24,15 +22,9 @@ #pragma create TClass string; #pragma link C++ class std::vector; #pragma link C++ operator std::vector; -#pragma link C++ class std::vector::iterator; -#pragma link C++ class std::vector::const_iterator; -#pragma link C++ class std::vector::reverse_iterator; #pragma link C++ class std::vector; #pragma link C++ operators std::vector; -#pragma link C++ class std::vector::iterator; -#pragma link C++ class std::vector::const_iterator; -#pragma link C++ class std::vector::reverse_iterator; #include diff --git a/core/cont/inc/LinkDef.h b/core/cont/inc/LinkDef.h index 5df7bfd611661..b6e86f1cce1cb 100644 --- a/core/cont/inc/LinkDef.h +++ b/core/cont/inc/LinkDef.h @@ -56,9 +56,6 @@ #pragma link C++ class TVirtualCollectionProxy-; #pragma link C++ class std::vector; -#pragma link C++ class std::vector::iterator; -#pragma link C++ class std::vector::const_iterator; -#pragma link C++ class std::vector::reverse_iterator; #pragma link C++ nestedclass; #pragma link C++ nestedtypedef; diff --git a/core/dictgen/src/rootcling_impl.cxx b/core/dictgen/src/rootcling_impl.cxx index a5494717d4356..7e9d9bcae6459 100644 --- a/core/dictgen/src/rootcling_impl.cxx +++ b/core/dictgen/src/rootcling_impl.cxx @@ -1172,6 +1172,7 @@ void WriteClassFunctions(const clang::CXXRecordDecl *cl, std::ostream &dictStrea enclSpaceNesting = ROOT::TMetaUtils::WriteNamespaceHeader(dictStream, cl); } + fullname = TClassEdit::InsertStd(fullname.c_str()); clsname = TClassEdit::InsertStd(clsname.c_str()); if (autoLoad) @@ -1186,15 +1187,18 @@ void WriteClassFunctions(const clang::CXXRecordDecl *cl, std::ostream &dictStrea << "//_______________________________________" << "_______________________________________" << std::endl; if (add_template_keyword) dictStream << "template <> "; - dictStream << "const char *" << clsname << "::Class_Name()" << std::endl << "{" << std::endl - << " return \"" << fullname << "\";" << std::endl << "}" << std::endl << std::endl; + dictStream << "const char *" << clsname << "::Class_Name()" << std::endl + << "{" << std::endl + << " return \"" << fullname << "\";" << std::endl + << "}" << std::endl + << std::endl; dictStream << "//_______________________________________" << "_______________________________________" << std::endl; if (add_template_keyword) dictStream << "template <> "; dictStream << "const char *" << clsname << "::ImplFileName()" << std::endl << "{" << std::endl - << " return ::ROOT::GenerateInitInstanceLocal((const ::" << clsname << "*)nullptr)->GetImplFileName();" + << " return ::ROOT::GenerateInitInstanceLocal((const ::" << fullname << "*)nullptr)->GetImplFileName();" << std::endl << "}" << std::endl << std::endl @@ -1204,7 +1208,7 @@ void WriteClassFunctions(const clang::CXXRecordDecl *cl, std::ostream &dictStrea if (add_template_keyword) dictStream << "template <> "; dictStream << "int " << clsname << "::ImplFileLine()" << std::endl << "{" << std::endl - << " return ::ROOT::GenerateInitInstanceLocal((const ::" << clsname << "*)nullptr)->GetImplFileLine();" + << " return ::ROOT::GenerateInitInstanceLocal((const ::" << fullname << "*)nullptr)->GetImplFileLine();" << std::endl << "}" << std::endl << std::endl @@ -1217,7 +1221,7 @@ void WriteClassFunctions(const clang::CXXRecordDecl *cl, std::ostream &dictStrea // Trigger autoloading if dictionary is split if (autoLoad) dictStream << " gInterpreter->AutoLoad(\"" << fullname << "\");\n"; - dictStream << " fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::" << clsname << "*)nullptr)->GetClass();" + dictStream << " fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::" << fullname << "*)nullptr)->GetClass();" << std::endl << " return fgIsA;\n" << "}" << std::endl @@ -1231,7 +1235,7 @@ void WriteClassFunctions(const clang::CXXRecordDecl *cl, std::ostream &dictStrea dictStream << " Dictionary();\n"; } else { dictStream << " if (!fgIsA.load()) { R__LOCKGUARD(gInterpreterMutex); fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::"; - dictStream << clsname << "*)nullptr)->GetClass(); }" << std::endl; + dictStream << fullname << "*)nullptr)->GetClass(); }" << std::endl; } dictStream << " return fgIsA;" << std::endl << "}" << std::endl << std::endl; diff --git a/graf3d/eve/inc/LinkDef1.h b/graf3d/eve/inc/LinkDef1.h index ad6d66b622afc..d0057516c1501 100644 --- a/graf3d/eve/inc/LinkDef1.h +++ b/graf3d/eve/inc/LinkDef1.h @@ -105,7 +105,6 @@ // TEveChunkManager #pragma link C++ class TEveChunkManager+; -#pragma link C++ class TEveChunkManager::iterator-; // TEveEventManager #pragma link C++ class TEveEventManager+; @@ -123,15 +122,11 @@ #pragma link C++ class TEveElementEditor+; #pragma link C++ class std::list; -#pragma link C++ class std::list::iterator; -#pragma link C++ class std::list::const_iterator; #pragma link C++ typedef TEveElement::List_t; #pragma link C++ typedef TEveElement::List_i; #pragma link C++ typedef TEveElement::List_ci; #pragma link C++ class std::set; -#pragma link C++ class std::set::iterator; -#pragma link C++ class std::set::const_iterator; #pragma link C++ typedef TEveElement::Set_t; #pragma link C++ typedef TEveElement::Set_i; #pragma link C++ typedef TEveElement::Set_ci; @@ -192,8 +187,6 @@ #pragma link C++ class TEveProjection+; #pragma link C++ class TEveProjection::PreScaleEntry_t+; #pragma link C++ class std::vector; -#pragma link C++ class std::vector::iterator; -#pragma link C++ operators std::vector::iterator; #pragma link C++ typedef TEveProjection::vPreScale_t; #pragma link C++ typedef TEveProjection::vPreScale_i; #pragma link C++ class TEveRhoZProjection+; diff --git a/graf3d/eve/src/TEveChunkManager.cxx b/graf3d/eve/src/TEveChunkManager.cxx index 08304c3ba2131..86a37e81afd33 100644 --- a/graf3d/eve/src/TEveChunkManager.cxx +++ b/graf3d/eve/src/TEveChunkManager.cxx @@ -22,7 +22,6 @@ The structure can be Refit() to occupy a single contiguous array. */ ClassImp(TEveChunkManager); -ClassImp(TEveChunkManager::iterator); //////////////////////////////////////////////////////////////////////////////// /// Release all memory chunks. diff --git a/graf3d/eve7/inc/LinkDef.h b/graf3d/eve7/inc/LinkDef.h index c0945f778ad39..e2523e4486860 100644 --- a/graf3d/eve7/inc/LinkDef.h +++ b/graf3d/eve7/inc/LinkDef.h @@ -242,7 +242,6 @@ // REveChunkManager #pragma link C++ class ROOT::Experimental::REveChunkManager+; -#pragma link C++ class ROOT::Experimental::REveChunkManager::iterator; // Tables #pragma link C++ class ROOT::Experimental::REveTableViewInfo; diff --git a/roofit/roofit/inc/LinkDef1.h b/roofit/roofit/inc/LinkDef1.h index 67ea67810b8f1..88499e0942040 100644 --- a/roofit/roofit/inc/LinkDef1.h +++ b/roofit/roofit/inc/LinkDef1.h @@ -55,7 +55,6 @@ #pragma link C++ class RooStepFunction+ ; #pragma link C++ class RooMultiBinomial+ ; /* #pragma link C++ class std::vector< TVector2 >; */ -/* #pragma link C++ class std::vector< TVector2 >::iterator ; */ /* #pragma link C++ class RooPolyMorph2D+ ; */ // #pragma link C++ class RooUniform+ ; From 542e382e48606a3e5ba110b4a9c02ee65438244a Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Thu, 11 May 2023 15:32:50 -0400 Subject: [PATCH 11/18] [foundation] Fix spelling of std types; add missing ones, rm auto_ptr. --- core/foundation/src/TClassEdit.cxx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/foundation/src/TClassEdit.cxx b/core/foundation/src/TClassEdit.cxx index 1ee901832726e..73ba8090dc4e7 100644 --- a/core/foundation/src/TClassEdit.cxx +++ b/core/foundation/src/TClassEdit.cxx @@ -1787,7 +1787,7 @@ string TClassEdit::InsertStd(const char *tname) { static const char *sSTLtypes[] = { "allocator", - "auto_ptr", + "any", "bad_alloc", "bad_cast", "bad_exception", @@ -1818,6 +1818,7 @@ string TClassEdit::InsertStd(const char *tname) "complex", "ctype_byname", "ctype", + "default_delete", "deque", "discard_block_engine", "divides", @@ -1889,6 +1890,7 @@ string TClassEdit::InsertStd(const char *tname) "reverse_iterator", "runtime_error", "set", + "shared_ptr", "slice_array", "slice", "stack", @@ -1896,13 +1898,15 @@ string TClassEdit::InsertStd(const char *tname) "strstream", "strstreambuf", "subtract_with_carry_engine", + "thread", "time_get_byname", "time_get", "time_put_byname", "time_put", + "tuple", "unary_function", "unary_negate", - "unique_pointer", + "unique_ptr", "underflow_error", "unordered_map", "unordered_multimap", @@ -1910,6 +1914,7 @@ string TClassEdit::InsertStd(const char *tname) "unordered_set", "valarray", "vector", + "weak_ptr", "wstring" }; From cdc2a3147c8c41085ef04e27e8d90d9aaacd1560 Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Mon, 15 May 2023 13:04:12 +0200 Subject: [PATCH 12/18] [io] Diagnose missing stdlib I/O support: An example is `std::pair`: ROOT should not be asked to serialize `std::thread::id` without explicit support (which currently does not exist). This catches missing std:: using decls and makes the error message more helpful than "this type is not known". --- io/rootpcm/src/rootclingIO.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/io/rootpcm/src/rootclingIO.cxx b/io/rootpcm/src/rootclingIO.cxx index 9e470646f4089..58c6855139763 100644 --- a/io/rootpcm/src/rootclingIO.cxx +++ b/io/rootpcm/src/rootclingIO.cxx @@ -16,6 +16,7 @@ #include "TEnum.h" #include "TError.h" #include "TFile.h" +#include "TInterpreter.h" #include "TProtoClass.h" #include "TDataMember.h" #include "TROOT.h" @@ -151,7 +152,14 @@ bool CloseStreamerInfoROOTFile(bool writeEmptyRootPCM) for (const auto & normName : gClassesToStore) { TClass *cl = TClass::GetClass(normName.c_str(), kTRUE /*load*/); if (!cl) { - Error("CloseStreamerInfoROOTFile", "Cannot find class %s.", normName.c_str()); + static int uniqueIndex = 0; + const std::string checkStdNames_Code = "void RootCling_CheckStdNames_" + std::to_string(++uniqueIndex) + + "() { using namespace std; using type = " + normName.c_str() + ";}"; + if (gInterpreter->Declare(checkStdNames_Code.c_str())) + Error("CloseStreamerInfoROOTFile", + "ROOT I/O on class %s is unsupported due to missing stdlib type support.", normName.c_str()); + else + Error("CloseStreamerInfoROOTFile", "Cannot find class %s.", normName.c_str()); return false; } From 4503bd065b69663b2de18e5e6ebd44b878bf6f9b Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Mon, 15 May 2023 13:05:09 +0200 Subject: [PATCH 13/18] [geo] Do not generate dictionaries for thread::id: ROOT cannot serialize these anyway, and nothing else needs a dictionary. --- geom/geom/inc/LinkDef1.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/geom/geom/inc/LinkDef1.h b/geom/geom/inc/LinkDef1.h index fd6918f9176e9..642b443b10ed6 100644 --- a/geom/geom/inc/LinkDef1.h +++ b/geom/geom/inc/LinkDef1.h @@ -100,9 +100,4 @@ #pragma link C++ class TGeoNavigator+; #pragma link C++ class TGeoNavigatorArray; #pragma link C++ class TGDMLMatrix+; -#pragma link C++ struct std::map; -#pragma link C++ struct std::pair; -#pragma link C++ struct std::map; -#pragma link C++ struct std::pair; - #endif From 52e9f326ebb3e1349ee0cc4dba88da560dd35034 Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Mon, 15 May 2023 13:47:41 +0200 Subject: [PATCH 14/18] [fumili] no dict for TFumiliMinimizer: not persistent and not a TObject.. --- math/fumili/inc/LinkDef.h | 2 -- math/fumili/inc/TFumiliMinimizer.h | 3 --- math/fumili/src/TFumiliMinimizer.cxx | 4 ---- 3 files changed, 9 deletions(-) diff --git a/math/fumili/inc/LinkDef.h b/math/fumili/inc/LinkDef.h index 31378af3fbd08..ed733bc422439 100644 --- a/math/fumili/inc/LinkDef.h +++ b/math/fumili/inc/LinkDef.h @@ -17,6 +17,4 @@ #pragma link C++ global gFumili; #pragma link C++ class TFumili; -#pragma link C++ class TFumiliMinimizer; - #endif diff --git a/math/fumili/inc/TFumiliMinimizer.h b/math/fumili/inc/TFumiliMinimizer.h index 20640c4e24f90..b48dc72c991a5 100644 --- a/math/fumili/inc/TFumiliMinimizer.h +++ b/math/fumili/inc/TFumiliMinimizer.h @@ -173,9 +173,6 @@ class TFumiliMinimizer : public ROOT::Math::Minimizer { static ROOT::Math::FitMethodGradFunction * fgGradFunc; static TFumili * fgFumili; // static instance (used by fcn function) - - ClassDef(TFumiliMinimizer,1) //Implementation of Minimizer interface using TFumili - }; diff --git a/math/fumili/src/TFumiliMinimizer.cxx b/math/fumili/src/TFumiliMinimizer.cxx index 087cdffbf09c5..8cd114499e27c 100644 --- a/math/fumili/src/TFumiliMinimizer.cxx +++ b/math/fumili/src/TFumiliMinimizer.cxx @@ -130,10 +130,6 @@ ROOT::Math::FitMethodFunction * TFumiliMinimizer::fgFunc = 0; ROOT::Math::FitMethodGradFunction * TFumiliMinimizer::fgGradFunc = 0; TFumili * TFumiliMinimizer::fgFumili = 0; - -ClassImp(TFumiliMinimizer); - - TFumiliMinimizer::TFumiliMinimizer(int ) : fDim(0), fNFree(0), From 430660e2abcf800fc6b08d40e108daa680cc2f89 Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Mon, 15 May 2023 20:09:21 +0200 Subject: [PATCH 15/18] [clingutils] Fwd decls must use "std::" where needed: Fixes ``` Forward declarations from lib/libcomplexDict.rootmap:2:19: error: explicit specialization of undeclared template class 'complex' template <> class complex; ^ ~~~~~~~ ``` --- core/clingutils/src/TClingUtils.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/clingutils/src/TClingUtils.cxx b/core/clingutils/src/TClingUtils.cxx index 69319d38af45d..bd05506944de5 100644 --- a/core/clingutils/src/TClingUtils.cxx +++ b/core/clingutils/src/TClingUtils.cxx @@ -5365,7 +5365,8 @@ int ROOT::TMetaUtils::AST2SourceTools::FwdDeclIfTmplSpec(const clang::RecordDecl } defString += argFwdDecl + '\n'; } - defString += "template <> class " + normalizedName + ';'; + std::string normalizedNameWithStd = TClassEdit::InsertStd(normalizedName.c_str()); + defString += "template <> class " + normalizedNameWithStd + ';'; return 0; } } From a3161419259078835ade1531879a11208056ee42 Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Tue, 16 May 2023 12:43:15 +0200 Subject: [PATCH 16/18] [dictgen] Inject using decls for common stdlib names in ACLiC dicts: User code might rely on `vector` being available without `std::` qualification because of CINT/cling/ROOT exposing a using namespace std since decades. Work around that by injecting some of the main types through using decls for ACliC. --- core/dictgen/src/rootcling_impl.cxx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/core/dictgen/src/rootcling_impl.cxx b/core/dictgen/src/rootcling_impl.cxx index 7e9d9bcae6459..261333ee173f5 100644 --- a/core/dictgen/src/rootcling_impl.cxx +++ b/core/dictgen/src/rootcling_impl.cxx @@ -2839,6 +2839,24 @@ void CreateDictHeader(std::ostream &dictStream, const std::string &main_dictname << "#include \"TCollectionProxyInfo.h\"\n" << "/*******************************************************************/\n\n" << "#include \"TDataMember.h\"\n\n"; // To set their transiency + + if (main_dictname.length() > 11 && main_dictname.substr(main_dictname.length() - 11) == "_ACLiC_dict") + dictStream << "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "using std::allocator; using std::bitset; using std::default_delete; using " + "std::forward_list; using std::list; using std::map; using std::multimap; using " + "std::multiset; using std::pair; using std::set; using std::shared_ptr; using std::string; " + "using std::unique_ptr; using std::unordered_multimap; using std::unordered_map; using " + "std::unordered_multiset; using std::unordered_set; using std::vector;\n"; } //////////////////////////////////////////////////////////////////////////////// From 32f08faf28c213c95ca66204bdaf1cff2a9fc659 Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Tue, 16 May 2023 20:44:12 +0200 Subject: [PATCH 17/18] [core] Do not InspectMembers() for stdlib types: This prevents TClass getting confused about normalized names in std:: which will likely be implementation details --- core/meta/inc/TDictionary.h | 3 +++ core/metacling/src/TCling.cxx | 13 ++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/core/meta/inc/TDictionary.h b/core/meta/inc/TDictionary.h index 04546c4ac37d4..e77f8e02ffd76 100644 --- a/core/meta/inc/TDictionary.h +++ b/core/meta/inc/TDictionary.h @@ -193,6 +193,9 @@ class TDictionary : public TNamed { static TDictionary* GetDictionary(const char* name); static TDictionary* GetDictionary(const std::type_info &typeinfo); + /// Return `true` if the TClass representd a name in the `std::` namespace. + Bool_t IsInStdLib() const { return Property() & kIsDefinedInStd; } + // Type of STL container (returned by IsSTLContainer). enum ESTLType { kNone = ROOT::kNotSTL, diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index 69bd3cf854576..cd267a322452a 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -2661,16 +2661,11 @@ void TCling::InspectMembers(TMemberInspector& insp, const void* obj, return; } - static const TClassRef clRefString("std::string"); - if (clRefString == cl) { - // We stream std::string without going through members.. + if (cl->IsInStdLib() && strncmp(cl->GetName(), "unique_ptr<", 11) != 0) + // We stream std::string and friends without going through members. + // `CloseStreamerInfoROOTFile()` needs to know the internal structure + // of std::unique_ptr. return; - } - - if (TClassEdit::IsStdArray(cl->GetName())) { - // We treat std arrays as C arrays - return; - } const char* cobj = (const char*) obj; // for ptr arithmetics From 353faaa61a66e8141dce44aa47859e4796beb6ac Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Wed, 17 May 2023 09:06:35 +0200 Subject: [PATCH 18/18] [core] Centralize using decls injected into cling, add more. --- core/clingutils/res/TClingUtils.h | 3 ++ core/clingutils/src/TClingUtils.cxx | 43 +++++++++++++++++++++++++++++ core/dictgen/src/rootcling_impl.cxx | 19 ++----------- core/metacling/src/TCling.cxx | 5 ++-- 4 files changed, 50 insertions(+), 20 deletions(-) diff --git a/core/clingutils/res/TClingUtils.h b/core/clingutils/res/TClingUtils.h index 7968ba98fec83..0a32b6ce9bd98 100644 --- a/core/clingutils/res/TClingUtils.h +++ b/core/clingutils/res/TClingUtils.h @@ -740,6 +740,9 @@ void SetPathsForRelocatability(std::vector& clingArgs); //______________________________________________________________________________ void ReplaceAll(std::string& str, const std::string& from, const std::string& to, bool recurse=false); +//______________________________________________________________________________ +std::string GetInjectedUsingDecls(); + // Functions for the printouts ------------------------------------------------- //______________________________________________________________________________ diff --git a/core/clingutils/src/TClingUtils.cxx b/core/clingutils/src/TClingUtils.cxx index bd05506944de5..c92c5de62c955 100644 --- a/core/clingutils/src/TClingUtils.cxx +++ b/core/clingutils/src/TClingUtils.cxx @@ -5098,6 +5098,49 @@ bool ROOT::TMetaUtils::IsHeaderName(const std::string &filename) llvm::sys::path::extension(filename) == "HXX"; } +//////////////////////////////////////////////////////////////////////////////// +/// Get the using decls (and corresponding `#includes`) injected into cling for +/// backward compatibility with the earlier `using namespace std`. +std::string ROOT::TMetaUtils::GetInjectedUsingDecls() { + return R"CODE(#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using std::abs; +using std::fabs; +using std::array; +using std::bitset; +using std::cerr; +using std::cos; +using std::cout; +using std::endl; +using std::list; +using std::map; +using std::multimap; +using std::multiset; +using std::pair; +using std::round; +using std::set; +using std::sin; +using std::shared_ptr; +using std::string; +using std::tan; +using std::unique_ptr; +using std::unordered_map; +using std::unordered_set; +using std::vector; +)CODE"; +} + //////////////////////////////////////////////////////////////////////////////// const std::string ROOT::TMetaUtils::AST2SourceTools::Decls2FwdDecls(const std::vector &decls, diff --git a/core/dictgen/src/rootcling_impl.cxx b/core/dictgen/src/rootcling_impl.cxx index 261333ee173f5..646315a8a365e 100644 --- a/core/dictgen/src/rootcling_impl.cxx +++ b/core/dictgen/src/rootcling_impl.cxx @@ -2841,27 +2841,12 @@ void CreateDictHeader(std::ostream &dictStream, const std::string &main_dictname << "#include \"TDataMember.h\"\n\n"; // To set their transiency if (main_dictname.length() > 11 && main_dictname.substr(main_dictname.length() - 11) == "_ACLiC_dict") - dictStream << "#include \n" - "#include \n" - "#include \n" - "#include \n" - "#include \n" - "#include \n" - "#include \n" - "#include \n" - "#include \n" - "#include \n" - "#include \n" - "using std::allocator; using std::bitset; using std::default_delete; using " - "std::forward_list; using std::list; using std::map; using std::multimap; using " - "std::multiset; using std::pair; using std::set; using std::shared_ptr; using std::string; " - "using std::unique_ptr; using std::unordered_multimap; using std::unordered_map; using " - "std::unordered_multiset; using std::unordered_set; using std::vector;\n"; + dictStream << ROOT::TMetaUtils::GetInjectedUsingDecls(); } //////////////////////////////////////////////////////////////////////////////// -void AddNamespaceSTDdeclaration(std::ostream &dictStream) +void AddNamespaceSTDdeclaration(std::ostream & dictStream) { } diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index cd267a322452a..85f0316bb3ab1 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -1330,9 +1330,8 @@ static void RegisterPreIncludedHeaders(cling::Interpreter &clingInterp) #ifndef R__WIN32 PreIncludes += "#include \n"; #endif - PreIncludes += "#include \n" - "#include \n" - "using std::string; using std::vector;\n"; + PreIncludes += ROOT::TMetaUtils::GetInjectedUsingDecls(); + clingInterp.declare(PreIncludes); }