139using std::string, std::map, std::ifstream, std::ofstream, std::endl, std::ios, std::vector;
264 clang::ASTContext &C =
decl.getASTContext();
270 if (! it->GetAttributeValue(propNames::name,
varName))
continue;
274 BaseSelectionRule::AttributesMap_t::iterator iter;
277 const std::string &
name = iter->first;
278 const std::string &
value = iter->second;
280 if (
name == propNames::name)
continue;
285 if (
name == propNames::iotype &&
286 (
decl.getType()->isArrayType() ||
decl.getType()->isPointerType())) {
287 const char *
msg =
"Data member \"%s\" is an array or a pointer. "
288 "It is not possible to assign to it the iotype \"%s\". "
289 "This transformation is possible only with data members "
290 "which are not pointers or arrays.\n";
300 if (
name == propNames::comment) {
301 decl.addAttr(clang::AnnotateAttr::CreateImplicit(C,
value,
nullptr, 0));
305 if ((
name == propNames::transient &&
value ==
"true") ||
306 (
name == propNames::persistent &&
value ==
"false")) {
311 decl.addAttr(clang::AnnotateAttr::CreateImplicit(C,
"!",
nullptr, 0));
857 const cling::Interpreter &
interp,
875 if (!
clxx ||
clxx->getTemplateSpecializationKind() == clang::TSK_Undeclared)
return 0;
877 const clang::ClassTemplateSpecializationDecl *
tmplt_specialization = llvm::dyn_cast<clang::ClassTemplateSpecializationDecl> (
clxx);
885 const char *
tcl1 =
nullptr, *
tcl2 =
nullptr;
887 clang::QualType
ti =
arg0.getAsType();
905 const clang::ConstantArrayType *
arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
m.getType().getTypePtr());
911 if (
arrayType->getArrayElementTypeNoTypeQual()->isPointerType()) {
915 arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
arrayType->getArrayElementTypeNoTypeQual());
917 }
else if (
m.getType()->isPointerType()) {
924 dictStream <<
" for (Int_t R__l = 0; R__l < " <<
len <<
"; R__l++) {" << std::endl;
936 <<
" *" <<
stlName.c_str() <<
" = new " <<
stlType.c_str() <<
";" << std::endl
937 <<
" " <<
stlType.c_str() <<
" &R__stl = **" <<
stlName.c_str() <<
";" << std::endl;
941 <<
" " <<
stlName.c_str() <<
"[R__l] = new " <<
stlType.c_str() <<
";" << std::endl
942 <<
" " <<
stlType.c_str() <<
" &R__stl = *" <<
stlName.c_str() <<
"[R__l];" << std::endl;
946 dictStream <<
" R__stl.clear();" << std::endl;
949 dictStream <<
" TClass *R__tcl1 = TBuffer::GetClass(typeid(" <<
fulName1.c_str() <<
"));" << std::endl
950 <<
" if (R__tcl1==0) {" << std::endl
951 <<
" Error(\"" <<
stlName.c_str() <<
" streamer\",\"Missing the TClass object for "
952 <<
fulName1.c_str() <<
"!\");" << std::endl
953 <<
" return;" << std::endl
954 <<
" }" << std::endl;
957 dictStream <<
" TClass *R__tcl2 = TBuffer::GetClass(typeid(" <<
fulName2.c_str() <<
"));" << std::endl
958 <<
" if (R__tcl2==0) {" << std::endl
959 <<
" Error(\"" <<
stlName.c_str() <<
" streamer\",\"Missing the TClass object for "
960 <<
fulName2.c_str() <<
"!\");" << std::endl
961 <<
" return;" << std::endl
962 <<
" }" << std::endl;
966 <<
" R__b >> R__n;" << std::endl;
969 dictStream <<
" R__stl.reserve(R__n);" << std::endl;
971 dictStream <<
" for (R__i = 0; R__i < R__n; R__i++) {" << std::endl;
997 <<
" std::pair<Value_t const, " <<
tmplt_specialization->getTemplateArgs().get(1).getAsType().getAsString() <<
" > R__t3(R__t,R__t2);" << std::endl
998 <<
" R__stl.insert(R__t3);" << std::endl;
1006 dictStream <<
" R__stl.insert(R__t);" << std::endl;
1011 dictStream <<
" R__stl.push_back(R__t);" << std::endl;
1014 dictStream <<
" R__stl.push_front(R__t);" << std::endl;
1020 <<
" }" << std::endl;
1027 dictStream <<
" for (Int_t R__l = 0; R__l < " <<
len <<
"; R__l++) {" << std::endl;
1045 dictStream <<
" int R__n=int(R__stl.size());" << std::endl
1046 <<
" R__b << R__n;" << std::endl
1047 <<
" if(R__n) {" << std::endl;
1050 dictStream <<
" TClass *R__tcl1 = TBuffer::GetClass(typeid(" <<
fulName1.c_str() <<
"));" << std::endl
1051 <<
" if (R__tcl1==0) {" << std::endl
1052 <<
" Error(\"" <<
stlName.c_str() <<
" streamer\",\"Missing the TClass object for "
1053 <<
fulName1.c_str() <<
"!\");" << std::endl
1054 <<
" return;" << std::endl
1055 <<
" }" << std::endl;
1058 dictStream <<
" TClass *R__tcl2 = TBuffer::GetClass(typeid(" <<
fulName2.c_str() <<
"));" << std::endl
1059 <<
" if (R__tcl2==0) {" << std::endl
1060 <<
" Error(\"" <<
stlName.c_str() <<
"streamer\",\"Missing the TClass object for " <<
fulName2.c_str() <<
"!\");" << std::endl
1061 <<
" return;" << std::endl
1062 <<
" }" << std::endl;
1066 <<
" for (R__k = R__stl.begin(); R__k != R__stl.end(); ++R__k) {" << std::endl;
1077 <<
" }" << std::endl
1078 <<
" }" << std::endl;
1100 if (
m.getType()->isConstantArrayType()) {
1101 if (
m.getType().getTypePtr()->getArrayElementTypeNoTypeQual()->isPointerType()) {
1102 dictStream <<
"// Array of pointer to std::string are not supported (" <<
fieldname <<
"\n";
1105 const clang::ConstantArrayType *
arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
m.getType().getTypePtr());
1108 dictStream <<
" for (int R__i" << dim <<
"=0; R__i" << dim <<
"<"
1109 <<
arrayType->getSize().getLimitedValue() <<
"; ++R__i" << dim <<
" )" << std::endl;
1110 fullIdx <<
"[R__i" << dim <<
"]";
1111 arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
arrayType->getArrayElementTypeNoTypeQual());
1114 dictStream <<
" { TString R__str; R__str.Streamer(R__b); "
1118 dictStream <<
" { TString R__str; R__str.Streamer(R__b); ";
1119 if (
m.getType()->isPointerType())
1121 <<
fieldname <<
" = new string(R__str.Data())); }" << std::endl;
1127 if (
m.getType()->isPointerType())
1129 <<
fieldname <<
")->c_str(); R__str.Streamer(R__b);}" << std::endl;
1130 else if (
m.getType()->isConstantArrayType()) {
1132 const clang::ConstantArrayType *
arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
m.getType().getTypePtr());
1135 dictStream <<
" for (int R__i" << dim <<
"=0; R__i" << dim <<
"<"
1136 <<
arrayType->getSize().getLimitedValue() <<
"; ++R__i" << dim <<
" )" << std::endl;
1137 fullIdx <<
"[R__i" << dim <<
"]";
1138 arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
arrayType->getArrayElementTypeNoTypeQual());
1143 dictStream <<
" { TString R__str = " <<
fieldname <<
".c_str(); R__str.Streamer(R__b);}" << std::endl;
1391 const cling::Interpreter &
interp,
1395 const clang::CXXRecordDecl *
clxx = llvm::dyn_cast<clang::CXXRecordDecl>(cl.
GetRecordDecl());
1396 if (
clxx ==
nullptr)
return;
1409 dictStream <<
"//_______________________________________"
1410 <<
"_______________________________________" << std::endl;
1412 dictStream <<
"void " <<
clsname <<
"::Streamer(TBuffer &R__b)" << std::endl <<
"{" << std::endl
1413 <<
" // Stream an object of class " << fullname <<
"." << std::endl << std::endl;
1422 for (clang::CXXRecordDecl::base_class_const_iterator iter =
clxx->bases_begin(), end =
clxx->bases_end();
1431 dictStream <<
" //This works around a msvc bug and should be harmless on other platforms" << std::endl
1433 <<
" baseClass" <<
basestreamer <<
"::Streamer(R__b);" << std::endl;
1441 dictStream <<
" ::Error(\"" << fullname <<
"::Streamer\", \"version id <=0 in ClassDef,"
1442 " dummy Streamer() called\"); if (R__b.IsReading()) { }" << std::endl;
1453 string classname = fullname;
1454 if (
strstr(fullname.c_str(),
"::")) {
1456 dictStream <<
" //This works around a msvc bug and should be harmless on other platforms" << std::endl
1457 <<
" typedef ::" << fullname <<
" thisClass;" << std::endl;
1458 classname =
"thisClass";
1460 for (
int i = 0; i < 2; i++) {
1465 dictStream <<
" UInt_t R__s, R__c;" << std::endl;
1466 dictStream <<
" if (R__b.IsReading()) {" << std::endl;
1467 dictStream <<
" Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }" << std::endl;
1469 dictStream <<
" R__b.CheckByteCount(R__s, R__c, " << classname.c_str() <<
"::IsA());" << std::endl;
1471 dictStream <<
" R__c = R__b.WriteVersion(" << classname.c_str() <<
"::IsA(), kTRUE);" << std::endl;
1476 for (clang::CXXRecordDecl::base_class_const_iterator iter =
clxx->bases_begin(), end =
clxx->bases_end();
1485 dictStream <<
" //This works around a msvc bug and should be harmless on other platforms" << std::endl
1486 <<
" typedef " <<
base_fullname <<
" baseClass" << base <<
";" << std::endl
1487 <<
" baseClass" << base <<
"::Streamer(R__b);" << std::endl;
1496 for (clang::RecordDecl::field_iterator
field_iter =
clxx->field_begin(), end =
clxx->field_end();
1502 std::string
type_name =
type.getAsString(
clxx->getASTContext().getPrintingPolicy());
1519 if (
strncmp(comment,
"!", 1)) {
1523 if (
type.getTypePtr()->isConstantArrayType() &&
1524 type.getTypePtr()->getArrayElementTypeNoTypeQual()->isPointerType()) {
1525 const clang::ConstantArrayType *
arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
type.getTypePtr());
1532 dictStream <<
" for (R__i = 0; R__i < " << s <<
"; R__i++)" << std::endl;
1534 ROOT::TMetaUtils::Error(
nullptr,
"*** Datamember %s::%s: array of pointers to fundamental type (need manual intervention)\n", fullname.c_str(),
field_iter->getName().str().c_str());
1537 dictStream <<
" ;//R__b.WriteArray(" <<
field_iter->getName().str() <<
", __COUNTER__);" << std::endl;
1539 }
else if (
type.getTypePtr()->isPointerType()) {
1543 ROOT::TMetaUtils::Error(
nullptr,
"*** Datamember %s::%s: pointer to fundamental type (need manual intervention)\n", fullname.c_str(),
field_iter->getName().str().c_str());
1546 dictStream <<
" //R__b.WriteArray(" <<
field_iter->getName().str() <<
", __COUNTER__);" << std::endl;
1555 <<
"," <<
indexvar.str() <<
");" << std::endl;
1558 <<
"," <<
indexvar.str() <<
");" << std::endl;
1561 <<
"," <<
indexvar.str() <<
");" << std::endl;
1568 dictStream <<
" R__b.WriteFastArrayDouble32("
1576 }
else if (
type.getTypePtr()->isArrayType()) {
1578 if (
type.getTypePtr()->getArrayElementTypeNoTypeQual()->isArrayType()) {
1580 dictStream <<
" R__b.ReadStaticArray((Int_t*)" <<
field_iter->getName().str() <<
");" << std::endl;
1584 <<
"*)" <<
field_iter->getName().str() <<
");" << std::endl;
1587 <<
"*)" <<
field_iter->getName().str() <<
");" << std::endl;
1590 <<
"*)" <<
field_iter->getName().str() <<
");" << std::endl;
1595 dictStream <<
" R__b.ReadStaticArray((Int_t*)" <<
field_iter->getName().str() <<
");" << std::endl;
1598 dictStream <<
" R__b.ReadStaticArrayFloat16(" <<
field_iter->getName().str() <<
");" << std::endl;
1600 dictStream <<
" R__b.ReadStaticArrayDouble32(" <<
field_iter->getName().str() <<
");" << std::endl;
1603 <<
"*)" <<
field_iter->getName().str() <<
");" << std::endl;
1608 const clang::ConstantArrayType *
arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
type.getTypePtr());
1611 if (
type.getTypePtr()->getArrayElementTypeNoTypeQual()->isArrayType()) {
1614 << s <<
");" << std::endl;
1617 <<
"*)" <<
field_iter->getName().str() <<
", " << s <<
");" << std::endl;
1620 <<
"*)" <<
field_iter->getName().str() <<
", " << s <<
");" << std::endl;
1623 <<
"*)" <<
field_iter->getName().str() <<
", " << s <<
");" << std::endl;
1627 dictStream <<
" R__b.WriteArray((Int_t*)" <<
field_iter->getName().str() <<
", " << s <<
");" << std::endl;
1629 dictStream <<
" R__b.WriteArrayFloat16(" <<
field_iter->getName().str() <<
", " << s <<
");" << std::endl;
1631 dictStream <<
" R__b.WriteArrayDouble32(" <<
field_iter->getName().str() <<
", " << s <<
");" << std::endl;
1633 dictStream <<
" R__b.WriteArray(" <<
field_iter->getName().str() <<
", " << s <<
");" << std::endl;
1640 dictStream <<
" R__b >> *reinterpret_cast<Int_t*>(ptr_" <<
field_iter->getName().str() <<
");" << std::endl;
1647 <<
"=Float16_t(R_Dummy);}" << std::endl;
1653 <<
"=Double32_t(R_Dummy);}" << std::endl;
1675 if (
type.getTypePtr()->isConstantArrayType() &&
1676 type.getTypePtr()->getArrayElementTypeNoTypeQual()->isPointerType()) {
1677 const clang::ConstantArrayType *
arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
type.getTypePtr());
1684 dictStream <<
" for (R__i = 0; R__i < " << s <<
"; R__i++)" << std::endl;
1695 }
else if (
type.getTypePtr()->isPointerType()) {
1703 ROOT::TMetaUtils::Error(
nullptr,
"*** Datamember %s::%s: pointer to pointer (need manual intervention)\n", fullname.c_str(),
field_iter->getName().str().c_str());
1730 }
else if (
const clang::ConstantArrayType *
arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
type.getTypePtr())) {
1737 dictStream <<
" for (R__i = 0; R__i < " << s <<
"; R__i++)" << std::endl;
1741 const char *
constwd =
"const ";
1746 dictStream <<
"[R__i]).Streamer(R__b);" << std::endl;
1750 dictStream <<
"[R__i].Streamer(R__b);" << std::endl;
1757 <<
field_iter->getName().str() <<
"));" << std::endl;
1768 dictStream <<
" R__b.SetByteCount(R__c, kTRUE);" << std::endl
1769 <<
" }" << std::endl
1770 <<
"}" << std::endl << std::endl;
2003 clang::Module *
module =
nullptr)
2006 llvm::SmallVector<char, 128> buffer;
2007 llvm::BitstreamWriter stream(buffer);
2009 std::unique_ptr<llvm::raw_ostream> out =
2024 out->write(&buffer.front(), buffer.size());
2680 auto nsName = ns.GetNamespaceDecl()->getQualifiedNameAsString();
2681 if (
nsName.find(
"(anonymous)") == std::string::npos)
2686 if (!
selClass.GetRecordDecl()->isCompleteDefinition()) {
2690 if (
selClass.RequestOnlyTClass()) {
2698 if (clang::CXXRecordDecl *
CXXRD =
2699 llvm::dyn_cast<clang::CXXRecordDecl>(
const_cast<clang::RecordDecl *
>(
selClass.GetRecordDecl()))) {
2703 const clang::CXXRecordDecl *
CRD = llvm::dyn_cast<clang::CXXRecordDecl>(
selClass.GetRecordDecl());
2711 }
else if (
CRD->getName() ==
"RVec") {
2712 static const clang::DeclContext *
vecOpsDC =
nullptr;
2714 vecOpsDC = llvm::dyn_cast<clang::DeclContext>(
2715 interp.getLookupHelper().findScope(
"ROOT::VecOps", cling::LookupHelper::NoDiagnostics));
2739 if (!
selClass.GetRecordDecl()->isCompleteDefinition() ||
selClass.RequestOnlyTClass()) {
2743 const clang::CXXRecordDecl *
cxxdecl = llvm::dyn_cast<clang::CXXRecordDecl>(
selClass.GetRecordDecl());
2755 if (!
selClass.GetRecordDecl()->isCompleteDefinition() || !
selClass.RequestOnlyTClass()) {
2759 const clang::CXXRecordDecl *
CRD = llvm::dyn_cast<clang::CXXRecordDecl>(
selClass.GetRecordDecl());
3087 const cling::Interpreter &
interp,
3090 std::list<std::string>
headers;
3093 cling::Interpreter::PushTransactionRAII
RAII(&
interp);
3100 if (
const clang::ClassTemplateSpecializationDecl *
tsd = llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(&
rcd)) {
3103 for (
auto &
tArg :
tsd->getTemplateArgs().asArray()) {
3104 if (clang::TemplateArgument::ArgKind::Type !=
tArg.getKind())
continue;
3125 if (
const clang::FieldDecl *
fieldDecl = llvm::dyn_cast<clang::FieldDecl>(*
declIt)) {
3138 for (
auto & fPar :
methodIt->parameters()) {
3901 for (
const std::string &header :
modGen.GetHeaders()) {
3906 clang::ConstSearchDirIterator *
CurDir =
nullptr;
3908 header, clang::SourceLocation(),
3911 clang::ArrayRef<std::pair<clang::OptionalFileEntryRef, clang::DirectoryEntryRef>>(),
3950 clang::HeaderSearch &
headerSearch =
CI->getPreprocessor().getHeaderSearchInfo();
3954 clang::Module *
module = headerSearch.lookupModule(llvm::StringRef(moduleName));
3970 msgStream <<
"after creating module \"" <<
module->Name << "\" ";
3971 if (!
module->PresumedModuleMapFile.empty())
3972 msgStream <<
"using modulemap \"" <<
module->PresumedModuleMapFile << "\" ";
3973 msgStream <<
"the following headers are not part of that module:\n";
3977 msgStream <<
" (already part of module \"" <<
H[1] <<
"\")";
3993 ROOT::TMetaUtils::Info(
"CheckModuleValid, %s. You can silence this message by adding %s to the invocation.",
4003 [](
const std::array<std::string, 2>&
HdrMod) { return HdrMod[0];});
4041 llvm::PrettyStackTraceProgram
X(
argc,
argv);
4044#if defined(R__WIN32) && !defined(R__WINGCC)
4065 auto &
opts = llvm::cl::getRegisteredOptions();
4068 llvm::cl::desc(
"Alias for -help"),
4069 llvm::cl::aliasopt(*
optHelp));
4071 llvm::cl::desc(
"Alias for -help"),
4072 llvm::cl::aliasopt(*
optHelp));
4074 llvm::cl::ParseCommandLineOptions(
argc,
argv,
"rootcling");
4095 return interp->getDiagnostics().hasFatalErrorOccurred();
4112 llvm::cl::PrintHelpMessage();
4127 if ((fp =
fopen(
filein.c_str(),
"r")) ==
nullptr) {
4155 ROOT::TMetaUtils::Error(
nullptr,
"Inconsistent set of arguments detected: overwrite of dictionary file forced but no filename specified.\n");
4156 llvm::cl::PrintHelpMessage();
4168 std::list<std::string>
diagnosticPragmas = {
"#pragma clang diagnostic ignored \"-Wdeprecated-declarations\""};
4174 if (GetErrorIgnoreLevel() >
kWarning)
4176 GetWarningsAreErrors() =
true;
4190 ROOT::TMetaUtils::Error(
"",
"Multidict requested but no target library. Please specify one with the -s argument.\n");
4224 std::vector<std::string>
pcmArgs;
4238 [&](
const std::string& path){
4239 return ROOT::TMetaUtils::BeginsWith(&thisArg[offset], path);});
4246 clingArgs.push_back(std::string(
"-I") + llvm::sys::path::convert_to_slash(
gDriverConfig->fTROOT__GetEtcDir()));
4252 clingArgs.push_back(
"-DSYSTEM_TYPE_macosx");
4253#elif defined(R__WIN32)
4254 clingArgs.push_back(
"-DSYSTEM_TYPE_winnt");
4261 clingArgs.push_back(
"-DSYSTEM_TYPE_unix");
4269 clingArgs.push_back(
"-fmodules-embed-all-files");
4333 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"_Builtin_intrinsics.pcm").str().c_str());
4334 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"_Builtin_stddef_max_align_t.pcm").str().c_str());
4335 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"Cling_Runtime.pcm").str().c_str());
4336 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"Cling_Runtime_Extra.pcm").str().c_str());
4338 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"vcruntime.pcm").str().c_str());
4339 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"services.pcm").str().c_str());
4343 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"Darwin.pcm").str().c_str());
4345 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"libc.pcm").str().c_str());
4347 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"std.pcm").str().c_str());
4348 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"boost.pcm").str().c_str());
4349 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"tinyxml2.pcm").str().c_str());
4350 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"ROOT_Config.pcm").str().c_str());
4351 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"ROOT_Rtypes.pcm").str().c_str());
4352 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"ROOT_Foundation_C.pcm").str().c_str());
4353 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"ROOT_Foundation_Stage1_NoRTTI.pcm").str().c_str());
4355 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"Vc.pcm").str().c_str());
4370 std::cerr <<
"Argument \""<<
clingArg <<
"\" is not a supported cling argument. "
4371 <<
"This could be mistyped rootcling argument. Please check the commandline.\n";
4379 cling::Interpreter*
interpPtr =
nullptr;
4407 clang::CompilerInstance *
CI =
interp.getCI();
4409 CI->getFrontendOpts().ModulesEmbedAllFiles =
true;
4410 CI->getSourceManager().setAllFilesAreTransient(
true);
4412 clang::Preprocessor &
PP =
CI->getPreprocessor();
4422 diags.setSeverity(clang::diag::remark_module_build, clang::diag::Severity::Remark, clang::SourceLocation());