[cfe-dev] How to demangle _ZN3foocvPT_I3barEEv?

Joshua Naismith fakju666 at o2.pl
Mon Feb 11 10:04:03 PST 2013


Olivier Goffart wrote:
> On Monday 11 February 2013 14:06:45 fakju666 wrote:
> > Can anyone tell me what this is supposed to demangle to:
> > 
> > _ZN3foocvPT_I3barEEv
> > 
> > I got this in a call graph generated by opt, and this is the only name that
> > c++filt can't process. I think the problem is with the "T_" identifier,
> > because c++filt is happy if I replace it with "S_":
> > 
> > foo::operator foo<bar>*()
> 
> Could it be something like:
> 
> template<template<typename S> class T> 
> foo<T>::operator T<bar>*()
> 
> "T_" seems to indicate a template dependent name.
> I don't know where you got that symbol from.

Below is a minimized testcase. Run with:

clang++ -S -emit-llvm --std=gnu++0x -o - testcase.cpp | opt -analyze -dot-callgraph

Then feed the resulting callgraph.dot to c++filt:

cat callgraph.dot | c++filt

As you can see, _ZN3FoocvPT_I3DerEEv isn't demangled. It seems to be a bug in c++filt since an older version could demangle "T_" according to Marshall.

Testcase:
---------
class Base {
public:
  virtual void* basefun() = 0;
};

class Der : public Base {};

class Foo {
public:
  Foo(Base *s) : ptr(s) {}

  template<class Dest>
  operator Dest*() {
    return reinterpret_cast<Dest*>(ptr->basefun());
  }

private:
  Base *ptr;
};

Der*
f(Base *in) {
      return Foo(in);
}
---------




More information about the cfe-dev mailing list