[cfe-commits] r136306 - in /cfe/trunk: include/clang/AST/DeclBase.h lib/AST/DeclPrinter.cpp lib/Frontend/ASTConsumers.cpp test/Misc/ast-dump-templates.cpp

Richard Trieu rtrieu at google.com
Thu Jul 28 13:38:42 PDT 2011


Thanks for the help tracking down the problem.  I've committed a fixed test
case at r136385.  The test now does two FileCheck's to find the
instantiations and will not be order dependent.  Let me know if any more
problems crop up.

On Thu, Jul 28, 2011 at 6:59 AM, Douglas Gregor <dgregor at apple.com> wrote:

>
> On Jul 27, 2011, at 5:19 PM, Richard Trieu wrote:
>
> > Author: rtrieu
> > Date: Wed Jul 27 19:19:05 2011
> > New Revision: 136306
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=136306&view=rev
> > Log:
> > Add template instantiations to the output of -ast-dump.
> >
> > Added:
> >    cfe/trunk/test/Misc/ast-dump-templates.cpp
> > Modified:
> >    cfe/trunk/include/clang/AST/DeclBase.h
> >    cfe/trunk/lib/AST/DeclPrinter.cpp
> >    cfe/trunk/lib/Frontend/ASTConsumers.cpp
> >
> >
> > +void DeclPrinter::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
> > +  if (PrintInstantiation) {
> > +    TemplateParameterList *Params = D->getTemplateParameters();
> > +    for (FunctionTemplateDecl::spec_iterator I = D->spec_begin(), E =
> D->spec_end();
> > +         I != E; ++I) {
> > +      PrintTemplateParameters(Params,
> (*I)->getTemplateSpecializationArgs());
> > +      Visit(*I);
> > +    }
> > +  }
> > +
> > +  return VisitRedeclarableTemplateDecl(D);
> > +}
> > +
> > +void DeclPrinter::VisitClassTemplateDecl(ClassTemplateDecl *D) {
> > +  if (PrintInstantiation) {
> > +    TemplateParameterList *Params = D->getTemplateParameters();
> > +    for (ClassTemplateDecl::spec_iterator I = D->spec_begin(), E =
> D->spec_end();
> > +         I != E; ++I) {
> > +      PrintTemplateParameters(Params, &(*I)->getTemplateArgs());
> > +      Visit(*I);
> > +      Out << '\n';
> > +    }
> > +  }
> > +
> > +  return VisitRedeclarableTemplateDecl(D);
> > +}
> > +
>
> This is the reason for the instability in tests: spec_begin()/spec_end()
> iterators over a FoldingSet, so the order will differ from one invocation of
> Clang to the next.
>
>        - Doug
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110728/a0588e4f/attachment.html>


More information about the cfe-commits mailing list