[cfe-dev] Plugin clang
Reid Kleckner
rnk at google.com
Wed Feb 18 09:55:58 PST 2015
Call T->getAsCXXRecordDecl() and see if you get one back. You might not get
one if the base is a template parameter. Then you can call RD->getName()
for the DeclarationName (which could be none) and try to print it.
On Wed, Feb 18, 2015 at 2:10 AM, brahim brahim <brahimalekhine at gmail.com>
wrote:
> Hello,
>
> I am trying to implement a plugin for clang that prints all c++ classes
> and they are base classes.
> I can't find in Doxygen how to access the base class's name.
> Can someone help finish this piece of code(see below)?
>
> Thank
>
> Brahim
>
>
> class ClassFinderConsumer : public ASTConsumer {
> public:
> virtual bool HandleTopLevelDecl(DeclGroupRef DG) {
> for (DeclGroupRef::iterator i = DG.begin(), e = DG.end(); i != e; ++i)
> {
> const Decl *D = *i;
> if (const CXXRecordDecl *ND = dyn_cast<CXXRecordDecl>(D)) {
> llvm::errs() << "Class: " << ND->getNameAsString() << "\nBase(s):
> ";
> for (const auto& ItBase : ND->bases()) {
> const QualType& T = ItBase.getType();
> // Then...
> //llvm::errs() << ItBase.getType() << " ";
> }
> llvm::errs() << "\n";
> }
> }
>
> return true;
> }
> };
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150218/34acdfce/attachment.html>
More information about the cfe-dev
mailing list