This is an archive of the discontinued LLVM Phabricator instance.

[demangler] remove StdQualifiedName
ClosedPublic

Authored by urnathan on Jan 26 2022, 7:11 AM.

Details

Summary

The StdQualifiedName node class is used for names exactly in the std namespace. It is not used for nested names that descend further --
those use a NestedName with NameType("std") as the scope. We can use the same structure for those exactly in std too, and reduce code size a bit.

This also makes a further simplification possible.

Diff Detail

Event Timeline

urnathan created this revision.Jan 26 2022, 7:11 AM
urnathan requested review of this revision.Jan 26 2022, 7:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 26 2022, 7:11 AM

Do you say: we would use StdQualifiedName for names in ::std originally and use NameType with value std for names in something like NamespaceA::std::? If I understand correctly, I feel that it might not be a good choice. I think the current design makes the semantics more clear and it have a higher level of abstraction. The description says the main intention is to make code shorter. But I feel that the shorter code is not always simpler to understand.

No, sorry for being unclear.

std::name (St4Name)-> we would use StdQualifiedName
std::name1::name2 (NSt5Name15Name2E)-> we would use NestedName (std, ...)
std::name1<Inst> (NSt5Name1I4InstEE)-> we would also use NestedName (std, ...)

this patch moves to using NestedName in all these cases. (The other substitutions, such as 'Sa' remain unchanged)

No, sorry for being unclear.

std::name (St4Name)-> we would use StdQualifiedName
std::name1::name2 (NSt5Name15Name2E)-> we would use NestedName (std, ...)
std::name1<Inst> (NSt5Name1I4InstEE)-> we would also use NestedName (std, ...)

this patch moves to using NestedName in all these cases. (The other substitutions, such as 'Sa' remain unchanged)

Yeah, but it looks like StdQualifiedName is deleted completely...

No, sorry for being unclear.

std::name (St4Name)-> we would use StdQualifiedName
std::name1::name2 (NSt5Name15Name2E)-> we would use NestedName (std, ...)
std::name1<Inst> (NSt5Name1I4InstEE)-> we would also use NestedName (std, ...)

this patch moves to using NestedName in all these cases. (The other substitutions, such as 'Sa' remain unchanged)

Yeah, but it looks like StdQualifiedName is deleted completely...

Yes. That is the intent.

No, sorry for being unclear.

std::name (St4Name)-> we would use StdQualifiedName
std::name1::name2 (NSt5Name15Name2E)-> we would use NestedName (std, ...)
std::name1<Inst> (NSt5Name1I4InstEE)-> we would also use NestedName (std, ...)

this patch moves to using NestedName in all these cases. (The other substitutions, such as 'Sa' remain unchanged)

Yeah, but it looks like StdQualifiedName is deleted completely...

Yes. That is the intent.

I got your point. hmmm I think such rewriting would make the code harder to read. Is it possible to use StdQualifiedName to replace NestedName (std, ...)?

urnathan added a comment.EditedJan 31 2022, 3:54 AM

Yeah, but it looks like StdQualifiedName is deleted completely...

Yes. That is the intent.

I got your point. hmmm I think such rewriting would make the code harder to read. Is it possible to use StdQualifiedName to replace NestedName (std, ...)?

I'm sorry I disagree. I see no reason to special-case '::std' in this way, and doing so makes the code harder to read --we'd keep having to check if a name is ::std. Let's pick one way to represent nested names.

ETA: Let's expand this a bit more.
The substitution mechanism is a compression technique in the mangled symbols. The Node type hierarchy is a representation of the components of an entity's identity, and the subsequent Node graph is that entity. These latter two components need not and, I assert, should not contain representations of the compression -- that's mixing abstractions (The Nodes don't contain representations of the back-reference substitutions for instance.)

I hope that makes things clearer?

Yeah, but it looks like StdQualifiedName is deleted completely...

Yes. That is the intent.

I got your point. hmmm I think such rewriting would make the code harder to read. Is it possible to use StdQualifiedName to replace NestedName (std, ...)?

I'm sorry I disagree. I see no reason to special-case '::std' in this way, and doing so makes the code harder to read --we'd keep having to check if a name is ::std. Let's pick one way to represent nested names.

ETA: Let's expand this a bit more.
The substitution mechanism is a compression technique in the mangled symbols. The Node type hierarchy is a representation of the components of an entity's identity, and the subsequent Node graph is that entity. These latter two components need not and, I assert, should not contain representations of the compression -- that's mixing abstractions (The Nodes don't contain representations of the back-reference substitutions for instance.)

I hope that makes things clearer?

So the key point here is: Although ::std namespace is special in mangling, we could treat it homogeneously in the Node since we could handle it later. Do I understand right? If yes, I think this one should be good.

So the key point here is: Although ::std namespace is special in mangling, we could treat it homogeneously in the Node since we could handle it later. Do I understand right? If yes, I think this one should be good.

yes, that is correct. i hope you enjoyed your vacation.

ChuanqiXu accepted this revision.Feb 7 2022, 5:19 AM

So the key point here is: Although ::std namespace is special in mangling, we could treat it homogeneously in the Node since we could handle it later. Do I understand right? If yes, I think this one should be good.

yes, that is correct. i hope you enjoyed your vacation.

Thanks : )

This revision is now accepted and ready to land.Feb 7 2022, 5:19 AM
This revision was landed with ongoing or failed builds.Feb 7 2022, 7:49 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2022, 7:49 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript