[meta] Ctor name lookup is not enough for the class info - #23098
Conversation
Test Results 23 files 23 suites 3d 16h 24m 29s ⏱️ For more details on these failures, see this check. Results for commit b51209a. ♻️ This comment has been updated with latest results. |
the mechanism in place to allow the initialisation of TClingClassInfo based on names of forward declared classes was a bit too loose. It also allowed for finding a class by the name of its constructor. Fixes ROOT-10311
| if (const auto *TD = type->getAsTagDecl()) { | ||
| decl = TD; | ||
| const auto *CXXRD = type->getAsCXXRecordDecl(); | ||
| if (CXXRD && !CXXRD->hasDefinition()) { |
There was a problem hiding this comment.
| if (CXXRD && !CXXRD->hasDefinition()) { | |
| if (CXXRD && CXXRD->NamedDecl::isUnconditionallyVisible()) { |
However, it may be actually more semantically correct, to move this check into quickFindDecl possibly around line 226:
226 next = utils::Lookup::Named(&S, declName.substr(last, c - last), sofar);
| if (!decl && type) { | ||
| if (const auto *TD = type->getAsTagDecl()) { | ||
| decl = TD; | ||
| const auto *CXXRD = type->getAsCXXRecordDecl(); |
There was a problem hiding this comment.
I'm curious since this dropped getAsTagDecl I assume something like:
gInterpreter->Declare("enum class E : int;");
gInterpreter->ClassInfo_Factory("E");would not work. Why not just check for a definition on the TagDecl instead? as I think that would still reject TTree::TTree:
if (const auto *TD = type->getAsTagDecl(); TD && !TD->getDefinition())
decl = TD;but perhaps I'm missing another reason why we should restrict on CXXRecordDecl
There was a problem hiding this comment.
The choice of CXXRecordDecl is solely this commit 842767f#diff-fb8b9374813e714b3d3b31ba080d2c8121fc3f3882ac775a6cd0904e3a2e882aR102-R103 .
All that code seems to be there to get a grip onto class fwd declarations. TagDecls are a way to achieve that, but it's not always working, and therefore the more stringent check
The mechanism in place to allow the initialisation of TClingClassInfo based on names of forward declared classes was a bit too loose. It also allowed for finding a class by the name of its constructor.
The new mechanism is more explicit about the properties of the CXXRecordDecl identified by the lookup (if any).
Fixes ROOT-10311