Skip to content

[6.36] Check for existing type before removing whitespaces #19229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2025

Conversation

vepadulano
Copy link
Member

Backport of #19087

This fixes root-project#19022

In `TClassEdit::GetNormalizedName`, the call to
`gInterpreterHelper->ExistingTypeCheck` is the one where eventually any
alternative names for the class name being looked for will be detected and used
for replacement (in `TClassTable::Check`). The alternative names for a custom
class may appear in a dictionary when the user declared their class in the
`ROOT::Meta::Selection` namespace and made it derive from the
`KeepFirstTemplateArguments` type trait.

Previously, the call to `ExistingTypeCheck` only happened after the input
demangled type name passed through the normalization logic of
`TClassEdit::TSplitType`. This led to an unfortunate situation.

The demangled type name resulting from a previous `TClassEdit::DemangleName`
call is the name representation of the typeid of the class type for the current
execution, i.e. whatever was generate by the compiler. In the case of a class
with multiple template arguments, this usually leads to a representation of the
form `A<B, C>`, i.e. where the two template arguments are separated by a
whitespace after the comma.

Crucially, this representation is also the same one used by the type system to
populate the dictionary information relative to the alternative class name for
classes where the user wants to strip one or more template arguments. In the
example just made, the class alternative name for `A<B>` will be registered as
`A<B, C>` with the whitespace in the dictionary sources.

Since the call to `ExistingTypeCheck` was happening *after* the `TSplitType`
normalization, the input class name was lacking the extra whitespace. Thus, any
search in `TClassTable::Check` would fail because it does a hash-based lookup of
the string in the map of class alternatives.

Thus, we now inject some logic to call `TClassTable::Check` earlier on
in the function, before the whitespace removal. This ensures that the name
lookup in the type system can work correctly. Note that a small addition
to the interface of TClingLookupHelper was needed, as the
`ExistingTypeCheck` method contains too much extra logic which in
certain situations would even lead to unwanted autoparsing if called too
early.

Co-authored-by: Philippe Canal <pcanal@fnal.gov>
@vepadulano
Copy link
Member Author

Sibling roottest PR at root-project/roottest#1344

Copy link

github-actions bot commented Jun 30, 2025

Test Results

    19 files      19 suites   3d 0h 53m 1s ⏱️
 2 748 tests  2 702 ✅ 0 💤 46 ❌
50 475 runs  50 429 ✅ 0 💤 46 ❌

For more details on these failures, see this check.

Results for commit 94ab15d.

♻️ This comment has been updated with latest results.

@vepadulano vepadulano added the clean build Ask CI to do non-incremental build on PR label Jul 1, 2025
@dpiparo dpiparo merged commit e6d7f86 into root-project:v6-36-00-patches Jul 1, 2025
78 of 83 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clean build Ask CI to do non-incremental build on PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants