[cfe-dev] doing global unused methods analysis
Noel Grandin via cfe-dev
cfe-dev at lists.llvm.org
Mon Oct 5 06:27:18 PDT 2015
Hi Manuel
That was a bad example, this is a better one (dramatically simplified from my actual code).
I can't seem to use clang-query here (I have 3.6), but dumping the AST shows my problem.
Specifically, in the below code, when I traverse the AST, there is no way to see that a call to doRegisterHandlers() is
in fact being generated.
The relevant section of AST looks like:
CallExpr 0x328d958 <line:15:9, col:42> '<dependent type>'
| | | | |-CXXDependentScopeMemberExpr 0x328d8d8 <col:9, col:15> '<dependent type>' lvalue
| | | | | `-CXXThisExpr 0x328d8c0 <col:9> 'ImportFilterImpl<Generator> *' this
| | | | `-DeclRefExpr 0x328d930 <col:34> 'Generator' lvalue Var 0x328d850 'exporter' 'Generator'
Now I know that clang is doing the right thing here, but I'm hoping there is a way I can tell it to "expand out" and
generate more AST nodes when I hit a template instantiation?
Thanks a lot for the help!
Regards, Noel.
--------------------------------------
class XFilter
{
public:
virtual bool filter() = 0;
};
template<class Generator>
class ImportFilterImpl : public XFilter
{
public:
virtual bool filter() override
{
Generator exporter;
this->doRegisterHandlers(exporter);
}
private:
virtual void doRegisterHandlers(Generator &) {};
};
template<class T>
class ImplInheritanceHelper : public T
{};
template<class Generator>
struct ImportFilter : public ImplInheritanceHelper<ImportFilterImpl<Generator> >
{
};
class MyGenerator {};
class MainClass : public ImportFilter<MyGenerator>
{};
More information about the cfe-dev
mailing list