Skip to content

Commit d8356ba

Browse files
committed
TCling: Register, give access to and print list of autoparsed class.
Use `gInterpreter->Print("autoparsed");` to print a list of the class names that directly lead to auto-parsing. Use `gCling->GetAutoParseClasses()` to programatically get a set of the class names that directly lead to auto-parsing.
1 parent 63a76bb commit d8356ba

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

core/metacling/src/TCling.cxx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2662,6 +2662,29 @@ void TCling::PrintIntro()
26622662
{
26632663
}
26642664

2665+
////////////////////////////////////////////////////////////////////////////////
2666+
/// Print information about the interpreter.
2667+
///\param[in] option Selects the type of information to print.
2668+
///
2669+
/// List of currently support options:
2670+
/// - autoparsed: Print the list of classes that triggered autoparsing.
2671+
void TCling::Print(Option_t *option) const
2672+
{
2673+
if (option && *option) {
2674+
if (!strcmp(option, "autoparsed")) {
2675+
std::cout << "Auto parsed classes:" << std::endl;
2676+
for (auto & cls : fAutoParseClasses) {
2677+
std::cout << " " << cls << std::endl;
2678+
}
2679+
} else {
2680+
::Error("TCling::Print", "Unknown option '%s'", option);
2681+
}
2682+
} else {
2683+
::Info("TCling::Print", "No options specified");
2684+
}
2685+
}
2686+
2687+
26652688
////////////////////////////////////////////////////////////////////////////////
26662689
/// \brief Add a directory to the list of directories in which the
26672690
/// interpreter looks for include files.
@@ -6533,6 +6556,12 @@ UInt_t TCling::AutoParseImplRecurse(const char *cls, bool topLevel)
65336556
}
65346557
}
65356558

6559+
if (nHheadersParsed) {
6560+
// Register that we did autoparsing for this class.
6561+
fAutoParseClasses.insert(cls);
6562+
if (gDebug)
6563+
Info("AutoParse", "Parsed %d headers for %s", nHheadersParsed, cls);
6564+
}
65366565
return nHheadersParsed;
65376566

65386567
}

core/metacling/src/TCling.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ class TCling final : public TInterpreter {
121121
std::set<size_t> fLookedUpClasses; // Set of classes for which headers were looked up already
122122
std::set<size_t> fPayloads; // Set of payloads
123123
std::set<const char*> fParsedPayloadsAddresses; // Set of payloads which were parsed
124+
std::set<std::string> fAutoParseClasses; // Set of classes for which we autoparsed a header
124125
std::hash<std::string> fStringHashFunction; // A simple hashing function
125126
std::unordered_set<const clang::NamespaceDecl*> fNSFromRootmaps; // Collection of namespaces fwd declared in the rootmaps
126127
TObjArray* fRootmapFiles; // Loaded rootmap files.
@@ -200,6 +201,7 @@ class TCling final : public TInterpreter {
200201
Int_t AutoLoad(const char *classname, Bool_t knowDictNotLoaded = kFALSE) final;
201202
Int_t AutoLoad(const std::type_info& typeinfo, Bool_t knowDictNotLoaded = kFALSE) final;
202203
Int_t AutoParse(const char* cls) final;
204+
const std::set<std::string>& GetAutoParseClasses() const { return fAutoParseClasses; }
203205
void* LazyFunctionCreatorAutoload(const std::string& mangled_name);
204206
bool LibraryLoadingFailed(const std::string&, const std::string&, bool, bool);
205207
Bool_t IsAutoLoadNamespaceCandidate(const clang::NamespaceDecl* nsDecl);
@@ -240,6 +242,7 @@ class TCling final : public TInterpreter {
240242
Longptr_t ProcessLineAsynch(const char* line, EErrorCode* error = nullptr);
241243
Longptr_t ProcessLineSynch(const char* line, EErrorCode* error = nullptr) final;
242244
void PrintIntro() final;
245+
void Print(Option_t *option="") const final;
243246
bool RegisterPrebuiltModulePath(const std::string& FullPath,
244247
const std::string& ModuleMapName = "module.modulemap") const final;
245248
void RegisterModule(const char* modulename,

0 commit comments

Comments
 (0)