[cfe-commits] r67308 - in /cfe/trunk: include/clang/AST/DeclTemplate.h include/clang/AST/ExprCXX.h include/clang/AST/StmtNodes.def include/clang/Parse/DeclSpec.h lib/AST/DeclTemplate.cpp lib/AST/ExprCXX.cpp lib/AST/StmtPrinter.cpp lib/Sema/Sema.h lib/Sema/SemaCXXScopeSpec.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaTemplate.cpp lib/Sema/SemaTemplateInstantiate.cpp test/SemaTemplate/fibonacci.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Thu Mar 19 11:04:43 PDT 2009


Douglas Gregor wrote:
> Author: dgregor
> Date: Thu Mar 19 12:26:29 2009
> New Revision: 67308
>
> URL: http://llvm.org/viewvc/llvm-project?rev=67308&view=rev
> Log:
> Introduce a new expression type, UnresolvedDeclRefExpr, that describes
> dependent qualified-ids such as
>
>   Fibonacci<N - 1>::value
>
> where N is a template parameter. These references are "unresolved"
> because the name is dependent and, therefore, cannot be resolved to a
> declaration node (as we would do for a DeclRefExpr or
> QualifiedDeclRefExpr). UnresolvedDeclRefExprs instantiate to
> DeclRefExprs, QualifiedDeclRefExprs, etc.
>
> Also, be a bit more careful about keeping only a single set of
> specializations for a class template, and instantiating from the
> definition of that template rather than a previous declaration. In
> general, we need a better solution for this for all TagDecls, because
> it's too easy to accidentally look at a declaration that isn't the
> definition.
>
> We can now process a simple Fibonacci computation described as a
> template metaprogram.
>   

Very nice. Is this computation linear or exponential, though? The usual
template instantiation rules are memoizing, so it should be linear, but
that only works if the compiler won't try to instantiation
FibonacciEval<N> twice (once as FibonacciEval<I-1> where I == N+1, and
once as FibonacciEval<I-2> where I == N + 2).

Sebastian



More information about the cfe-commits mailing list