[LLVMdev] Why is "typedef boost::shared_ptr<MyClass> MyClass_ptr" named "struct.boost::MyClass_ptr" by llvm-g++?
matthijs at stdin.nl
Wed Nov 19 04:03:53 PST 2008
> In the code below, MyNamespace::MyClass_ptr will be named
> "struct.boost::MyClass_ptr" by llvm-g++, and not
> "struct.MyNamespace::MyClass_ptr" as I expected.
In LLVM IR, types use structural equivalency. That means that types are
equivalent when they are the same type (ie, have the same type of fields,
etc.), regardless of what name they have. Moreover, any given type can have
only a single name.
This means that when there are two typenames for the same (structural) type in
the original sourcecode (which is the case by definition when typedeffing
something), only one of those names will be used on the resulting type in the
IR. Which one of those names is used is pretty arbitrary I think (and if there
happens to be another type that is structurally the same, it might even become
In short, you should probably not value typenames too much in LLVM IR. If you
really want to keep types apart, you'll have to check their structure.
Alternatively, you might be able to switch on debugging info to get some
higher level (ie, closer to C++) type info, but I'm not so sure this is
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 189 bytes
Desc: Digital signature
More information about the llvm-dev