[cfe-dev] Getting fully qualified names of random qualtypes.

Philippe Canal via cfe-dev cfe-dev at lists.llvm.org
Tue Oct 13 14:48:33 PDT 2015


Hi,

We also discovered that we could not find in clang a routine that reliably generate the name (or the equivalent
decl/type) corresponding to a type as it would need to be typed from the global namespace (i.e. a unique identifier
of the class); for example the naming routine that can be tuned to give a fully qualified name often do not reliably handle the
nested template parameters (similar to what Sterling also found out).

Cheers,
Philippe.

PS. As an aside the code we have in cling/lib/Utils/AST.cpp does a bit more as it can drop some
of the template parameters when they are defaulted and keep some typedef (for example std::string).
The goal is to produce a 'normalized name' that is platform independent and suitable to use
as a persistent representation of the class;   This is used as part of ROOT I/O which enables storing
arbitrary C++ objects in files that can be read on multiple platforms and can be read even when
the class' schema changes.   This used to store many petabytes of experimental data that needs to
be read very quickly and need to also be readable many years later.

On 10/13/15 4:01 PM, Sterling Augustine wrote:
> On Tue, Oct 13, 2015 at 1:33 PM, David Blaikie <dblaikie at gmail.com <mailto:dblaikie at gmail.com>> wrote:
>
>
>         https://root.cern.ch/gitweb?p=root.git;a=blob;f=interpreter/cling/lib/Utils/AST.cpp
>
>         Does it makes sense to upstream this functionality from cling into clang?
>
>
>     Presumably clang needs to do this in places already (diagnostic messages, etc?)? Have you found any instances of that? Is
>     there existing code doing that work that could be refactored into something reusable (that way it's being actually executed
>     and tested within Clang's many codepaths, which is helpful to avoid bitrot, etc)
>
>
> To the best of my knowledge, it doesn't exist. Certainly not in diagnostics, which try to reproduce what the user wrote, rather 
> than what they would need to write in general. (In particular, things like template_A<nested_type_0, template_B<nested_type_1>> 
> seem to never have sub-types get fully expanded. I've looked for this in clang, and it is possible I missed something, so happy 
> for any pointers.
>
> Clang is oriented to reproducing the source code as written, not what one would need to write to access it from a random namespace.
>
> This is one of several bits of functionality where the comment in my code is: "one would think this is implemented somewhere in 
> clang, but one would be wrong". (Generic fully-qualified lookup being another. Also implemented in cling, but is not very 
> complicated, so not as big of a deal as this.)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151013/c8d9531e/attachment.html>


More information about the cfe-dev mailing list