12#include "rootclingCommandLineOptionsHelp.h"
14#include "RConfigure.h"
33#include <unordered_map>
34#include <unordered_set>
46#define PATH_MAX _MAX_PATH
54#include <mach-o/dyld.h>
62#include <libprocstat.h>
71#include "cling/Interpreter/Interpreter.h"
72#include "cling/Interpreter/InterpreterCallbacks.h"
73#include "cling/Interpreter/LookupHelper.h"
74#include "cling/Interpreter/Value.h"
75#include "clang/AST/CXXInheritance.h"
76#include "clang/Basic/Diagnostic.h"
77#include "clang/Frontend/CompilerInstance.h"
78#include "clang/Frontend/FrontendActions.h"
79#include "clang/Frontend/FrontendDiagnostic.h"
80#include "clang/Lex/HeaderSearch.h"
81#include "clang/Lex/Preprocessor.h"
82#include "clang/Lex/ModuleMap.h"
83#include "clang/Lex/Pragma.h"
84#include "clang/Sema/Sema.h"
85#include "clang/Serialization/ASTWriter.h"
86#include "cling/Utils/AST.h"
88#include "llvm/ADT/StringRef.h"
90#include "llvm/Support/CommandLine.h"
91#include "llvm/Support/Path.h"
92#include "llvm/Support/PrettyStackTrace.h"
93#include "llvm/Support/Signals.h"
117#include <mach-o/dyld.h>
122#define strcasecmp _stricmp
123#define strncasecmp _strnicmp
131#define rootclingStringify(s) rootclingStringifyx(s)
132#define rootclingStringifyx(s) #s
139using std::string, std::map, std::ifstream, std::ofstream, std::endl, std::ios, std::vector;
150static llvm::cl::opt<bool>
152 llvm::cl::desc(
"Deprecated. Similar to -f but it ignores the dictionary generation. \
153When -r is present rootcling becomes a tool to generate rootmaps (and capability files)."),
178 gDriverConfig->fAddTypedefToROOTFile(
td->getQualifiedNameAsString().c_str());
186 if (clang::isa<clang::TranslationUnitDecl>(
en->getDeclContext())
187 || clang::isa<clang::LinkageSpecDecl>(
en->getDeclContext())
188 || clang::isa<clang::NamespaceDecl>(
en->getDeclContext()))
189 gDriverConfig->fAddEnumToROOTFile(
en->getQualifiedNameAsString().c_str());
203#if defined(__linux) || defined(__linux__)
212 if (
ret > 0 &&
ret < 1024) {
246 const cling::Interpreter &
interp)
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));
305 if ((
name == propNames::transient &&
value ==
"true") ||
306 (
name == propNames::persistent &&
value ==
"false")) {
311 decl.addAttr(clang::AnnotateAttr::CreateImplicit(C,
"!"));
338 using namespace clang;
340 llvm::StringRef comment;
357 BaseSelectionRule::AttributesMap_t::iterator iter;
360 const std::string &
name =
attr.first;
372 for (CXXRecordDecl::decl_iterator
I =
CXXRD.decls_begin(),
373 E =
CXXRD.decls_end();
I != E; ++
I) {
377 if (!(*I)->isImplicit()
389 if (comment.size()) {
392 CXXRD.addAttr(AnnotateAttr::CreateImplicit(C, comment.str()));
399 (*I)->addAttr(AnnotateAttr::CreateImplicit(C, comment.str()));
423 while (
const clang::ConstantArrayType *
subArrayType = llvm::dyn_cast<clang::ConstantArrayType>(
arrayType->getArrayElementTypeNoTypeQual())) {
427 return len.getLimitedValue();
433 const cling::Interpreter &
interp)
438 const clang::CXXRecordDecl *
clxx = llvm::dyn_cast<clang::CXXRecordDecl>(cl);
445 const cling::Interpreter &
interp)
490 fprintf(
stderr,
"rootcling: error getting realpath of rootcling!");
495 char *
ep =
new char[
nche];
503 if (!
strncmp(s + 1,
"rootcling_stage1.exe", 20)) {
507 }
else if (!
strncmp(s + 1,
"rootcling_stage1", 16)) {
529 char *env =
new char[
ncha];
552 size_t *end =
nullptr)
555 if (
line[0] !=
'#')
return false;
580 clang::Module *M =
recordDecl->getOwningModule()->getTopLevelModule();
598 if (classname.find(
':') == std::string::npos)
return;
601 int slen = classname.size();
602 for (
int k = 0; k <
slen; ++k) {
603 if (classname[k] ==
':') {
604 if (k + 1 >=
slen || classname[k + 1] !=
':') {
609 string base = classname.substr(0, k);
618 }
else if (classname[k] ==
'<') {
630 std::string classname;
632 while (file >>
line) {
634 if (
line.find(
"Library.") != 0)
continue;
636 int pos =
line.find(
":", 8);
637 classname =
line.substr(8, pos - 8);
643 while (
line[0] ==
' ')
line.replace(0, 1,
"");
647 if (classname ==
"ROOT::TImpProxy") {
666 const std::unordered_map<char, unsigned int>
keyLenMap = {{
'c', 6}, {
'n', 10}, {
't', 8}};
669 if (
line ==
"{ decls }") {
671 if (
line[0] ==
'[')
break;
678 while (
libs[0] ==
' ')
libs.replace(0, 1,
"");
702 if (llvm::sys::fs::is_directory(
filename))
continue;
710 file.seekg(0, std::ios::beg);
731 const string &fullname,
732 const clang::RecordDecl *cl,
733 cling::Interpreter &
interp)
736 const clang::FunctionDecl *
method
741 clang::TranslationUnitDecl *
TU =
742 cl->getASTContext().getTranslationUnitDecl();
747 if (
method !=
nullptr && (
method->getAccess() == clang::AS_public ||
method->getAccess() == clang::AS_none)) {
766 "in this version of ROOT, the option '!' used in a linkdef file\n"
767 " implies the actual existence of customized operators.\n"
768 " The following declaration is now required:\n"
783 int ncha = fullname.length() + 13;
808 const clang::CXXRecordDecl *
clxx = llvm::dyn_cast<clang::CXXRecordDecl>(&cl);
819 "because it inherits from TObject but does not "
820 "have its own ClassDef.\n",
833 if (
m.getType().isConstQualified()) {
834 string ret =
"const_cast< ";
844 ret +=
m.getName().str();
848 return prefix +
m.getName().str();
858 const cling::Interpreter &
interp,
876 if (!
clxx ||
clxx->getTemplateSpecializationKind() == clang::TSK_Undeclared)
return 0;
878 const clang::ClassTemplateSpecializationDecl *
tmplt_specialization = llvm::dyn_cast<clang::ClassTemplateSpecializationDecl> (
clxx);
886 const char *
tcl1 =
nullptr, *
tcl2 =
nullptr;
888 clang::QualType
ti =
arg0.getAsType();
906 const clang::ConstantArrayType *
arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
m.getType().getTypePtr());
912 if (
arrayType->getArrayElementTypeNoTypeQual()->isPointerType()) {
916 arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
arrayType->getArrayElementTypeNoTypeQual());
918 }
else if (
m.getType()->isPointerType()) {
925 dictStream <<
" for (Int_t R__l = 0; R__l < " <<
len <<
"; R__l++) {" << std::endl;
937 <<
" *" <<
stlName.c_str() <<
" = new " <<
stlType.c_str() <<
";" << std::endl
938 <<
" " <<
stlType.c_str() <<
" &R__stl = **" <<
stlName.c_str() <<
";" << std::endl;
942 <<
" " <<
stlName.c_str() <<
"[R__l] = new " <<
stlType.c_str() <<
";" << std::endl
943 <<
" " <<
stlType.c_str() <<
" &R__stl = *" <<
stlName.c_str() <<
"[R__l];" << std::endl;
947 dictStream <<
" R__stl.clear();" << std::endl;
950 dictStream <<
" TClass *R__tcl1 = TBuffer::GetClass(typeid(" <<
fulName1.c_str() <<
"));" << std::endl
951 <<
" if (R__tcl1==0) {" << std::endl
952 <<
" Error(\"" <<
stlName.c_str() <<
" streamer\",\"Missing the TClass object for "
953 <<
fulName1.c_str() <<
"!\");" << std::endl
954 <<
" return;" << std::endl
955 <<
" }" << std::endl;
958 dictStream <<
" TClass *R__tcl2 = TBuffer::GetClass(typeid(" <<
fulName2.c_str() <<
"));" << std::endl
959 <<
" if (R__tcl2==0) {" << std::endl
960 <<
" Error(\"" <<
stlName.c_str() <<
" streamer\",\"Missing the TClass object for "
961 <<
fulName2.c_str() <<
"!\");" << std::endl
962 <<
" return;" << std::endl
963 <<
" }" << std::endl;
967 <<
" R__b >> R__n;" << std::endl;
970 dictStream <<
" R__stl.reserve(R__n);" << std::endl;
972 dictStream <<
" for (R__i = 0; R__i < R__n; R__i++) {" << std::endl;
998 <<
" std::pair<Value_t const, " <<
tmplt_specialization->getTemplateArgs().get(1).getAsType().getAsString() <<
" > R__t3(R__t,R__t2);" << std::endl
999 <<
" R__stl.insert(R__t3);" << std::endl;
1007 dictStream <<
" R__stl.insert(R__t);" << std::endl;
1012 dictStream <<
" R__stl.push_back(R__t);" << std::endl;
1015 dictStream <<
" R__stl.push_front(R__t);" << std::endl;
1021 <<
" }" << std::endl;
1028 dictStream <<
" for (Int_t R__l = 0; R__l < " <<
len <<
"; R__l++) {" << std::endl;
1046 dictStream <<
" int R__n=int(R__stl.size());" << std::endl
1047 <<
" R__b << R__n;" << std::endl
1048 <<
" if(R__n) {" << std::endl;
1051 dictStream <<
" TClass *R__tcl1 = TBuffer::GetClass(typeid(" <<
fulName1.c_str() <<
"));" << std::endl
1052 <<
" if (R__tcl1==0) {" << std::endl
1053 <<
" Error(\"" <<
stlName.c_str() <<
" streamer\",\"Missing the TClass object for "
1054 <<
fulName1.c_str() <<
"!\");" << std::endl
1055 <<
" return;" << std::endl
1056 <<
" }" << std::endl;
1059 dictStream <<
" TClass *R__tcl2 = TBuffer::GetClass(typeid(" <<
fulName2.c_str() <<
"));" << std::endl
1060 <<
" if (R__tcl2==0) {" << std::endl
1061 <<
" Error(\"" <<
stlName.c_str() <<
"streamer\",\"Missing the TClass object for " <<
fulName2.c_str() <<
"!\");" << std::endl
1062 <<
" return;" << std::endl
1063 <<
" }" << std::endl;
1067 <<
" for (R__k = R__stl.begin(); R__k != R__stl.end(); ++R__k) {" << std::endl;
1078 <<
" }" << std::endl
1079 <<
" }" << std::endl;
1101 if (
m.getType()->isConstantArrayType()) {
1102 if (
m.getType().getTypePtr()->getArrayElementTypeNoTypeQual()->isPointerType()) {
1103 dictStream <<
"// Array of pointer to std::string are not supported (" <<
fieldname <<
"\n";
1106 const clang::ConstantArrayType *
arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
m.getType().getTypePtr());
1109 dictStream <<
" for (int R__i" << dim <<
"=0; R__i" << dim <<
"<"
1110 <<
arrayType->getSize().getLimitedValue() <<
"; ++R__i" << dim <<
" )" << std::endl;
1111 fullIdx <<
"[R__i" << dim <<
"]";
1112 arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
arrayType->getArrayElementTypeNoTypeQual());
1115 dictStream <<
" { TString R__str; R__str.Streamer(R__b); "
1119 dictStream <<
" { TString R__str; R__str.Streamer(R__b); ";
1120 if (
m.getType()->isPointerType())
1122 <<
fieldname <<
" = new string(R__str.Data())); }" << std::endl;
1128 if (
m.getType()->isPointerType())
1130 <<
fieldname <<
")->c_str(); R__str.Streamer(R__b);}" << std::endl;
1131 else if (
m.getType()->isConstantArrayType()) {
1133 const clang::ConstantArrayType *
arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
m.getType().getTypePtr());
1136 dictStream <<
" for (int R__i" << dim <<
"=0; R__i" << dim <<
"<"
1137 <<
arrayType->getSize().getLimitedValue() <<
"; ++R__i" << dim <<
" )" << std::endl;
1138 fullIdx <<
"[R__i" << dim <<
"]";
1139 arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
arrayType->getArrayElementTypeNoTypeQual());
1144 dictStream <<
" { TString R__str = " <<
fieldname <<
".c_str(); R__str.Streamer(R__b);}" << std::endl;
1155 if (
m.getType()->isPointerType()) {
1156 if (
m.getType()->getPointeeType()->isPointerType()) {
1168 const clang::ConstantArrayType *
arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
type.getTypePtr());
1170 arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
arrayType->getArrayElementTypeNoTypeQual());
1173 arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
arrayType->getArrayElementTypeNoTypeQual());
1195 dictStream <<
"#include \"TInterpreter.h\"\n";
1197 dictStream <<
"//_______________________________________"
1198 <<
"_______________________________________" << std::endl;
1200 dictStream <<
"atomic_TClass_ptr " <<
clsname <<
"::fgIsA(nullptr); // static to hold class pointer" << std::endl
1203 <<
"//_______________________________________"
1204 <<
"_______________________________________" << std::endl;
1206 dictStream <<
"const char *" <<
clsname <<
"::Class_Name()" << std::endl <<
"{" << std::endl
1207 <<
" return \"" << fullname <<
"\";" << std::endl <<
"}" << std::endl << std::endl;
1209 dictStream <<
"//_______________________________________"
1210 <<
"_______________________________________" << std::endl;
1212 dictStream <<
"const char *" <<
clsname <<
"::ImplFileName()" << std::endl <<
"{" << std::endl
1213 <<
" return ::ROOT::GenerateInitInstanceLocal((const ::" << fullname
1214 <<
"*)nullptr)->GetImplFileName();" << std::endl <<
"}" << std::endl << std::endl
1216 <<
"//_______________________________________"
1217 <<
"_______________________________________" << std::endl;
1219 dictStream <<
"int " <<
clsname <<
"::ImplFileLine()" << std::endl <<
"{" << std::endl
1220 <<
" return ::ROOT::GenerateInitInstanceLocal((const ::" << fullname
1221 <<
"*)nullptr)->GetImplFileLine();" << std::endl <<
"}" << std::endl << std::endl
1223 <<
"//_______________________________________"
1224 <<
"_______________________________________" << std::endl;
1226 dictStream <<
"TClass *" <<
clsname <<
"::Dictionary()" << std::endl <<
"{" << std::endl;
1230 dictStream <<
" gInterpreter->AutoLoad(\"" << fullname <<
"\");\n";
1231 dictStream <<
" fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::" << fullname
1232 <<
"*)nullptr)->GetClass();" << std::endl
1233 <<
" return fgIsA;\n"
1234 <<
"}" << std::endl << std::endl
1236 <<
"//_______________________________________"
1237 <<
"_______________________________________" << std::endl;
1239 dictStream <<
"TClass *" <<
clsname <<
"::Class()" << std::endl <<
"{" << std::endl;
1243 dictStream <<
" if (!fgIsA.load()) { R__LOCKGUARD(gInterpreterMutex); fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::";
1244 dictStream << fullname <<
"*)nullptr)->GetClass(); }" << std::endl;
1247 <<
"}" << std::endl << std::endl;
1259 cling::Interpreter &
interp,
1262 if (cl->isAnonymousNamespace()) {
1274 if (classname !=
"ROOT") {
1278 dictStream <<
" namespace ROOTDict {" << std::endl;
1281 dictStream <<
" inline ::ROOT::TGenericClassInfo *GenerateInitInstance();" << std::endl;
1288 <<
" // Function generating the singleton type initializer" << std::endl
1291 <<
" inline ::ROOT::TGenericClassInfo *GenerateInitInstance()" << std::endl
1292 <<
" {" << std::endl
1294 <<
" ::ROOT::TGenericClassInfo *GenerateInitInstance()" << std::endl
1295 <<
" {" << std::endl
1298 <<
" static ::ROOT::TGenericClassInfo " << std::endl
1300 <<
" instance(\"" << classname.c_str() <<
"\", ";
1303 dictStream <<
"::" << classname.c_str() <<
"::Class_Version(), ";
1309 for (
unsigned int i = 0; i <
filename.length(); i++) {
1313 <<
" ::ROOT::Internal::DefineBehavior((void*)nullptr,(void*)nullptr)," << std::endl
1317 dictStream <<
"&::" << classname.c_str() <<
"::Dictionary, ";
1324 <<
" return &instance;" << std::endl
1325 <<
" }" << std::endl
1326 <<
" // Insure that the inline function is _not_ optimized away by the compiler\n"
1327 <<
" ::ROOT::TGenericClassInfo *(*_R__UNIQUE_DICT_(InitFunctionKeeper))() = &GenerateInitInstance; " << std::endl
1328 <<
" // Static variable to force the class initialization" << std::endl
1330 <<
" static ::ROOT::TGenericClassInfo *_R__UNIQUE_DICT_(Init) = GenerateInitInstance();"
1331 <<
" R__UseDummy(_R__UNIQUE_DICT_(Init));" << std::endl;
1334 dictStream << std::endl <<
" // Dictionary for non-ClassDef classes" << std::endl
1335 <<
" static TClass *" <<
mappedname.c_str() <<
"_Dictionary() {" << std::endl
1336 <<
" return GenerateInitInstance()->GetClass();" << std::endl
1337 <<
" }" << std::endl << std::endl;
1356 llvm::StringRef
where;
1359 if (
index.size() == 0 && printError) {
1366 errorstring =
"has not been defined before the array";
1369 errorstring =
"is a private member of a parent class";
1378 if (
where.size() == 0) {
1380 member.getParent()->getName().str().c_str(),
member.getName().str().c_str());
1392 const cling::Interpreter &
interp,
1396 const clang::CXXRecordDecl *
clxx = llvm::dyn_cast<clang::CXXRecordDecl>(cl.
GetRecordDecl());
1397 if (
clxx ==
nullptr)
return;
1410 dictStream <<
"//_______________________________________"
1411 <<
"_______________________________________" << std::endl;
1413 dictStream <<
"void " <<
clsname <<
"::Streamer(TBuffer &R__b)" << std::endl <<
"{" << std::endl
1414 <<
" // Stream an object of class " << fullname <<
"." << std::endl << std::endl;
1423 for (clang::CXXRecordDecl::base_class_const_iterator iter =
clxx->bases_begin(), end =
clxx->bases_end();
1432 dictStream <<
" //This works around a msvc bug and should be harmless on other platforms" << std::endl
1434 <<
" baseClass" <<
basestreamer <<
"::Streamer(R__b);" << std::endl;
1442 dictStream <<
" ::Error(\"" << fullname <<
"::Streamer\", \"version id <=0 in ClassDef,"
1443 " dummy Streamer() called\"); if (R__b.IsReading()) { }" << std::endl;
1454 string classname = fullname;
1455 if (
strstr(fullname.c_str(),
"::")) {
1457 dictStream <<
" //This works around a msvc bug and should be harmless on other platforms" << std::endl
1458 <<
" typedef ::" << fullname <<
" thisClass;" << std::endl;
1459 classname =
"thisClass";
1461 for (
int i = 0; i < 2; i++) {
1466 dictStream <<
" UInt_t R__s, R__c;" << std::endl;
1467 dictStream <<
" if (R__b.IsReading()) {" << std::endl;
1468 dictStream <<
" Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }" << std::endl;
1470 dictStream <<
" R__b.CheckByteCount(R__s, R__c, " << classname.c_str() <<
"::IsA());" << std::endl;
1472 dictStream <<
" R__c = R__b.WriteVersion(" << classname.c_str() <<
"::IsA(), kTRUE);" << std::endl;
1477 for (clang::CXXRecordDecl::base_class_const_iterator iter =
clxx->bases_begin(), end =
clxx->bases_end();
1486 dictStream <<
" //This works around a msvc bug and should be harmless on other platforms" << std::endl
1487 <<
" typedef " <<
base_fullname <<
" baseClass" << base <<
";" << std::endl
1488 <<
" baseClass" << base <<
"::Streamer(R__b);" << std::endl;
1497 for (clang::RecordDecl::field_iterator
field_iter =
clxx->field_begin(), end =
clxx->field_end();
1503 std::string
type_name =
type.getAsString(
clxx->getASTContext().getPrintingPolicy());
1520 if (
strncmp(comment,
"!", 1)) {
1524 if (
type.getTypePtr()->isConstantArrayType() &&
1525 type.getTypePtr()->getArrayElementTypeNoTypeQual()->isPointerType()) {
1526 const clang::ConstantArrayType *
arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
type.getTypePtr());
1533 dictStream <<
" for (R__i = 0; R__i < " << s <<
"; R__i++)" << std::endl;
1535 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());
1538 dictStream <<
" ;//R__b.WriteArray(" <<
field_iter->getName().str() <<
", __COUNTER__);" << std::endl;
1540 }
else if (
type.getTypePtr()->isPointerType()) {
1544 ROOT::TMetaUtils::Error(
nullptr,
"*** Datamember %s::%s: pointer to fundamental type (need manual intervention)\n", fullname.c_str(),
field_iter->getName().str().c_str());
1547 dictStream <<
" //R__b.WriteArray(" <<
field_iter->getName().str() <<
", __COUNTER__);" << std::endl;
1556 <<
"," <<
indexvar.str() <<
");" << std::endl;
1559 <<
"," <<
indexvar.str() <<
");" << std::endl;
1562 <<
"," <<
indexvar.str() <<
");" << std::endl;
1569 dictStream <<
" R__b.WriteFastArrayDouble32("
1577 }
else if (
type.getTypePtr()->isArrayType()) {
1579 if (
type.getTypePtr()->getArrayElementTypeNoTypeQual()->isArrayType()) {
1581 dictStream <<
" R__b.ReadStaticArray((Int_t*)" <<
field_iter->getName().str() <<
");" << std::endl;
1585 <<
"*)" <<
field_iter->getName().str() <<
");" << std::endl;
1588 <<
"*)" <<
field_iter->getName().str() <<
");" << std::endl;
1591 <<
"*)" <<
field_iter->getName().str() <<
");" << std::endl;
1596 dictStream <<
" R__b.ReadStaticArray((Int_t*)" <<
field_iter->getName().str() <<
");" << std::endl;
1599 dictStream <<
" R__b.ReadStaticArrayFloat16(" <<
field_iter->getName().str() <<
");" << std::endl;
1601 dictStream <<
" R__b.ReadStaticArrayDouble32(" <<
field_iter->getName().str() <<
");" << std::endl;
1604 <<
"*)" <<
field_iter->getName().str() <<
");" << std::endl;
1609 const clang::ConstantArrayType *
arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
type.getTypePtr());
1612 if (
type.getTypePtr()->getArrayElementTypeNoTypeQual()->isArrayType()) {
1615 << s <<
");" << std::endl;
1618 <<
"*)" <<
field_iter->getName().str() <<
", " << s <<
");" << std::endl;
1621 <<
"*)" <<
field_iter->getName().str() <<
", " << s <<
");" << std::endl;
1624 <<
"*)" <<
field_iter->getName().str() <<
", " << s <<
");" << std::endl;
1628 dictStream <<
" R__b.WriteArray((Int_t*)" <<
field_iter->getName().str() <<
", " << s <<
");" << std::endl;
1630 dictStream <<
" R__b.WriteArrayFloat16(" <<
field_iter->getName().str() <<
", " << s <<
");" << std::endl;
1632 dictStream <<
" R__b.WriteArrayDouble32(" <<
field_iter->getName().str() <<
", " << s <<
");" << std::endl;
1634 dictStream <<
" R__b.WriteArray(" <<
field_iter->getName().str() <<
", " << s <<
");" << std::endl;
1641 dictStream <<
" R__b >> *reinterpret_cast<Int_t*>(ptr_" <<
field_iter->getName().str() <<
");" << std::endl;
1648 <<
"=Float16_t(R_Dummy);}" << std::endl;
1654 <<
"=Double32_t(R_Dummy);}" << std::endl;
1676 if (
type.getTypePtr()->isConstantArrayType() &&
1677 type.getTypePtr()->getArrayElementTypeNoTypeQual()->isPointerType()) {
1678 const clang::ConstantArrayType *
arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
type.getTypePtr());
1685 dictStream <<
" for (R__i = 0; R__i < " << s <<
"; R__i++)" << std::endl;
1696 }
else if (
type.getTypePtr()->isPointerType()) {
1704 ROOT::TMetaUtils::Error(
nullptr,
"*** Datamember %s::%s: pointer to pointer (need manual intervention)\n", fullname.c_str(),
field_iter->getName().str().c_str());
1731 }
else if (
const clang::ConstantArrayType *
arrayType = llvm::dyn_cast<clang::ConstantArrayType>(
type.getTypePtr())) {
1738 dictStream <<
" for (R__i = 0; R__i < " << s <<
"; R__i++)" << std::endl;
1742 const char *
constwd =
"const ";
1747 dictStream <<
"[R__i]).Streamer(R__b);" << std::endl;
1751 dictStream <<
"[R__i].Streamer(R__b);" << std::endl;
1758 <<
field_iter->getName().str() <<
"));" << std::endl;
1769 dictStream <<
" R__b.SetByteCount(R__c, kTRUE);" << std::endl
1770 <<
" }" << std::endl
1771 <<
"}" << std::endl << std::endl;
1782 const cling::Interpreter &
interp,
1788 const clang::CXXRecordDecl *
clxx = llvm::dyn_cast<clang::CXXRecordDecl>(cl.
GetRecordDecl());
1789 if (
clxx ==
nullptr)
return;
1794 for (clang::CXXRecordDecl::base_class_const_iterator iter =
clxx->bases_begin(), end =
clxx->bases_end();
1812 dictStream <<
"//_______________________________________"
1813 <<
"_______________________________________" << std::endl;
1817 <<
" // Stream an object of class " << fullname <<
"." << std::endl << std::endl
1818 <<
" if (R__b.IsReading()) {" << std::endl
1819 <<
" R__b.ReadClassBuffer(" << fullname <<
"::Class(),this);" << std::endl
1820 <<
" } else {" << std::endl
1821 <<
" R__b.WriteClassBuffer(" << fullname <<
"::Class(),this);" << std::endl
1822 <<
" }" << std::endl
1823 <<
"}" << std::endl << std::endl;
1834 const cling::Interpreter &
interp,
1856 for (std::string& arg : InputFiles) {
1859 for (
int j = 0;
j < 3;
j++) {
1860 if (arg[
l] ==
'-') {
1865 if (arg[
l] ==
'!') {
1870 if (arg[
l] ==
'+') {
1886 llvm::SmallString<256>
filestem = llvm::sys::path::filename(arg);
1887 llvm::sys::path::replace_extension(
filestem,
"");
1926 for (
size_t i = 0; i <
nPaths; i += 1 ) {
1975 cling::Interpreter &
interp,
1978 std::ostringstream out;
1982 modGen.WriteUmbrellaHeader(out);
1983 if (
interp.declare(out.str()) != cling::Interpreter::kSuccess) {
1991 modGen.WriteContentHeader(out);
2004 clang::Module *
module =
nullptr)
2007 llvm::SmallVector<char, 128> buffer;
2008 llvm::BitstreamWriter stream(buffer);
2010 std::unique_ptr<llvm::raw_ostream> out =
2025 out->write(&buffer.front(), buffer.size());
2039 assert(
modGen.IsPCH() &&
"modGen must be in PCH mode");
2041 std::string
iSysRoot(
"/DUMMY_SYSROOT/include/");
2057 for (
const std::string &header :
headers) {
2058 includes <<
"#include \"" << header <<
"\"\n";
2062 return result == cling::Interpreter::CompilationResult::kSuccess;
2071#ifdef __INTEL_COMPILER
2084#ifdef __GNUC_MINOR__
2100#ifdef _STLPORT_VERSION
2147 return llvm::sys::path::filename(path).str();
2157 if (std::string::npos != pos) {
2158 dirname.assign(path.begin(), path.begin() + pos + 1);
2226 const cling::Interpreter &
interp)
2228 if (!
decls.empty()) {
2235 names.push_back(
d->getQualifiedNameAsString());
2256 const std::list<std::string> &
nsNames,
2257 const std::list<std::string> &
tdNames,
2258 const std::list<std::string> &
enNames,
2259 const std::list<std::string> &
varNames,
2293 rootmapFile <<
"class " << className << std::endl;
2300 if (className.find(
"<") != std::string::npos)
continue;
2304 auto &header =
headers.front();
2325 rootmapFile <<
"# List of selected typedefs and outer classes\n";
2334 rootmapFile <<
"# List of selected enums and outer classes\n";
2361 if (
foundNsPos == std::string::npos)
return {
"",
""};
2417 std::list<std::string> &
el_list,
2418 std::unordered_set<std::string> &
el_set)
2425 if (
el_set.insert(tmp).second && !tmp.empty()) {
2476 std::cerr <<
"FATAL: A class with normalized name " <<
normalizedName
2477 <<
" was already selected. This means that two different instances of"
2478 <<
" clang::RecordDecl had the same name, which is not possible."
2479 <<
" This can be a hint of a serious problem in the class selection."
2480 <<
" In addition, the generated dictionary would not even compile.\n";
2494 if (llvm::isa<clang::ClassTemplateSpecializationDecl>(
rDecl)) {
2536 !llvm::isa<clang::ClassTemplateSpecializationDecl>(
rDecl) &&
2590 if (clang::CXXRecordDecl *
CXXRD =
2591 llvm::dyn_cast<clang::CXXRecordDecl>(
const_cast<clang::RecordDecl *
>(
selClass.GetRecordDecl()))) {
2603 if (!
selClass.GetRecordDecl()->isCompleteDefinition() ||
selClass.RequestOnlyTClass()) {
2606 const clang::CXXRecordDecl *
cxxdecl = llvm::dyn_cast<clang::CXXRecordDecl>(
selClass.GetRecordDecl());
2609 "Interactivity only dictionaries are not supported for classes with ClassDef\n");
2625 if (
interp.parseForModule(
"#include \"TStreamerInfo.h\"\n"
2626 "#include \"TFile.h\"\n"
2627 "#include \"TObjArray.h\"\n"
2628 "#include \"TVirtualArray.h\"\n"
2629 "#include \"TStreamerElement.h\"\n"
2630 "#include \"TProtoClass.h\"\n"
2631 "#include \"TBaseClass.h\"\n"
2632 "#include \"TListOfDataMembers.h\"\n"
2633 "#include \"TListOfEnums.h\"\n"
2634 "#include \"TListOfEnumsWithLock.h\"\n"
2635 "#include \"TDataMember.h\"\n"
2636 "#include \"TEnum.h\"\n"
2637 "#include \"TEnumConstant.h\"\n"
2638 "#include \"TDictAttributeMap.h\"\n"
2639 "#include \"TMessageHandler.h\"\n"
2640 "#include \"TArray.h\"\n"
2641 "#include \"TRefArray.h\"\n"
2642 "#include \"root_std_complex.h\"\n")
2643 != cling::Interpreter::kSuccess)
2654 cling::Interpreter &
interp,
2686 auto nsName = ns.GetNamespaceDecl()->getQualifiedNameAsString();
2687 if (
nsName.find(
"(anonymous)") == std::string::npos)
2692 if (!
selClass.GetRecordDecl()->isCompleteDefinition()) {
2696 if (
selClass.RequestOnlyTClass()) {
2704 if (clang::CXXRecordDecl *
CXXRD =
2705 llvm::dyn_cast<clang::CXXRecordDecl>(
const_cast<clang::RecordDecl *
>(
selClass.GetRecordDecl()))) {
2709 const clang::CXXRecordDecl *
CRD = llvm::dyn_cast<clang::CXXRecordDecl>(
selClass.GetRecordDecl());
2717 }
else if (
CRD->getName() ==
"RVec") {
2718 static const clang::DeclContext *
vecOpsDC =
nullptr;
2720 vecOpsDC = llvm::dyn_cast<clang::DeclContext>(
2721 interp.getLookupHelper().findScope(
"ROOT::VecOps", cling::LookupHelper::NoDiagnostics));
2745 if (!
selClass.GetRecordDecl()->isCompleteDefinition() ||
selClass.RequestOnlyTClass()) {
2749 const clang::CXXRecordDecl *
cxxdecl = llvm::dyn_cast<clang::CXXRecordDecl>(
selClass.GetRecordDecl());
2761 if (!
selClass.GetRecordDecl()->isCompleteDefinition() || !
selClass.RequestOnlyTClass()) {
2765 const clang::CXXRecordDecl *
CRD = llvm::dyn_cast<clang::CXXRecordDecl>(
selClass.GetRecordDecl());
2815 dictStream <<
"// Do NOT change. Changes will be lost next time file is generated\n\n"
2816 <<
"#define R__DICTIONARY_FILENAME " <<
main_dictname << std::endl
2819 <<
"#define R__NO_DEPRECATION" << std::endl
2824 <<
"\n/*******************************************************************/\n"
2825 <<
"#include <stddef.h>\n"
2826 <<
"#include <stdio.h>\n"
2827 <<
"#include <stdlib.h>\n"
2828 <<
"#include <string.h>\n"
2829 <<
"#include <assert.h>\n"
2830 <<
"#define G__DICTIONARY\n"
2831 <<
"#include \"ROOT/RConfig.hxx\"\n"
2832 <<
"#include \"TClass.h\"\n"
2833 <<
"#include \"TDictAttributeMap.h\"\n"
2834 <<
"#include \"TInterpreter.h\"\n"
2835 <<
"#include \"TROOT.h\"\n"
2836 <<
"#include \"TBuffer.h\"\n"
2837 <<
"#include \"TMemberInspector.h\"\n"
2838 <<
"#include \"TInterpreter.h\"\n"
2839 <<
"#include \"TVirtualMutex.h\"\n"
2840 <<
"#include \"TError.h\"\n\n"
2841 <<
"#ifndef G__ROOT\n"
2842 <<
"#define G__ROOT\n"
2844 <<
"#include \"RtypesImp.h\"\n"
2845 <<
"#include \"TIsAProxy.h\"\n"
2846 <<
"#include \"TFileMergeInfo.h\"\n"
2847 <<
"#include <algorithm>\n"
2848 <<
"#include \"TCollectionProxyInfo.h\"\n"
2849 <<
"/*******************************************************************/\n\n"
2850 <<
"#include \"TDataMember.h\"\n\n";
2857 dictStream <<
"// The generated code does not explicitly qualify STL entities\n"
2858 <<
"namespace std {} using namespace std;\n\n";
2867 dictStream <<
"// Header files passed as explicit arguments\n"
2869 <<
"// Header files passed via #pragma extra_include\n"
2876#if defined(R__IOSSIM) || defined(R__IOS)
2937 for (
unsigned int i = 0; i < m_size; ++i) {
2938 const char *
tmpName = m_tempNames[i].c_str();
2945 if (
ifile.is_open())
2947 if (0 != std::remove(
tmpName)) {
2960 for (
unsigned int i = 0; i < m_size; ++i) {
2961 const char *
tmpName = m_tempNames[i].c_str();
2962 const char *
name = m_names[i].c_str();
2969 if (
ifile.is_open())
2977 llvm::sys::fs::remove(
tmpName);
2993 size_t i = std::distance(m_tempNames.begin(),
2994 find(m_tempNames.begin(), m_tempNames.end(),
tmpFileName));
2995 if (i == m_tempNames.size())
return m_emptyString;
3002 std::cout <<
"Restoring files in temporary file catalog:\n";
3003 for (
unsigned int i = 0; i < m_size; ++i) {
3004 std::cout << m_tempNames[i] <<
" --> " << m_names[i] << std::endl;
3036 static const std::string pattern(
"-Wno-");
3038 if (arg.find(pattern) != 0)
3049 cling::Interpreter &
interp)
3074 if (
qt.isNull())
return qt;
3076 while (
thisQt->isPointerType() ||
3077 thisQt->isReferenceType()) {
3088 const cling::Interpreter &
interp,
3091 std::list<std::string>
headers;
3094 cling::Interpreter::PushTransactionRAII
RAII(&
interp);
3101 if (
const clang::ClassTemplateSpecializationDecl *
tsd = llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(&
rcd)) {
3104 for (
auto &
tArg :
tsd->getTemplateArgs().asArray()) {
3105 if (clang::TemplateArgument::ArgKind::Type !=
tArg.getKind())
continue;
3126 if (
const clang::FieldDecl *
fieldDecl = llvm::dyn_cast<clang::FieldDecl>(*
declIt)) {
3139 for (
auto & fPar :
methodIt->parameters()) {
3174 if (!
dclCtxt->isStdNamespace()){
3194 if (
argKind != clang::TemplateArgument::Type){
3195 if (
argKind == clang::TemplateArgument::Integral)
continue;
3202 if (
isPOD)
continue;
3227 const cling::Interpreter &
interp)
3230 std::unordered_set<std::string> buffer;
3235 if (
const clang::CXXRecordDecl *
cxxRcd =
3236 llvm::dyn_cast_or_null<clang::CXXRecordDecl>(
annotatedRcd.GetRecordDecl())) {
3242 headers.remove_if([&buffer](
const std::string & s) {
3243 return !buffer.insert(s).second;
3256 if (!llvm::isa<clang::ClassTemplateSpecializationDecl>(
cxxRcd)){
3265 if (clang::CXXRecordDecl *
cxxRcd =
tDef->getUnderlyingType()->getAsCXXRecordDecl()) {
3272 headers.remove_if([&buffer](
const std::string & s) {
3273 return !buffer.insert(s).second;
3304 const cling::Interpreter &
interp)
3312 std::unordered_set<std::string>
fwdDecls;
3355 std::cout <<
"Logs from forward decl printer: \n"
3386 std::cout <<
"Class-headers Mapping:\n";
3402 std::cout << std::endl;
3429 static const std::vector<std::string>
namePrfxes {
3434 [&](
const std::string& str){return ROOT::TMetaUtils::BeginsWith(name,str);});
3452 [&](
const std::string& str){return ROOT::TMetaUtils::BeginsWith(name,str);});
3466 std::cerr <<
"Error: Class " <<
clName <<
" has been selected but "
3467 <<
"currently the support for its I/O is not yet available. Note that "
3468 <<
clName <<
", even if not selected, will be available for "
3469 <<
"interpreted code.\n";
3473 std::cerr <<
"Error: It is not necessary to explicitly select class "
3474 <<
clName <<
". I/O is supported for it transparently.\n";
3486 bool isLocked =
false;
3489 InterpreterCallbacks(
interp),
3495 llvm::StringRef FileName,
bool IsAngled, clang::CharSourceRange ,
3496 clang::OptionalFileEntryRef , llvm::StringRef ,
3497 llvm::StringRef ,
const clang::Module * ,
3498 clang::SrcMgr::CharacteristicKind )
override
3500 if (isLocked)
return;
3513 fFilesIncludedByLinkdef.clear();
3533 using namespace clang;
3534 if (llvm::StringRef(M->Name).endswith(
"ACLiC_dict")) {
3540 assert(M &&
"Must have module Core");
3546static llvm::cl::list<std::string>
3549 llvm::cl::desc(
"The list of the expected implicit modules build as part of building the current module."),
3552static llvm::cl::opt<std::string>
3554 llvm::cl::desc(
"<output dictionary file>"),
3586 using namespace clang::diag;
3593 const clang::Module *
module = nullptr;
3596 const auto &ID =
Info.getID();
3599 module = fMap.findModule(moduleName);
3605 "Couldn't find module %s in the available modulemaps. This"
3606 "prevents us from correctly diagnosing wrongly built modules.\n",
3621 =
module && std::find(gOptModuleByproducts.begin(), gOptModuleByproducts.end(), moduleName) != gOptModuleByproducts.end();
3627 "Building module '%s' implicitly. If '%s' requires a \n"
3628 "dictionary please specify build dependency: '%s' depends on '%s'.\n"
3629 "Otherwise, specify '-mByproduct %s' to disable this diagnostic.\n",
3639 DiagnosticConsumer::clear();
3645 DiagnosticConsumer::BeginSourceFile(
LangOpts,
PP);
3650 fChild->EndSourceFile();
3651 DiagnosticConsumer::EndSourceFile();
3657 DiagnosticConsumer::finish();
3664#if defined(_WIN32) && defined(_MSC_VER)
3681static llvm::cl::opt<bool>
gOptForce(
"f", llvm::cl::desc(
"Overwrite <file>s."),
3683static llvm::cl::opt<bool>
gOptRootBuild(
"rootbuild", llvm::cl::desc(
"If we are building ROOT."),
3694static llvm::cl::opt<VerboseLevel>
3696 llvm::cl::values(
clEnumVal(
v,
"Show errors."),
3705static llvm::cl::opt<bool>
3706gOptCint(
"cint", llvm::cl::desc(
"Deprecated, legacy flag which is ignored."),
3709static llvm::cl::opt<bool>
3710gOptReflex(
"reflex", llvm::cl::desc(
"Deprecated, legacy flag which is ignored."),
3713static llvm::cl::opt<bool>
3714gOptGccXml(
"gccxml", llvm::cl::desc(
"Deprecated, legacy flag which is ignored."),
3717static llvm::cl::opt<std::string>
3719 llvm::cl::desc(
"An ACLiC feature which exports the list of dependent libraries."),
3722static llvm::cl::opt<bool>
3724 llvm::cl::desc(
"Generates a pch file from a predefined set of headers. See makepch.py."),
3727static llvm::cl::opt<bool>
3728gOptC(
"c", llvm::cl::desc(
"Deprecated, legacy flag which is ignored."),
3730static llvm::cl::opt<bool>
3731gOptP(
"p", llvm::cl::desc(
"Deprecated, legacy flag which is ignored."),
3733static llvm::cl::list<std::string>
3735 llvm::cl::desc(
"Generate rootmap file."),
3737static llvm::cl::opt<std::string>
3739 llvm::cl::desc(
"Generate a rootmap file with the specified name."),
3741static llvm::cl::opt<bool>
3743 llvm::cl::desc(
"Generate a C++ module."),
3745static llvm::cl::list<std::string>
3747 llvm::cl::desc(
"Specify a C++ modulemap file."),
3750static llvm::cl::opt<bool>
3752 llvm::cl::desc(
"A single header including all headers instead of specifying them on the command line."),
3754static llvm::cl::opt<bool>
3756 llvm::cl::desc(
"If this library has multiple separate LinkDef files."),
3758static llvm::cl::opt<bool>
3760 llvm::cl::desc(
"Do not declare {using namespace std} in dictionary global scope."),
3762static llvm::cl::opt<bool>
3764 llvm::cl::desc(
"Generate minimal dictionary for interactivity (without IO information)."),
3766static llvm::cl::opt<bool>
3768 llvm::cl::desc(
"Split the dictionary into two parts: one containing the IO (ClassDef)\
3769information and another the interactivity support."),
3771static llvm::cl::opt<bool>
3774 llvm::cl::desc(
"Do not run the selection rules. Useful when in -onepcm mode."),
3776static llvm::cl::opt<std::string>
3778 llvm::cl::desc(
"The path to the library of the built dictionary."),
3780static llvm::cl::list<std::string>
3782 llvm::cl::desc(
"The list of dependent modules of the dictionary."),
3784static llvm::cl::list<std::string>
3786 llvm::cl::desc(
"Do not store the <path> in the dictionary."),
3790static llvm::cl::opt<bool>
3792 llvm::cl::desc(
"Does not generate #include <header> but expands the header content."),
3800static llvm::cl::opt<bool>
3803 llvm::cl::desc(
"Does not include the header files as it assumes they exist in the pch."),
3805static llvm::cl::opt<bool>
3807 llvm::cl::desc(
"Check the selection syntax only."),
3809static llvm::cl::opt<bool>
3811 llvm::cl::desc(
"Fail if there are warnings."),
3813static llvm::cl::opt<bool>
3815 llvm::cl::desc(
"Do not store include paths but rely on the env variable ROOT_INCLUDE_PATH."),
3817static llvm::cl::opt<std::string>
3819 llvm::cl::desc(
"Specify an isysroot."),
3821 llvm::cl::init(
"-"));
3822static llvm::cl::list<std::string>
3824 llvm::cl::desc(
"Specify an include path."),
3826static llvm::cl::list<std::string>
3828 llvm::cl::desc(
"Specify a compiler default include path, to suppress unneeded `-isystem` arguments."),
3830static llvm::cl::list<std::string>
3832 llvm::cl::desc(
"Specify a system include path."),
3834static llvm::cl::list<std::string>
3836 llvm::cl::desc(
"Specify defined macros."),
3838static llvm::cl::list<std::string>
3840 llvm::cl::desc(
"Specify undefined macros."),
3842static llvm::cl::list<std::string>
3844 llvm::cl::desc(
"Specify compiler diagnostics options."),
3847static llvm::cl::list<std::string>
3849 llvm::cl::desc(
"<list of dictionary header files> <LinkDef file>"),
3851static llvm::cl::list<std::string>
3853 llvm::cl::desc(
"Consumes all unrecognized options."),
3856static llvm::cl::SubCommand
3859static llvm::cl::list<std::string>
3861 llvm::cl::desc(
"Consumes options and sends them to cling."),
3890 for (
const std::string &header :
modGen.GetHeaders()) {
3895 clang::ConstSearchDirIterator *
CurDir =
nullptr;
3897 header, clang::SourceLocation(),
3900 clang::ArrayRef<std::pair<const clang::FileEntry *, const clang::DirectoryEntry *>>(),
3939 clang::HeaderSearch &
headerSearch =
CI->getPreprocessor().getHeaderSearchInfo();
3943 clang::Module *
module = headerSearch.lookupModule(llvm::StringRef(moduleName));
3959 msgStream <<
"after creating module \"" <<
module->Name << "\" ";
3960 if (!
module->PresumedModuleMapFile.empty())
3961 msgStream <<
"using modulemap \"" <<
module->PresumedModuleMapFile << "\" ";
3962 msgStream <<
"the following headers are not part of that module:\n";
3966 msgStream <<
" (already part of module \"" <<
H[1] <<
"\")";
3982 ROOT::TMetaUtils::Info(
"CheckModuleValid, %s. You can silence this message by adding %s to the invocation.",
3992 [](
const std::array<std::string, 2>&
HdrMod) { return HdrMod[0];});
4030 llvm::PrettyStackTraceProgram
X(
argc,
argv);
4033#if defined(R__WIN32) && !defined(R__WINGCC)
4054 auto &
opts = llvm::cl::getRegisteredOptions();
4057 llvm::cl::desc(
"Alias for -help"),
4058 llvm::cl::aliasopt(*
optHelp));
4060 llvm::cl::desc(
"Alias for -help"),
4061 llvm::cl::aliasopt(*
optHelp));
4063 llvm::cl::ParseCommandLineOptions(
argc,
argv,
"rootcling");
4084 return interp->getDiagnostics().hasFatalErrorOccurred();
4101 llvm::cl::PrintHelpMessage();
4116 if ((fp =
fopen(
filein.c_str(),
"r")) ==
nullptr) {
4144 ROOT::TMetaUtils::Error(
nullptr,
"Inconsistent set of arguments detected: overwrite of dictionary file forced but no filename specified.\n");
4145 llvm::cl::PrintHelpMessage();
4157 std::list<std::string>
diagnosticPragmas = {
"#pragma clang diagnostic ignored \"-Wdeprecated-declarations\""};
4163 if (GetErrorIgnoreLevel() >
kWarning)
4165 GetWarningsAreErrors() =
true;
4179 ROOT::TMetaUtils::Error(
"",
"Multidict requested but no target library. Please specify one with the -s argument.\n");
4213 std::vector<std::string>
pcmArgs;
4227 [&](
const std::string& path){
4228 return ROOT::TMetaUtils::BeginsWith(&thisArg[offset], path);});
4235 clingArgs.push_back(std::string(
"-I") + llvm::sys::path::convert_to_slash(
gDriverConfig->fTROOT__GetEtcDir()));
4241 clingArgs.push_back(
"-DSYSTEM_TYPE_macosx");
4242#elif defined(R__WIN32)
4243 clingArgs.push_back(
"-DSYSTEM_TYPE_winnt");
4250 clingArgs.push_back(
"-DSYSTEM_TYPE_unix");
4258 clingArgs.push_back(
"-fmodules-embed-all-files");
4322 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"_Builtin_intrinsics.pcm").str().c_str());
4323 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"_Builtin_stddef_max_align_t.pcm").str().c_str());
4324 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"Cling_Runtime.pcm").str().c_str());
4325 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"Cling_Runtime_Extra.pcm").str().c_str());
4327 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"vcruntime.pcm").str().c_str());
4328 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"services.pcm").str().c_str());
4332 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"Darwin.pcm").str().c_str());
4334 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"libc.pcm").str().c_str());
4336 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"std.pcm").str().c_str());
4337 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"boost.pcm").str().c_str());
4338 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"tinyxml2.pcm").str().c_str());
4339 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"ROOT_Config.pcm").str().c_str());
4340 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"ROOT_Rtypes.pcm").str().c_str());
4341 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"ROOT_Foundation_C.pcm").str().c_str());
4342 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"ROOT_Foundation_Stage1_NoRTTI.pcm").str().c_str());
4344 remove((
moduleCachePath + llvm::sys::path::get_separator() +
"Vc.pcm").str().c_str());
4359 std::cerr <<
"Argument \""<<
clingArg <<
"\" is not a supported cling argument. "
4360 <<
"This could be mistyped rootcling argument. Please check the commandline.\n";
4368 cling::Interpreter*
interpPtr =
nullptr;
4394 clang::CompilerInstance *
CI =
interp.getCI();
4396 CI->getFrontendOpts().ModulesEmbedAllFiles =
true;
4397 CI->getSourceManager().setAllFilesAreTransient(
true);
4399 clang::Preprocessor &
PP =
CI->getPreprocessor();
4409 diags.setSeverity(clang::diag::remark_module_build, clang::diag::Severity::Remark, clang::SourceLocation());
4420 interp.DumpIncludePath();
4425 interp.printIncludedFiles(llvm::outs());
4426 llvm::outs() <<
"\n\n";
4427 llvm::outs().flush();
4431 =
interp.getCI()->getASTContext().getLangOpts();
4432#define LANGOPT(Name, Bits, Default, Description) \
4433 ROOT::TMetaUtils::Info(nullptr, "%s = %d // %s\n", #Name, (int)LangOpts.Name, Description);
4434#define ENUM_LANGOPT(Name, Type, Bits, Default, Description)
4435#include "clang/Basic/LangOptions.def"
4439 interp.getOptions().ErrorOut =
true;
4440 interp.enableRawInput(
true);
4444 if (
DepMod.endswith(
"_rdict.pcm")) {
4451 cling::Interpreter::PushTransactionRAII
RAII(&
interp);
4461 if (
interp.declare(
"#include <assert.h>\n"
4462 "#include \"Rtypes.h\"\n"
4463 "#include \"TObject.h\"") != cling::Interpreter::kSuccess
4471 if (
interp.declare(
"#include <string>\n"
4472 "#include <RtypesCore.h>\n"
4473 "namespace std {} using namespace std;") != cling::Interpreter::kSuccess) {
4569 std::stringstream res;
4570 const char*
delim=
"\n";
4573 std::ostream_iterator<std::string>(res,
delim));
4574 if (
interp.declare(res.str()) != cling::Interpreter::kSuccess) {
4583 clang::PragmaNamespace(
pragma) {}
4584 void HandlePragma(clang::Preprocessor &
PP,
4586 clang::Token &
tok)
override {
4587 PP.DiscardUntilEndOfDirective();
4674 if (
dh != std::string::npos) {
4738 if (file.is_open()) {
4751 clingArgs.push_back(
"-Ietc/cling/cint");
4771 if (file.is_open()) {
4812 <<
"#include \"TVirtualObject.h\"\n"
4813 <<
"#include <vector>\n"
4814 <<
"#include \"TSchemaHelper.h\"\n\n";
4854 scan.
Scan(
CI->getASTContext());
4877 if (
annRcd.RequestNoInputOperator()) {
5050 [](
const std::string &
a,
const std::string &
b) -> std::string {
5051 if (a.empty()) return b;
5052 else return a +
" " + b;
5082 std::list<std::string>
nsNames;
5125 cling::Interpreter::PushTransactionRAII
RAII(&
interp);
5126 CI->getSema().getASTConsumer().HandleTranslationUnit(
CI->getSema().getASTContext());
5162 "*** genreflex: %s is not a valid header name (.h and .hpp extensions expected)!\n",
5176 for (
int i = 1; i <
argc; ++i) {
5179 args.push_back(
argv[i]);
5189 std::cout <<
"Args: \n";
5190 for (std::vector<std::string>::iterator it = args.begin();
5191 it < args.end(); ++it) {
5192 std::cout << i <<
") " << *it << std::endl;
5206 if (std::string::npos !=
result) {
5218 const unsigned int size(str.size());
5219 char *
a =
new char[
size + 1];
5253 const std::string &
optName =
"")
5265 const std::string &
optName =
"")
5282 const std::vector<std::string> &
pcmsNames,
5283 const std::vector<std::string> &
includes,
5286 const std::vector<std::string> &
warnings,
5323 "*** genreflex: No rootmap lib and several header specified!\n");
5411 std::cout <<
"Rootcling commandline:\n";
5412 for (
int i = 0; i <
argc; i++)
5413 std::cout << i <<
") " <<
argvVector[i] << std::endl;
5421 for (
int i = 0; i <
argc; i++)
5436 const std::vector<std::string> &
pcmsNames,
5437 const std::vector<std::string> &
includes,
5440 const std::vector<std::string> &
warnings,
5464 for (
unsigned int i = 0; i <
headersNames.size(); ++i) {
5505 std::vector<std::string> &values)
5510 values.reserve(
nVals);
5515 << opt->arg << std::endl;
5517 values.push_back(opt->arg);
5532 "*** genereflex: %s is not supported anymore.\n",
5624 "Generates dictionary sources and related ROOT pcm starting from an header.\n"
5625 "Usage: genreflex headerfile.h [opts] [preproc. opts]\n\n"
5629 "-s, --selection_file\tSelection filename\n"
5630 " Class selection file to specify for which classes the dictionary\n"
5631 " will be generated. The final set can be crafted with exclusion and\n"
5632 " exclusion rules.\n"
5633 " Properties can be specified. Some have special meaning:\n"
5634 " - name [string] name of the entity to select with an exact matching\n"
5635 " - pattern [string] name with wildcards (*) to select entities\n"
5636 " - file_name/file_pattern [string]: as name/pattern but referring to\n"
5637 " file where the C++ entities reside and not to C++ entities themselves.\n"
5638 " - transient/persistent [string: true/false] The fields to which they are\n"
5639 " applied will not be persistified if requested.\n"
5640 " - comment [string]: what you could write in code after an inline comment\n"
5641 " without \"//\". For example comment=\"!\" or \"||\".\n"
5642 " - noStreamer [true/false]: turns off streamer generation if set to 'true.'\n"
5643 " Default value is 'false'\n"
5644 " - noInputOperator [true/false]: turns off input operator generation if set\n"
5645 " to 'true'. Default value is 'false'\n"
5649 " <class [name=\"classname\"] [pattern=\"wildname\"]\n"
5650 " [file_name=\"filename\"] [file_pattern=\"wildname\"]\n"
5651 " [id=\"xxxx\"] [noStreamer=\"true/false\"]\n"
5652 " [noInputOperator=\"true/false\"] />\n"
5653 " <class name=\"classname\" >\n"
5654 " <field name=\"m_transient\" transient=\"true\"/>\n"
5655 " <field name=\"m_anothertransient\" persistent=\"false\"/>\n"
5656 " <field name=\"m_anothertransient\" comment=\"||\"/>\n"
5657 " <properties prop1=\"value1\" [prop2=\"value2\"]/>\n"
5659 " <function [name=\"funcname\"] [pattern=\"wildname\"] />\n"
5660 " <enum [name=\"enumname\"] [pattern=\"wildname\"] />\n"
5661 " <variable [name=\"varname\"] [pattern=\"wildname\"] />\n"
5664 " <class [name=\"classname\"] [pattern=\"wildname\"] />\n"
5665 " <method name=\"unwanted\" />\n"
5670 " If no selection file is specified, the class with the filename without\n"
5671 " extension will be selected, i.e. myClass.h as argument without any\n"
5672 " selection xml comes with an implicit selection rule for class \"myClass\".\n";
5675 "-o, --output\tOutput filename\n"
5676 " Output file name. If an existing directory is specified instead of a file,\n"
5677 " then a filename will be built using the name of the input file and will\n"
5678 " be placed in the given directory. <headerfile>_rflx.cpp.\n"
5679 " NOTA BENE: the dictionaries that will be used within the same project must\n"
5680 " have unique names.\n";
5684 "-l, --library\tTarget library\n"
5685 " The flag -l must be followed by the name of the library that will\n"
5686 " contain the object file corresponding to the dictionary produced by\n"
5687 " this invocation of genreflex.\n"
5688 " The name takes priority over the one specified for the rootmapfile.\n"
5689 " The name influences the name of the created pcm:\n"
5690 " 1) If it is not specified, the pcm is called libINPUTHEADER_rdict.pcm\n"
5691 " 2) If it is specified, the pcm is called libTARGETLIBRARY_rdict.pcm\n"
5692 " Any \"liblib\" occurence is transformed in the expected \"lib\".\n"
5693 " 3) If this is specified in conjunction with --multiDict, the output is\n"
5694 " libTARGETLIBRARY_DICTIONARY_rdict.pcm\n";
5697 "--rootmap\tGenerate the rootmap file to be used by ROOT.\n"
5698 " This file lists the autoload keys. For example classes for which the\n"
5699 " reflection information is provided.\n"
5700 " The format of the rootmap is the following:\n"
5701 " - Forward declarations section\n"
5702 " - Libraries sections\n"
5703 " Rootmaps can be concatenated together, for example with the cat util.\n"
5704 " In order for ROOT to pick up the information in the rootmaps, they\n"
5705 " have to be located in the library path and have the .rootmap extension.\n"
5706 " An example rootmap file could be:\n"
5708 " template <class T> class A;\n"
5709 " [ libMyLib.so ]\n"
5710 " class A<double>\n"
5716 "--rootmap-lib\tLibrary name for the rootmap file.\n";
5749 "--multiDict\tSupport for many dictionaries in one library\n"
5750 " Form correct pcm names if multiple dictionaries will be in the same\n"
5751 " library (needs target library switch. See its documentation).\n"
5758 "" ,
"noGlobalUsingStd" ,
5760 "--noGlobalUsingStd\tDo not declare {using namespace std} in the dictionary global scope\n"
5761 " All header files must have sumbols from std:: namespace fully qualified\n"
5767 "s" ,
"selection_file" ,
5783 "" ,
"rootmap-lib" ,
5791 "" ,
"interpreteronly",
5793 "--interpreteronly\tDo not generate I/O related information.\n"
5794 " Generate minimal dictionary required for interactivity.\n"
5802 "--split\tSplit the dictionary\n"
5803 " Split in two the dictionary, isolating the part with\n"
5804 " ClassDef related functions in a separate file.\n"
5812 "-m \tPcm file loaded before any header (option can be repeated).\n"
5820 "-v, --verbose\tPrint some debug information.\n"
5828 "--debug\tPrint all debug information.\n"
5836 "--quiet\tPrint only warnings and errors (default).\n"
5844 "--silent\tPrint no information at all.\n"
5850 "" ,
"writeEmptyPCM",
5852 "--writeEmptyPCM\tWrite an empty ROOT pcm.\n"
5860 "--cxxmodule\tGenerates a PCM for C++ Modules.\n"
5869 "--help\tPrint usage and exit.\n"
5875 "",
"fail_on_warnings",
5877 "--fail_on_warnings\tFail on warnings and errors.\n"
5883 "",
"selSyntaxOnly",
5885 "--selSyntaxOnly\tValidate selection file w/o generating the dictionary.\n"
5891 "" ,
"noIncludePaths",
5893 "--noIncludePaths\tDo not store the headers' directories in the dictionary. Instead, rely on the environment variable $ROOT_INCLUDE_PATH at runtime.\n"
5932 "" ,
"no_membertypedefs" ,
5940 "" ,
"no_templatetypedefs" ,
5945 {0, 0,
nullptr,
nullptr,
nullptr,
nullptr}
5959 std::vector<ROOT::option::Option> options(
stats.options_max);
5960 std::vector<ROOT::option::Option> buffer(
stats.buffer_max);
5966 if (parse.
error()) {
6002 "Invalid selection file extension: filename is %s and extension .xml is expected!\n",
6027 "Invalid target library extension: filename is %s and extension %s is expected!\n",
6047 "Multilib support is requested but no target lib is specified. A sane pcm name cannot be formed.\n");
6193 if (std::string::npos !=
exeName.find(
"genreflex"))
6201 ROOT::TMetaUtils::Info(
nullptr,
"Problems have been detected during the generation of the dictionary.\n");
Select classes and assign properties using C++ syntax.
The file contains utilities which are foundational and could be used across the core component of ROO...
This is the only file required to use The Lean Mean C++ Option Parser.
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t dest
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t attr
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
std::unordered_map< std::string, std::string > AttributesMap_t
Custom diag client for clang that verifies that each implicitly build module is a system module.
CheckModuleBuildClient(clang::DiagnosticConsumer *Child, bool OwnsChild, clang::ModuleMap &Map)
clang::DiagnosticConsumer * fChild
~CheckModuleBuildClient()
virtual void BeginSourceFile(const clang::LangOptions &LangOpts, const clang::Preprocessor *PP) override
virtual void finish() override
virtual void HandleDiagnostic(clang::DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &Info) override
virtual void clear() override
virtual bool IncludeInDiagnosticCounts() const override
virtual void EndSourceFile() override
const_iterator begin() const
const_iterator end() const
A parsed option from the command line together with its argument if it has one.
Checks argument vectors for validity and parses them into data structures that are easier to work wit...
bool error()
Returns true if an unrecoverable error occurred while parsing options.
void Scan(const clang::ASTContext &C)
std::vector< ROOT::TMetaUtils::AnnotatedRecordDecl > ClassColl_t
const DeclsSelRulesMap_t & GetDeclsSelRulesMap() const
FunctionColl_t fSelectedFunctions
std::vector< const clang::FunctionDecl * > FunctionColl_t
NamespaceColl_t fSelectedNamespaces
TypedefColl_t fSelectedTypedefs
DeclCallback SetRecordDeclCallback(DeclCallback callback)
Set the callback to the RecordDecl and return the previous one.
std::map< const clang::Decl *, const BaseSelectionRule * > DeclsSelRulesMap_t
EnumColl_t fSelectedEnums
std::vector< const clang::TypedefNameDecl * > TypedefColl_t
std::vector< const clang::VarDecl * > VariableColl_t
static bool GetDeclQualName(const clang::Decl *D, std::string &qual_name)
VariableColl_t fSelectedVariables
std::vector< const clang::EnumDecl * > EnumColl_t
ClassColl_t fSelectedClasses
The class representing the collection of selection rules.
void InclusionDirective(clang::SourceLocation, const clang::Token &, llvm::StringRef FileName, bool IsAngled, clang::CharSourceRange, clang::OptionalFileEntryRef, llvm::StringRef, llvm::StringRef, const clang::Module *, clang::SrcMgr::CharacteristicKind) override
std::list< std::string > & fFilesIncludedByLinkdef
void EnteredSubmodule(clang::Module *M, clang::SourceLocation ImportLoc, bool ForPragma) override
TRootClingCallbacks(cling::Interpreter *interp, std::list< std::string > &filesIncludedByLinkdef)
Little helper class to bookkeep the files names which we want to make temporary.
void addFileName(std::string &nameStr)
Adds the name and the associated temp name to the catalog.
const std::string & getFileName(const std::string &tmpFileName)
std::vector< std::string > m_names
std::vector< std::string > m_tempNames
const std::string m_emptyString
std::string getTmpFileName(const std::string &filename)
static bool FromCygToNativePath(std::string &path)
std::string GetCurrentDir()
std::string MakePathRelative(const std::string &path, const std::string &base, bool isBuildingROOT=false)
void printUsage(OStream &prn, const Descriptor usage[], int width=80, int last_column_min_percent=50, int last_column_own_line_max_percent=75)
Outputs a nicely formatted usage string with support for multi-column formatting and line-wrapping.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
R__EXTERN SchemaRuleClassMap_t gReadRules
void GetRuleIncludes(std::list< std::string > &result)
Get the list of includes specified in the shema rules.
R__EXTERN SchemaRuleClassMap_t gReadRawRules
ROOT::ESTLType STLKind(std::string_view type)
Converts STL container name to number.
void Init(TClassEdit::TInterpreterLookupHelper *helper)
void header2outputName(std::string &fileName)
Replace the extension with "_rflx.cpp".
void AddToArgVectorSplit(std::vector< char * > &argvVector, const std::vector< std::string > &argsToBeAdded, const std::string &optName="")
void changeExtension(std::string &filename, const std::string &newExtension)
int invokeRootCling(const std::string &verbosity, const std::string &selectionFileName, const std::string &targetLibName, bool multiDict, const std::vector< std::string > &pcmsNames, const std::vector< std::string > &includes, const std::vector< std::string > &preprocDefines, const std::vector< std::string > &preprocUndefines, const std::vector< std::string > &warnings, const std::string &rootmapFileName, const std::string &rootmapLibName, bool interpreteronly, bool doSplit, bool isCxxmodule, bool writeEmptyRootPCM, bool selSyntaxOnly, bool noIncludePaths, bool noGlobalUsingStd, const std::vector< std::string > &headersNames, bool failOnWarnings, const std::string &ofilename)
int invokeManyRootCling(const std::string &verbosity, const std::string &selectionFileName, const std::string &targetLibName, bool multiDict, const std::vector< std::string > &pcmsNames, const std::vector< std::string > &includes, const std::vector< std::string > &preprocDefines, const std::vector< std::string > &preprocUndefines, const std::vector< std::string > &warnings, const std::string &rootmapFileName, const std::string &rootmapLibName, bool interpreteronly, bool doSplit, bool isCxxmodule, bool writeEmptyRootPCM, bool selSyntaxOnly, bool noIncludePaths, bool noGlobalUsingStd, const std::vector< std::string > &headersNames, bool failOnWarnings, const std::string &outputDirName_const="")
Get the right ofilenames and invoke several times rootcling One invokation per header.
unsigned int checkHeadersNames(std::vector< std::string > &headersNames)
Loop on arguments: stop at the first which starts with -.
void headers2outputsNames(const std::vector< std::string > &headersNames, std::vector< std::string > &ofilesnames)
Get a proper name for the output file.
char * string2charptr(const std::string &str)
The caller is responsible for deleting the string!
unsigned int extractArgs(int argc, char **argv, std::vector< std::string > &args)
Extract the arguments from the command line.
void AddToArgVector(std::vector< char * > &argvVector, const std::vector< std::string > &argsToBeAdded, const std::string &optName="")
int FinalizeStreamerInfoWriting(cling::Interpreter &interp, bool writeEmptyRootPCM=false)
Make up for skipping RegisterModule, now that dictionary parsing is done and these headers cannot be ...
std::list< std::string > CollapseIdenticalNamespaces(const std::list< std::string > &fwdDeclarationsList)
If two identical namespaces are there, just declare one only Example: namespace A { namespace B { fwd...
static llvm::cl::opt< bool > gOptC("c", llvm::cl::desc("Deprecated, legacy flag which is ignored."), llvm::cl::cat(gRootclingOptions))
void RiseWarningIfPresent(std::vector< ROOT::option::Option > &options, int optionIndex, const char *descriptor)
int RootClingMain(int argc, char **argv, bool isGenreflex=false)
static llvm::StringRef GetModuleNameFromRdictName(llvm::StringRef rdictName)
static llvm::cl::opt< bool > gOptGccXml("gccxml", llvm::cl::desc("Deprecated, legacy flag which is ignored."), llvm::cl::Hidden, llvm::cl::cat(gRootclingOptions))
static llvm::cl::opt< std::string > gOptISysRoot("isysroot", llvm::cl::Prefix, llvm::cl::Hidden, llvm::cl::desc("Specify an isysroot."), llvm::cl::cat(gRootclingOptions), llvm::cl::init("-"))
int STLContainerStreamer(const clang::FieldDecl &m, int rwmode, const cling::Interpreter &interp, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt, std::ostream &dictStream)
Create Streamer code for an STL container.
std::string ExtractFileName(const std::string &path)
Extract the filename from a fullpath.
static llvm::cl::opt< bool > gOptRootBuild("rootbuild", llvm::cl::desc("If we are building ROOT."), llvm::cl::Hidden, llvm::cl::cat(gRootclingOptions))
bool IsImplementationName(const std::string &filename)
const std::string gLibraryExtension(".so")
static llvm::cl::list< std::string > gOptSink(llvm::cl::ZeroOrMore, llvm::cl::Sink, llvm::cl::desc("Consumes all unrecognized options."), llvm::cl::cat(gRootclingOptions))
int GenReflexMain(int argc, char **argv)
Translate the arguments of genreflex into rootcling ones and forward them to the RootCling function.
static void MaybeSuppressWin32CrashDialogs()
void RecordDeclCallback(const clang::RecordDecl *recordDecl)
void CheckClassNameForRootMap(const std::string &classname, map< string, string > &autoloads)
bool Which(cling::Interpreter &interp, const char *fname, string &pname)
Find file name in path specified via -I statements to Cling.
void AdjustRootMapNames(std::string &rootmapFileName, std::string &rootmapLibName)
void AddNamespaceSTDdeclaration(std::ostream &dictStream)
static llvm::cl::list< std::string > gOptWDiags("W", llvm::cl::Prefix, llvm::cl::ZeroOrMore, llvm::cl::desc("Specify compiler diagnostics options."), llvm::cl::cat(gRootclingOptions))
static llvm::cl::opt< bool > gOptCint("cint", llvm::cl::desc("Deprecated, legacy flag which is ignored."), llvm::cl::Hidden, llvm::cl::cat(gRootclingOptions))
static llvm::cl::list< std::string > gOptModuleByproducts("mByproduct", llvm::cl::ZeroOrMore, llvm::cl::Hidden, llvm::cl::desc("The list of the expected implicit modules build as part of building the current module."), llvm::cl::cat(gRootclingOptions))
map< string, string > gAutoloads
static llvm::cl::opt< bool > gOptCheckSelectionSyntax("selSyntaxOnly", llvm::cl::desc("Check the selection syntax only."), llvm::cl::cat(gRootclingOptions))
static bool CheckModuleValid(TModuleGenerator &modGen, const std::string &resourceDir, cling::Interpreter &interpreter, llvm::StringRef LinkdefPath, const std::string &moduleName)
Check moduleName validity from modulemap. Check if this module is defined or not.
static void CheckForMinusW(std::string arg, std::list< std::string > &diagnosticPragmas)
Transform -W statements in diagnostic pragmas for cling reacting on "-Wno-" For example -Wno-deprecat...
static bool WriteAST(llvm::StringRef fileName, clang::CompilerInstance *compilerInstance, llvm::StringRef iSysRoot, clang::Module *module=nullptr)
Write the AST of the given CompilerInstance to the given File while respecting the given isysroot.
static llvm::cl::opt< bool > gOptUmbrellaInput("umbrellaHeader", llvm::cl::desc("A single header including all headers instead of specifying them on the command line."), llvm::cl::cat(gRootclingOptions))
void ExtractFilePath(const std::string &path, std::string &dirname)
Extract the path from a fullpath finding the last \ or / according to the content in gPathSeparator.
int STLStringStreamer(const clang::FieldDecl &m, int rwmode, std::ostream &dictStream)
Create Streamer code for a standard string object.
void CreateDictHeader(std::ostream &dictStream, const std::string &main_dictname)
const char * GetExePath()
Returns the executable path name, used e.g. by SetRootSys().
const std::string gPathSeparator(ROOT::TMetaUtils::GetPathSeparator())
static llvm::cl::list< std::string > gOptBareClingSink(llvm::cl::OneOrMore, llvm::cl::Sink, llvm::cl::desc("Consumes options and sends them to cling."), llvm::cl::cat(gRootclingOptions), llvm::cl::sub(gBareClingSubcommand))
bool InheritsFromTObject(const clang::RecordDecl *cl, const cling::Interpreter &interp)
static bool InjectModuleUtilHeader(const char *argv0, TModuleGenerator &modGen, cling::Interpreter &interp, bool umbrella)
Write the extra header injected into the module: umbrella header if (umbrella) else content header.
static llvm::cl::list< std::string > gOptModuleMapFiles("moduleMapFile", llvm::cl::desc("Specify a C++ modulemap file."), llvm::cl::cat(gRootclingOptions))
int ExtractClassesListAndDeclLines(RScanner &scan, std::list< std::string > &classesList, std::list< std::string > &classesListForRootmap, std::list< std::string > &fwdDeclarationsList, const cling::Interpreter &interpreter)
void ParseRootMapFileNewFormat(ifstream &file, map< string, string > &autoloads)
Parse the rootmap and add entries to the autoload map, using the new format.
static llvm::cl::OptionCategory gRootclingOptions("rootcling common options")
static llvm::cl::list< std::string > gOptSysIncludePaths("isystem", llvm::cl::ZeroOrMore, llvm::cl::desc("Specify a system include path."), llvm::cl::cat(gRootclingOptions))
void ExtractHeadersForDecls(const RScanner::ClassColl_t &annotatedRcds, const RScanner::TypedefColl_t tDefDecls, const RScanner::FunctionColl_t funcDecls, const RScanner::VariableColl_t varDecls, const RScanner::EnumColl_t enumDecls, HeadersDeclsMap_t &headersClassesMap, HeadersDeclsMap_t &headersDeclsMap, const cling::Interpreter &interp)
bool ParsePragmaLine(const std::string &line, const char *expectedTokens[], size_t *end=nullptr)
Check whether the #pragma line contains expectedTokens (0-terminated array).
static llvm::cl::opt< bool > gOptWriteEmptyRootPCM("writeEmptyRootPCM", llvm::cl::Hidden, llvm::cl::desc("Does not include the header files as it assumes they exist in the pch."), llvm::cl::cat(gRootclingOptions))
static llvm::cl::opt< bool > gOptGeneratePCH("generate-pch", llvm::cl::desc("Generates a pch file from a predefined set of headers. See makepch.py."), llvm::cl::Hidden, llvm::cl::cat(gRootclingOptions))
static bool ModuleContainsHeaders(TModuleGenerator &modGen, clang::HeaderSearch &headerSearch, clang::Module *module, std::vector< std::array< std::string, 2 > > &missingHeaders)
Returns true iff a given module (and its submodules) contains all headers needed by the given ModuleG...
static bool GenerateAllDict(TModuleGenerator &modGen, clang::CompilerInstance *compilerInstance, const std::string ¤tDirectory)
Generates a PCH from the given ModuleGenerator and CompilerInstance.
void LoadLibraryMap(const std::string &fileListName, map< string, string > &autoloads)
Fill the map of libraries to be loaded in presence of a class Transparently support the old and new r...
std::ostream * CreateStreamPtrForSplitDict(const std::string &dictpathname, tempFileNamesCatalog &tmpCatalog)
Transform name of dictionary.
void WriteNamespaceInit(const clang::NamespaceDecl *cl, cling::Interpreter &interp, std::ostream &dictStream)
Write the code to initialize the namespace name and the initialization object.
static llvm::cl::list< std::string > gOptCompDefaultIncludePaths("compilerI", llvm::cl::Prefix, llvm::cl::ZeroOrMore, llvm::cl::desc("Specify a compiler default include path, to suppress unneeded `-isystem` arguments."), llvm::cl::cat(gRootclingOptions))
void AnnotateAllDeclsForPCH(cling::Interpreter &interp, RScanner &scan)
We need annotations even in the PCH: // !, // || etc.
size_t GetFullArrayLength(const clang::ConstantArrayType *arrayType)
static llvm::cl::opt< bool > gOptSplit("split", llvm::cl::desc("Split the dictionary into two parts: one containing the IO (ClassDef)\
information and another the interactivity support."), llvm::cl::cat(gRootclingOptions))
bool ProcessAndAppendIfNotThere(const std::string &el, std::list< std::string > &el_list, std::unordered_set< std::string > &el_set)
Separate multiline strings.
static llvm::cl::opt< bool > gOptNoGlobalUsingStd("noGlobalUsingStd", llvm::cl::desc("Do not declare {using namespace std} in dictionary global scope."), llvm::cl::cat(gRootclingOptions))
const ROOT::Internal::RootCling::DriverConfig * gDriverConfig
static llvm::cl::list< std::string > gOptModuleDependencies("m", llvm::cl::desc("The list of dependent modules of the dictionary."), llvm::cl::cat(gRootclingOptions))
static llvm::cl::SubCommand gBareClingSubcommand("bare-cling", "Call directly cling and exit.")
static llvm::cl::opt< bool > gOptInterpreterOnly("interpreteronly", llvm::cl::desc("Generate minimal dictionary for interactivity (without IO information)."), llvm::cl::cat(gRootclingOptions))
void WriteArrayDimensions(const clang::QualType &type, std::ostream &dictStream)
Write "[0]" for all but the 1st dimension.
void GetMostExternalEnclosingClassName(const clang::DeclContext &theContext, std::string &ctxtName, const cling::Interpreter &interpreter, bool treatParent=true)
Extract the proper autoload key for nested classes The routine does not erase the name,...
std::string GetFwdDeclnArgsToKeepString(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt, cling::Interpreter &interp)
int ExtractAutoloadKeys(std::list< std::string > &names, const COLL &decls, const cling::Interpreter &interp)
static llvm::cl::opt< std::string > gOptSharedLibFileName("s", llvm::cl::desc("The path to the library of the built dictionary."), llvm::cl::cat(gRootclingOptions))
void WriteStreamer(const ROOT::TMetaUtils::AnnotatedRecordDecl &cl, const cling::Interpreter &interp, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt, std::ostream &dictStream)
bool IsGoodForAutoParseMap(const clang::RecordDecl &rcd)
Check if the class good for being an autoparse key.
std::map< std::string, std::list< std::string > > HeadersDeclsMap_t
#define rootclingStringify(s)
void GetMostExternalEnclosingClassNameFromDecl(const clang::Decl &theDecl, std::string &ctxtName, const cling::Interpreter &interpreter)
static llvm::cl::opt< bool > gOptP("p", llvm::cl::desc("Deprecated, legacy flag which is ignored."), llvm::cl::cat(gRootclingOptions))
static llvm::cl::list< std::string > gOptDictionaryHeaderFiles(llvm::cl::Positional, llvm::cl::ZeroOrMore, llvm::cl::desc("<list of dictionary header files> <LinkDef file>"), llvm::cl::cat(gRootclingOptions))
void SetRootSys()
Set the ROOTSYS env var based on the executable location.
bool CheckInputOperator(const char *what, const char *proto, const string &fullname, const clang::RecordDecl *cl, cling::Interpreter &interp)
Check if the specified operator (what) has been properly declared if the user has requested a custom ...
void GenerateNecessaryIncludes(std::ostream &dictStream, const std::string &includeForSource, const std::string &extraIncludes)
void StrcpyArg(string &dest, const char *original)
Copy the command line argument, stripping MODULE/inc if necessary.
static llvm::cl::list< std::string > gOptRootmapLibNames("rml", llvm::cl::ZeroOrMore, llvm::cl::desc("Generate rootmap file."), llvm::cl::cat(gRootclingOptions))
void ParseRootMapFile(ifstream &file, map< string, string > &autoloads)
Parse the rootmap and add entries to the autoload map.
static llvm::cl::opt< bool > gOptCxxModule("cxxmodule", llvm::cl::desc("Generate a C++ module."), llvm::cl::cat(gRootclingOptions))
std::pair< std::string, std::string > GetExternalNamespaceAndContainedEntities(const std::string line)
Performance is not critical here.
void AddPlatformDefines(std::vector< std::string > &clingArgs)
static std::string GenerateFwdDeclString(const RScanner &scan, const cling::Interpreter &interp)
Generate the fwd declarations of the selected entities.
static llvm::cl::opt< bool > gOptFailOnWarnings("failOnWarnings", llvm::cl::desc("Fail if there are warnings."), llvm::cl::cat(gRootclingOptions))
const char * CopyArg(const char *original)
If the argument starts with MODULE/inc, strip it to make it the name we can use in #includes.
string GetNonConstMemberName(const clang::FieldDecl &m, const string &prefix="")
Return the name of the data member so that it can be used by non-const operation (so it includes a co...
static llvm::cl::list< std::string > gOptIncludePaths("I", llvm::cl::Prefix, llvm::cl::ZeroOrMore, llvm::cl::desc("Specify an include path."), llvm::cl::cat(gRootclingOptions))
void WriteAutoStreamer(const ROOT::TMetaUtils::AnnotatedRecordDecl &cl, const cling::Interpreter &interp, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt, std::ostream &dictStream)
void ExtractSelectedNamespaces(RScanner &scan, std::list< std::string > &nsList)
Loop on selected classes and put them in a list.
static bool IncludeHeaders(const std::vector< std::string > &headers, cling::Interpreter &interpreter)
Includes all given headers in the interpreter.
clang::QualType GetPointeeTypeIfPossible(const clang::QualType &qt)
Get the pointee type if possible.
void AnnotateDecl(clang::CXXRecordDecl &CXXRD, const RScanner::DeclsSelRulesMap_t &declSelRulesMap, cling::Interpreter &interpreter, bool isGenreflex)
static llvm::cl::opt< VerboseLevel > gOptVerboseLevel(llvm::cl::desc("Choose verbosity level:"), llvm::cl::values(clEnumVal(v, "Show errors."), clEnumVal(v0, "Show only fatal errors."), clEnumVal(v1, "Show errors (the same as -v)."), clEnumVal(v2, "Show warnings (default)."), clEnumVal(v3, "Show notes."), clEnumVal(v4, "Show information.")), llvm::cl::init(v2), llvm::cl::cat(gRootclingOptions))
void GenerateLinkdef(llvm::cl::list< std::string > &InputFiles, std::string &code_for_parser)
static llvm::cl::opt< std::string > gOptRootMapFileName("rmf", llvm::cl::desc("Generate a rootmap file with the specified name."), llvm::cl::cat(gRootclingOptions))
static llvm::cl::opt< bool > gOptInlineInput("inlineInputHeader", llvm::cl::desc("Does not generate #include <header> but expands the header content."), llvm::cl::cat(gRootclingOptions))
bool isPointerToPointer(const clang::FieldDecl &m)
int CreateNewRootMapFile(const std::string &rootmapFileName, const std::string &rootmapLibName, const std::list< std::string > &classesDefsList, const std::list< std::string > &classesNames, const std::list< std::string > &nsNames, const std::list< std::string > &tdNames, const std::list< std::string > &enNames, const std::list< std::string > &varNames, const HeadersDeclsMap_t &headersClassesMap, const std::unordered_set< std::string > headersToIgnore)
Generate a rootmap file in the new format, like { decls } namespace A { namespace B { template <typen...
static llvm::cl::opt< std::string > gOptDictionaryFileName(llvm::cl::Positional, llvm::cl::desc("<output dictionary file>"), llvm::cl::cat(gRootclingOptions))
bool IsSelectionXml(const char *filename)
bool IsGoodLibraryName(const std::string &name)
static llvm::cl::opt< bool > gOptReflex("reflex", llvm::cl::desc("Deprecated, legacy flag which is ignored."), llvm::cl::Hidden, llvm::cl::cat(gRootclingOptions))
llvm::StringRef GrabIndex(const cling::Interpreter &interp, const clang::FieldDecl &member, int printError)
GrabIndex returns a static string (so use it or copy it immediately, do not call GrabIndex twice in t...
static llvm::cl::opt< bool > gOptMultiDict("multiDict", llvm::cl::desc("If this library has multiple separate LinkDef files."), llvm::cl::cat(gRootclingOptions))
bool IsSelectionFile(const char *filename)
const std::string GenerateStringFromHeadersForClasses(const HeadersDeclsMap_t &headersClassesMap, const std::string &detectedUmbrella, bool payLoadOnly=false)
Generate a string for the dictionary from the headers-classes map.
bool IsSupportedClassName(const char *name)
static llvm::cl::opt< bool > gOptIgnoreExistingDict("r", llvm::cl::desc("Deprecated. Similar to -f but it ignores the dictionary generation. \
When -r is present rootcling becomes a tool to generate rootmaps (and capability files)."), llvm::cl::Hidden, llvm::cl::cat(gRootclingOptions))
static llvm::cl::opt< bool > gOptForce("f", llvm::cl::desc("Overwrite <file>s."), llvm::cl::cat(gRootclingOptions))
static void AnnotateFieldDecl(clang::FieldDecl &decl, const std::list< VariableSelectionRule > &fieldSelRules)
void CallWriteStreamer(const ROOT::TMetaUtils::AnnotatedRecordDecl &cl, const cling::Interpreter &interp, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt, std::ostream &dictStream, bool isAutoStreamer)
static llvm::cl::list< std::string > gOptPPUndefines("U", llvm::cl::Prefix, llvm::cl::ZeroOrMore, llvm::cl::desc("Specify undefined macros."), llvm::cl::cat(gRootclingOptions))
int CheckClassesForInterpreterOnlyDicts(cling::Interpreter &interp, RScanner &scan)
bool InheritsFromTSelector(const clang::RecordDecl *cl, const cling::Interpreter &interp)
static void EmitTypedefs(const std::vector< const clang::TypedefNameDecl * > &tdvec)
bool Namespace__HasMethod(const clang::NamespaceDecl *cl, const char *name, const cling::Interpreter &interp)
static llvm::cl::list< std::string > gOptPPDefines("D", llvm::cl::Prefix, llvm::cl::ZeroOrMore, llvm::cl::desc("Specify defined macros."), llvm::cl::cat(gRootclingOptions))
bool IsCorrectClingArgument(const std::string &argument)
Check if the argument is a sane cling argument.
bool IsLinkdefFile(const clang::PresumedLoc &PLoc)
void WriteClassFunctions(const clang::CXXRecordDecl *cl, std::ostream &dictStream, bool autoLoad=false)
Write the code to set the class name and the initialization object.
static llvm::cl::list< std::string > gOptExcludePaths("excludePath", llvm::cl::ZeroOrMore, llvm::cl::desc("Do not store the <path> in the dictionary."), llvm::cl::cat(gRootclingOptions))
std::list< std::string > RecordDecl2Headers(const clang::CXXRecordDecl &rcd, const cling::Interpreter &interp, std::set< const clang::CXXRecordDecl * > &visitedDecls)
Extract the list of headers necessary for the Decl.
void EmitStreamerInfo(const char *normName)
static llvm::cl::opt< bool > gOptNoIncludePaths("noIncludePaths", llvm::cl::desc("Do not store include paths but rely on the env variable ROOT_INCLUDE_PATH."), llvm::cl::cat(gRootclingOptions))
bool HasPath(const std::string &name)
Check if file has a path.
static llvm::cl::opt< std::string > gOptLibListPrefix("lib-list-prefix", llvm::cl::desc("An ACLiC feature which exports the list of dependent libraries."), llvm::cl::Hidden, llvm::cl::cat(gRootclingOptions))
static llvm::cl::opt< bool > gOptNoDictSelection("noDictSelection", llvm::cl::Hidden, llvm::cl::desc("Do not run the selection rules. Useful when in -onepcm mode."), llvm::cl::cat(gRootclingOptions))
int CheckForUnsupportedClasses(const RScanner::ClassColl_t &annotatedRcds)
Check if the list of selected classes contains any class which is not supported.
static void EmitEnums(const std::vector< const clang::EnumDecl * > &enumvec)
int GenerateFullDict(std::ostream &dictStream, cling::Interpreter &interp, RScanner &scan, const ROOT::TMetaUtils::RConstructorTypes &ctorTypes, bool isSplit, bool isGenreflex, bool isSelXML, bool writeEmptyRootPCM)
bool CheckClassDef(const clang::RecordDecl &cl, const cling::Interpreter &interp)
Return false if the class does not have ClassDef even-though it should.
bool NeedsSelection(const char *name)
int extractMultipleOptions(std::vector< ROOT::option::Option > &options, int oIndex, std::vector< std::string > &values)
Extract from options multiple values with the same option.
int ROOT_rootcling_Driver(int argc, char **argv, const ROOT::Internal::RootCling::DriverConfig &config)
static ArgStatus None(const Option &, bool)
For options that don't take an argument: Returns ARG_NONE.
Describes an option, its help text (usage) and how it should be parsed.
static option::ArgStatus Required(const option::Option &option, bool msg)
Determines the minimum lengths of the buffer and options arrays used for Parser.