aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/AST/Expr.h16
-rw-r--r--lib/AST/Expr.cpp4
-rw-r--r--lib/CodeGen/CGBlocks.cpp2
-rw-r--r--lib/Frontend/PCHReaderStmt.cpp2
-rw-r--r--lib/Sema/Sema.h2
-rw-r--r--lib/Sema/SemaExpr.cpp2
-rw-r--r--lib/Sema/SemaTemplateInstantiate.cpp21
-rw-r--r--lib/Sema/TreeTransform.h50
8 files changed, 45 insertions, 54 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index 2b8e221e87..116d89df97 100644
--- a/include/clang/AST/Expr.h
+++ b/include/clang/AST/Expr.h
@@ -389,7 +389,7 @@ class DeclRefExpr : public Expr {
// indicate whether (1) the declaration's name was explicitly qualified and
// (2) the declaration's name was followed by an explicit template
// argument list.
- llvm::PointerIntPair<NamedDecl *, 2> DecoratedD;
+ llvm::PointerIntPair<ValueDecl *, 2> DecoratedD;
// Loc - The location of the declaration name itself.
SourceLocation Loc;
@@ -427,7 +427,7 @@ class DeclRefExpr : public Expr {
}
DeclRefExpr(NestedNameSpecifier *Qualifier, SourceRange QualifierRange,
- NamedDecl *D, SourceLocation NameLoc,
+ ValueDecl *D, SourceLocation NameLoc,
const TemplateArgumentListInfo *TemplateArgs,
QualType T);
@@ -436,13 +436,13 @@ protected:
/// declaration reference expression.
void computeDependence();
- DeclRefExpr(StmtClass SC, NamedDecl *d, QualType t, SourceLocation l) :
+ DeclRefExpr(StmtClass SC, ValueDecl *d, QualType t, SourceLocation l) :
Expr(SC, t, false, false), DecoratedD(d, 0), Loc(l) {
computeDependence();
}
public:
- DeclRefExpr(NamedDecl *d, QualType t, SourceLocation l) :
+ DeclRefExpr(ValueDecl *d, QualType t, SourceLocation l) :
Expr(DeclRefExprClass, t, false, false), DecoratedD(d, 0), Loc(l) {
computeDependence();
}
@@ -454,14 +454,14 @@ public:
static DeclRefExpr *Create(ASTContext &Context,
NestedNameSpecifier *Qualifier,
SourceRange QualifierRange,
- NamedDecl *D,
+ ValueDecl *D,
SourceLocation NameLoc,
QualType T,
const TemplateArgumentListInfo *TemplateArgs = 0);
- NamedDecl *getDecl() { return DecoratedD.getPointer(); }
- const NamedDecl *getDecl() const { return DecoratedD.getPointer(); }
- void setDecl(NamedDecl *NewD) { DecoratedD.setPointer(NewD); }
+ ValueDecl *getDecl() { return DecoratedD.getPointer(); }
+ const ValueDecl *getDecl() const { return DecoratedD.getPointer(); }
+ void setDecl(ValueDecl *NewD) { DecoratedD.setPointer(NewD); }
SourceLocation getLocation() const { return Loc; }
void setLocation(SourceLocation L) { Loc = L; }
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index db7d94dba6..5823b4fa38 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -110,7 +110,7 @@ void DeclRefExpr::computeDependence() {
DeclRefExpr::DeclRefExpr(NestedNameSpecifier *Qualifier,
SourceRange QualifierRange,
- NamedDecl *D, SourceLocation NameLoc,
+ ValueDecl *D, SourceLocation NameLoc,
const TemplateArgumentListInfo *TemplateArgs,
QualType T)
: Expr(DeclRefExprClass, T, false, false),
@@ -133,7 +133,7 @@ DeclRefExpr::DeclRefExpr(NestedNameSpecifier *Qualifier,
DeclRefExpr *DeclRefExpr::Create(ASTContext &Context,
NestedNameSpecifier *Qualifier,
SourceRange QualifierRange,
- NamedDecl *D,
+ ValueDecl *D,
SourceLocation NameLoc,
QualType T,
const TemplateArgumentListInfo *TemplateArgs) {
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp
index 9fc2c1a97d..9e44db0aa0 100644
--- a/lib/CodeGen/CGBlocks.cpp
+++ b/lib/CodeGen/CGBlocks.cpp
@@ -296,7 +296,7 @@ llvm::Value *CodeGenFunction::BuildBlockLiteralTmp(const BlockExpr *BE) {
++helpersize;
continue;
} else
- E = new (getContext()) DeclRefExpr (cast<NamedDecl>(VD),
+ E = new (getContext()) DeclRefExpr (VD,
VD->getType(),
SourceLocation());
}
diff --git a/lib/Frontend/PCHReaderStmt.cpp b/lib/Frontend/PCHReaderStmt.cpp
index b2fc644c6d..f28e61e1ec 100644
--- a/lib/Frontend/PCHReaderStmt.cpp
+++ b/lib/Frontend/PCHReaderStmt.cpp
@@ -349,7 +349,7 @@ unsigned PCHStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
unsigned PCHStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
VisitExpr(E);
- E->setDecl(cast<NamedDecl>(Reader.GetDecl(Record[Idx++])));
+ E->setDecl(cast<ValueDecl>(Reader.GetDecl(Record[Idx++])));
E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
// FIXME: read qualifier
// FIXME: read explicit template arguments
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index 205ceb7e5b..46a87cff3f 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -1448,7 +1448,7 @@ public:
bool isAddressOfOperand,
const TemplateArgumentListInfo *TemplateArgs);
- OwningExprResult BuildDeclRefExpr(NamedDecl *D, QualType Ty,
+ OwningExprResult BuildDeclRefExpr(ValueDecl *D, QualType Ty,
SourceLocation Loc,
const CXXScopeSpec *SS = 0);
VarDecl *BuildAnonymousStructUnionMemberPath(FieldDecl *Field,
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 28a826f555..776ea71f29 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -415,7 +415,7 @@ static bool ShouldSnapshotBlockValueReference(BlockSemaInfo *CurBlock,
/// BuildDeclRefExpr - Build a DeclRefExpr.
Sema::OwningExprResult
-Sema::BuildDeclRefExpr(NamedDecl *D, QualType Ty, SourceLocation Loc,
+Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, SourceLocation Loc,
const CXXScopeSpec *SS) {
if (Context.getCanonicalType(Ty) == Context.UndeducedAutoTy) {
Diag(Loc,
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index 6158acbe9c..93df9cab02 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -782,25 +782,8 @@ TemplateInstantiator::TransformDeclRefExpr(DeclRefExpr *E,
// FindInstantiatedDecl will find it in the local instantiation scope.
}
- NamedDecl *InstD = SemaRef.FindInstantiatedDecl(D, TemplateArgs);
- if (!InstD)
- return SemaRef.ExprError();
-
- assert(!isa<UsingDecl>(InstD) && "decl ref instantiated to UsingDecl");
-
- CXXScopeSpec SS;
- NestedNameSpecifier *Qualifier = 0;
- if (E->getQualifier()) {
- Qualifier = TransformNestedNameSpecifier(E->getQualifier(),
- E->getQualifierRange());
- if (!Qualifier)
- return SemaRef.ExprError();
-
- SS.setScopeRep(Qualifier);
- SS.setRange(E->getQualifierRange());
- }
-
- return SemaRef.BuildDeclarationNameExpr(SS, E->getLocation(), InstD);
+ return TreeTransform<TemplateInstantiator>::
+ TransformDeclRefExpr(E, isAddressOfOperand);
}
Sema::OwningExprResult TemplateInstantiator::TransformCXXDefaultArgExpr(
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index 5f2ae604de..155e2e4a7d 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -830,15 +830,15 @@ public:
/// Subclasses may override this routine to provide different behavior.
OwningExprResult RebuildDeclRefExpr(NestedNameSpecifier *Qualifier,
SourceRange QualifierRange,
- NamedDecl *ND, SourceLocation Loc,
- bool isAddressOfOperand) {
+ ValueDecl *VD, SourceLocation Loc,
+ TemplateArgumentListInfo *TemplateArgs) {
CXXScopeSpec SS;
SS.setScopeRep(Qualifier);
SS.setRange(QualifierRange);
- return getSema().BuildDeclarationNameExpr(Loc, ND,
- /*FIXME:*/false,
- &SS,
- isAddressOfOperand);
+
+ // FIXME: loses template args.
+
+ return getSema().BuildDeclarationNameExpr(SS, Loc, VD);
}
/// \brief Build a new expression in parentheses.
@@ -3484,31 +3484,39 @@ TreeTransform<Derived>::TransformDeclRefExpr(DeclRefExpr *E,
if (!Qualifier)
return SemaRef.ExprError();
}
-
- NamedDecl *ND
- = dyn_cast_or_null<NamedDecl>(getDerived().TransformDecl(E->getDecl()));
+
+ ValueDecl *ND
+ = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getDecl()));
if (!ND)
return SemaRef.ExprError();
if (!getDerived().AlwaysRebuild() &&
Qualifier == E->getQualifier() &&
ND == E->getDecl() &&
- !E->hasExplicitTemplateArgumentList())
- return SemaRef.Owned(E->Retain());
+ !E->hasExplicitTemplateArgumentList()) {
- // FIXME: We're losing the explicit template arguments in this transformation.
+ // Mark it referenced in the new context regardless.
+ // FIXME: this is a bit instantiation-specific.
+ SemaRef.MarkDeclarationReferenced(E->getLocation(), ND);
- llvm::SmallVector<TemplateArgumentLoc, 4> TransArgs(E->getNumTemplateArgs());
- for (unsigned I = 0, N = E->getNumTemplateArgs(); I != N; ++I) {
- if (getDerived().TransformTemplateArgument(E->getTemplateArgs()[I],
- TransArgs[I]))
- return SemaRef.ExprError();
+ return SemaRef.Owned(E->Retain());
}
-
- // FIXME: Pass the qualifier/qualifier range along.
+
+ TemplateArgumentListInfo TransArgs, *TemplateArgs = 0;
+ if (E->hasExplicitTemplateArgumentList()) {
+ TemplateArgs = &TransArgs;
+ TransArgs.setLAngleLoc(E->getLAngleLoc());
+ TransArgs.setRAngleLoc(E->getRAngleLoc());
+ for (unsigned I = 0, N = E->getNumTemplateArgs(); I != N; ++I) {
+ TemplateArgumentLoc Loc;
+ if (getDerived().TransformTemplateArgument(E->getTemplateArgs()[I], Loc))
+ return SemaRef.ExprError();
+ TransArgs.addArgument(Loc);
+ }
+ }
+
return getDerived().RebuildDeclRefExpr(Qualifier, E->getQualifierRange(),
- ND, E->getLocation(),
- isAddressOfOperand);
+ ND, E->getLocation(), TemplateArgs);
}
template<typename Derived>