summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExprCXX.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-03-19 17:26:29 +0000
committerDouglas Gregor <dgregor@apple.com>2009-03-19 17:26:29 +0000
commit90a1a65194237f0fcd2c4bf847e0e8b4c419061c (patch)
tree9c3656f0c03a47912d4d1786159b9185af05e29d /clang/lib/AST/ExprCXX.cpp
parente4f361212b8aa2e0d587a6d173b3fb48808d400d (diff)
downloadbcm5719-llvm-90a1a65194237f0fcd2c4bf847e0e8b4c419061c.tar.gz
bcm5719-llvm-90a1a65194237f0fcd2c4bf847e0e8b4c419061c.zip
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. llvm-svn: 67308
Diffstat (limited to 'clang/lib/AST/ExprCXX.cpp')
-rw-r--r--clang/lib/AST/ExprCXX.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index f18a2888470..53be84b20d2 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -49,6 +49,29 @@ QualifiedDeclRefExpr::Create(ASTContext &Context, NamedDecl *d, QualType t,
NumComponents);
}
+UnresolvedDeclRefExpr::UnresolvedDeclRefExpr(DeclarationName N, QualType T,
+ SourceLocation L, SourceRange R,
+ const NestedNameSpecifier *Components,
+ unsigned NumComponents)
+ : Expr(UnresolvedDeclRefExprClass, T, true, true),
+ Name(N), Loc(L), QualifierRange(R), NumComponents(NumComponents) {
+ NestedNameSpecifier *Data
+ = reinterpret_cast<NestedNameSpecifier *>(this + 1);
+ for (unsigned I = 0; I < NumComponents; ++I)
+ Data[I] = Components[I];
+}
+
+UnresolvedDeclRefExpr *
+UnresolvedDeclRefExpr::Create(ASTContext &Context, DeclarationName N,
+ SourceLocation L, SourceRange R,
+ const NestedNameSpecifier *Components,
+ unsigned NumComponents) {
+ void *Mem = Context.Allocate((sizeof(UnresolvedDeclRefExpr) +
+ sizeof(NestedNameSpecifier) * NumComponents));
+ return new (Mem) UnresolvedDeclRefExpr(N, Context.DependentTy, L, R,
+ Components, NumComponents);
+}
+
//===----------------------------------------------------------------------===//
// Child Iterators for iterating over subexpressions/substatements
//===----------------------------------------------------------------------===//
@@ -164,6 +187,15 @@ Stmt::child_iterator UnaryTypeTraitExpr::child_end() {
return child_iterator();
}
+// UnresolvedDeclRefExpr
+StmtIterator UnresolvedDeclRefExpr::child_begin() {
+ return child_iterator();
+}
+
+StmtIterator UnresolvedDeclRefExpr::child_end() {
+ return child_iterator();
+}
+
bool UnaryTypeTraitExpr::EvaluateTrait() const {
switch(UTT) {
default: assert(false && "Unknown type trait or not implemented");
OpenPOWER on IntegriCloud