[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

Douglas Gregor dgregor at apple.com
Thu Jul 28 06:59:10 PDT 2011


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



More information about the cfe-commits mailing list