[cfe-dev] Problems in clang/AST/ASTConsumer.h
Simone Pellegrini
spellegrini at dps.uibk.ac.at
Wed Dec 10 03:07:56 PST 2008
Hi,
I'm extending the ASTConsumer class to make some custom analysis on the
Syntax tree created by clang in the following way:
class MyASTConsumer: public ASTConsumer {
...
}
when I try to compile my program using the g++ compiler (I've used both
the gcc 3.4.6 and gcc 4.3.2). I get the following error:
build/main.o(.gnu.linkonce.r._ZTI13MyASTConsumer+0x10): undefined
reference to `typeinfo for clang::ASTConsumer'
collect2: ld returned 1 exit status
Apparently the error is caused by the empty virtual definition of
ASTConsumer methods:
virtual ~ASTConsumer();
virtual void InitializeTU(TranslationUnit& TU) ;
changing this declaration (in the ASTConsumer.h file) into:
virtual ~ASTConsumer() {}
virtual void InitializeTU(TranslationUnit& TU) {}
or:
virtual ~ASTConsumer() = 0;
virtual void InitializeTU(TranslationUnit& TU) = 0;
fixes the problem for me! Of course in the second problem I have to
provide an implementation for both the methods in my class.
I hope it helps,
greetings Simone
More information about the cfe-dev
mailing list