700 const std::vector<std::string> &
headers,
701 const std::vector<std::string> &
fwdDecls,
702 const std::vector<std::string> &
unknown)
708 if (classes.empty()) {
712 const std::string& className = classes[0];
714 TString fileName =
"AutoDict_";
715 std::string::const_iterator
sIt;
716 for (
sIt = className.begin();
sIt != className.end(); ++
sIt) {
717 if (*
sIt ==
'<' || *
sIt ==
'>' ||
718 *
sIt ==
' ' || *
sIt ==
'*' ||
719 *
sIt ==
',' || *
sIt ==
'&' ||
727 if (classes.size() > 1) {
729 std::vector<std::string>::const_iterator it = classes.begin();
730 while ((++it) != classes.end()) {
745 static const std::set<std::string>
sSTLTypes {
746 "vector",
"list",
"forward_list",
"deque",
"map",
"unordered_map",
"multimap",
747 "unordered_multimap",
"set",
"unordered_set",
"multiset",
"unordered_multiset",
748 "queue",
"priority_queue",
"stack",
"iterator"};
749 std::vector<std::string>::const_iterator it;
773 fileContent +=
"#pragma link C++ nestedclasses;\n";
774 fileContent +=
"#pragma link C++ nestedtypedefs;\n";
775 for (it = classes.begin(); it != classes.end(); ++it) {
781 if (
n.compare(0, 5,
"std::") == 0) {
791 fileContent +=
"#pragma link C++ class " + *it +
"::*+;\n" ;
1102 for (ModuleMap::module_iterator
I =
MMap.module_begin(), E =
MMap.module_end();
I != E; ++
I) {
1112 clang::GlobalModuleIndex::UserDefinedInterestingIDs
IDs;
1120 if (!
ND->isFromASTFile())
1122 if (!
ND->getIdentifier())
1129 if (
TD->isCompleteDefinition())
1132 Register(
NSD,
false);
1140 clang::GlobalModuleIndex::UserDefinedInterestingIDs &
DefinitionIDs;
1145 if (!
ND->hasOwningModule()) {
1151 assert(
FE->getName().contains(
"input_line_"));
1156 Module *
OwningModule =
ND->getOwningModule()->getTopLevelModule();
1158 assert(!
ND->getName().empty() &&
"Empty name");
1170 llvm::cantFail(GlobalModuleIndex::writeIndex(
CI.getFileManager(),
1171 CI.getPCHContainerReader(),
1347#ifdef R__USE_CXXMODULES
1357 for (
const char*
const* arg =
argv; *arg; ++arg)
1407 std::optional<std::string>
EnvOpt = llvm::sys::Process::GetEnv(
"EXTRA_CLING_ARGS");
1408 if (
EnvOpt.has_value()) {
1410 while (!
Env.empty()) {
1412 std::tie(Arg,
Env) =
Env.split(
' ');
1418 std::optional<std::string>
EnvOpt = llvm::sys::Process::GetEnv(
EnvVar);
1419 if (
EnvOpt.has_value()) {
1421 while (!
Env.empty()) {
1425 Paths.push_back(Arg.str());
1431 std::vector<std::string>
Paths;
1438 for (
const std::string& P :
Paths)
1445 EnvOpt = llvm::sys::Process::GetEnv(
"ROOT_CLING_TIMING");
1468 EnvOpt = llvm::sys::Process::GetEnv(
"CLING_MODULES_CACHE_PATH");
1471 assert(llvm::sys::fs::exists(
Env) &&
"Path does not exist!");
1493 interpArgs.push_back(
"-fno-implicit-module-maps");
1523 std::vector<std::string>
_empty;
1525 for (
const auto &arg: args)
1529 cling::Interpreter::ModuleFileExtensions
extensions;
1530 EnvOpt = llvm::sys::Process::GetEnv(
"ROOTDEBUG_RDICT");
1532 extensions.push_back(std::make_shared<TClingRdictModuleFileExtension>());
1543 fInterpreter->getCI()->getPreprocessorOpts().DisablePCHOrModuleValidation =
1544 DisableValidationForModuleKind::All;
1548 fInterpreter->getCI()->getLangOpts().SpellChecking =
false;
1583 fInterpreter->getRuntimeOptions().AllowRedefinition = 1;
1584 auto &Policy =
const_cast<clang::PrintingPolicy &
>(
fInterpreter->getCI()->getASTContext().getPrintingPolicy());
1588 Policy.SplitTemplateClosers =
true;
1590 Policy.SuppressDefaultTemplateArgs =
false;
1596 std::unique_ptr<TClingCallbacks>
1603 cling::DynamicLibraryManager&
DLM = *
fInterpreter->getDynamicLibraryManager();
1609 llvm::StringRef
stem = llvm::sys::path::stem(FileName);
1610 return stem.startswith(
"libNew") ||
stem.startswith(
"libcppyy_backend");
2042 Info(
"TCling::RegisterModule",
2043 "Header parsing on demand is active but this is an Aclic library. Disabling it for this library.");
2061 cling::Transaction* T =
nullptr;
2068 "A fwd declaration could not be compiled");
2069 if (
compRes!=cling::Interpreter::kSuccess){
2070 Warning(
"TCling::RegisterModule",
2071 "Problems in declaring string '%s' were encountered.",
2094 ::Error(
"TCling::RegisterModule",
"Dictionary trigger function for %s not found",
modulename);
2132 std::vector<std::string>
scopes;
2136 if (
enumPos != std::string::npos) {
2154 clang::DeclContext*
DC =
nullptr;
2181 = cling::utils::Lookup::Named(&
fInterpreter->getSema(),
2199 "The forward declarations could not be compiled");
2200 if (
compRes!=cling::Interpreter::kSuccess){
2201 Warning(
"TCling::RegisterModule",
2202 "Problems in compiling forward declarations for module %s: '%s'",
2211 ExtLexicalStorageAdder
elsa;
2213 cling::Transaction::DelayCallInfo&
dci = *
dciIt;
2251 Info(
"TCling::RegisterModule",
2252 "Adding a header for %s", temp.c_str());
2275 clang::Preprocessor &
PP =
TheSema.getPreprocessor();
2293 Info(
"TCling::RegisterModule",
"Module %s in modulemap failed to load.",
ModuleName.c_str());
2314#if defined(R__MUST_REVISIT)
2315#if R__MUST_REVISIT(6,2)
2316 Warning(
"TCling::RegisterModule",
"Diagnostics suppression should be gone by now.");
2331 "Payload code of a dictionary could not be parsed correctly.");
2332 if (
compRes!=cling::Interpreter::kSuccess) {
2333 Warning(
"TCling::RegisterModule",
2334 "Problems declaring payload for module %s.",
modulename) ;
2350 "#undef __ROOTCLING__\n"
2475 gROOT->SetLineIsProcessing();
2479 gROOT->SetLineHasBeenProcessed();
2492 gROOT->SetLineIsProcessing();
2495 cling::Interpreter* fInterpreter;
2502 fInterpreter->enableDynamicLookup(
true);
2506 gROOT->SetLineHasBeenProcessed();
2515 cling::Interpreter::CompilationResult
compRes = cling::Interpreter::kSuccess;
2536 compRes = cling::Interpreter::kFailure;
2541 if (arguments.
Length() == 0) {
2554 }
else if (cling::DynamicLibraryManager::isSharedLibrary(
fname.Data()) &&
2558 compRes = cling::Interpreter::kFailure;
2560 if (arguments.
Length() == 0) {
2591 std::ifstream in(
fname, std::ifstream::binary);
2597 = cling::utils::isUnnamedMacro(code,
fInterpreter->getCI()->getLangOpts());
2636 case cling::Interpreter::kSuccess: *error =
kNoError;
break;
2637 case cling::Interpreter::kFailure: *error =
kRecoverable;
break;
2638 case cling::Interpreter::kMoreInputExpected: *error =
kProcessing;
break;
2641 if (
compRes == cling::Interpreter::kSuccess
2724 const char*
cobj = (
const char*) obj;
2764 static clang::PrintingPolicy
2769 printPol.SuppressInitializers =
true;
2790 Error(
"InspectMembers",
"Cannot find Decl for class %s",
clname);
2794 = llvm::dyn_cast<const clang::CXXRecordDecl>(
scopeDecl);
2796 Error(
"InspectMembers",
"Cannot find Decl for class %s is not a CXXRecordDecl.",
clname);
2820 Error(
"InspectMembers",
"TClass and cling disagree on the size of the class %s, respectively %d %lld\n",
2842 printPol.AnonymousTagLocations =
false;
2845 Error(
"InspectMembers",
2846 "Cannot retrieve QualType for member %s while inspecting class %s",
2855 printPol.AnonymousTagLocations =
false;
2858 Error(
"InspectMembers",
2859 "Cannot retrieve Type for member %s while inspecting class %s",
2868 clang::QualType
ptrQT
2875 if (
ptrQT.isNull()) {
2879 printPol.AnonymousTagLocations =
false;
2882 Error(
"InspectMembers",
2883 "Cannot retrieve pointee Type for member %s while inspecting class %s",
2891 llvm::SmallString<8> arraySize;
2899 clang::dyn_cast<clang::ConstantArrayType>(
arrType);
2909 printPol.AnonymousTagLocations =
false;
2912 Error(
"InspectMembers",
2913 "Cannot retrieve QualType for array level %d (i.e. element type of %s) for member %s while inspecting class %s",
2927 if (
memType->isPointerType()) {
2932 std::string ioname(
iField->getName());
2950 if (!
insp.IsTreatingNonAccessibleTypes()){
2990 for (clang::CXXRecordDecl::base_class_const_iterator
iBase
2995 Error(
"InspectMembers",
2996 "Cannot find QualType for base number %d while inspecting class %s",
3000 const clang::CXXRecordDecl*
baseDecl
3001 =
baseQT->getAsCXXRecordDecl();
3003 Error(
"InspectMembers",
3004 "Cannot find CXXRecordDecl for base number %d while inspecting class %s",
3029 Error(
"InspectMembers",
3035 if (
iBase->isVirtual()) {
3038 Error(
"InspectMembers",
3039 "Base %s of class %s is virtual but no object provided",
3051 Error(
"InspectMembers",
3052 "Error calculating offset of virtual base %s of class %s",
3056 Error(
"InspectMembers",
3057 "Cannot calculate offset of virtual base %s of class %s",
3066 if (
baseCl->IsLoaded()) {
3193 size_t at = std::string::npos;
3194 while ((at = file_name.find(
"/./")) != std::string::npos)
3195 file_name.replace(at, 3,
"/");
3199 clang::SourceManager &
SM =
fInterpreter->getCI()->getSourceManager();
3200 cling::ClangInternalState::printIncludedFiles(
filesOS,
SM);
3203 llvm::SmallVector<llvm::StringRef, 100>
files;
3206 std::set<std::string>
fileMap;
3226 incPath.Append(
":").Prepend(
" ");
3227 incPath.ReplaceAll(
" -I",
":");
3228 while (
incPath.Index(
" :") != -1) {
3229 incPath.ReplaceAll(
" :",
":");
3243 clang::ConstSearchDirIterator *
CurDir =
nullptr;
3244 clang::Preprocessor &
PP =
fInterpreter->getCI()->getPreprocessor();
3245 clang::HeaderSearch &
HS =
PP.getHeaderSearchInfo();
3246 auto FE =
HS.LookupFile(file_name.c_str(),
3247 clang::SourceLocation(),
3250 clang::ArrayRef<std::pair<clang::OptionalFileEntryRef,
3251 clang::DirectoryEntryRef>>(),
3264 clang::SourceManager &
SM =
fInterpreter->getCI()->getSourceManager();
3266 clang::FileID
FID =
SM.translateFile(*
FE);
3267 if (!
FID.isInvalid() &&
FID.getHashValue() == 0)
3270 clang::SrcMgr::SLocEntry
SLocE =
SM.getSLocEntry(
FID);
3271 if (
SLocE.isFile() && !
SLocE.getFile().getContentCache().getBufferIfLoaded())
3273 if (!
FID.isInvalid())
3534 cling::DynamicLibraryManager*
DLM =
fInterpreter->getDynamicLibraryManager();
3536 cling::DynamicLibraryManager::LoadLibResult res
3537 = cling::DynamicLibraryManager::kLoadLibNotFound;
3544 cling::Interpreter::CompilationResult
compRes;
3546 if (
compRes == cling::Interpreter::kSuccess)
3547 res = cling::DynamicLibraryManager::kLoadLibSuccess;
3551 if (res == cling::DynamicLibraryManager::kLoadLibSuccess) {
3555 case cling::DynamicLibraryManager::kLoadLibSuccess:
return 0;
3556 case cling::DynamicLibraryManager::kLoadLibAlreadyLoaded:
return 1;
3813#if defined(R__MUST_REVISIT)
3814#if R__MUST_REVISIT(6,2)
3815 Warning(
"DeleteVariable",
"should do more that just reseting the value to zero");
3823 const clang::DeclContext*
declCtx =
nullptr;
3824 if (
posScope != llvm::StringRef::npos) {
3828 cling::LookupHelper::WithDiagnostics);
3830 Error(
"DeleteVariable",
"Cannot find enclosing scope for variable %s",
3836 Error(
"DeleteVariable",
3837 "Enclosing scope for variable %s is not a declaration context",
3848 Error(
"DeleteVariable",
"Unknown variable %s",
name);
3853 Error(
"DeleteVariable",
"Entity %s is not a variable",
name);
3858 const clang::Type*
type =
qType->getUnqualifiedDesugaredType();
3861 if (
type->isPointerType()) {
4193 static const char *
anonEnum =
"anonymous enum ";
4221 const char *classname =
name;
4257 const clang::Type *
type =
nullptr;
4258 const clang::Decl *
decl
4259 =
lh.findScope(classname,
4260 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
4261 : cling::LookupHelper::NoDiagnostics,
4266 gDebug > 5 ? cling::LookupHelper::WithDiagnostics
4267 : cling::LookupHelper::NoDiagnostics,
4284 clang::ClassTemplateSpecializationDecl *
tmpltDecl =
4285 llvm::dyn_cast_or_null<clang::ClassTemplateSpecializationDecl>
4286 (
type->getAsCXXRecordDecl());
4298 if (!
tci.IsValid()) {
4418 D =
fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
4429 for (clang::DeclContext::decl_iterator
DI = (*declIter)->decls_begin(),
4430 DE = (*declIter)->decls_end();
DI !=
DE; ++
DI) {
4435 llvm::raw_string_ostream stream(buf);
4437 Policy.AnonymousTagLocations =
false;
4438 ED->getNameForDiagnostic(stream, Policy,
false);
4442 const char*
name = buf.c_str();