aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-11-23 11:41:28 +0000
committerDouglas Gregor <dgregor@apple.com>2009-11-23 11:41:28 +0000
commit0da76df9218d7c27b471b0a4d83a5b29fe24e5b4 (patch)
tree5554847f7a17fd1f639cb65f3148c399e45da367 /lib/Sema/SemaExpr.cpp
parentf155dbf901b77f0faa90a48670c0bdae7fbdea2d (diff)
Centralize and complete the computation of value- and type-dependence for DeclRefExprs
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89649 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r--lib/Sema/SemaExpr.cpp57
1 files changed, 3 insertions, 54 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 42b49c5d0b..1506fbaf60 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -415,7 +415,6 @@ static bool ShouldSnapshotBlockValueReference(BlockSemaInfo *CurBlock,
/// BuildDeclRefExpr - Build a DeclRefExpr.
Sema::OwningExprResult
Sema::BuildDeclRefExpr(NamedDecl *D, QualType Ty, SourceLocation Loc,
- bool TypeDependent, bool ValueDependent,
const CXXScopeSpec *SS) {
assert(!isa<OverloadedFunctionDecl>(D));
@@ -445,8 +444,7 @@ Sema::BuildDeclRefExpr(NamedDecl *D, QualType Ty, SourceLocation Loc,
return Owned(DeclRefExpr::Create(Context,
SS? (NestedNameSpecifier *)SS->getScopeRep() : 0,
SS? SS->getRange() : SourceRange(),
- D, Loc,
- Ty, TypeDependent, ValueDependent));
+ D, Loc, Ty));
}
/// getObjectForAnonymousRecordDecl - Retrieve the (unnamed) field or
@@ -842,7 +840,7 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
QualType NoProtoType = T;
if (const FunctionProtoType *Proto = T->getAs<FunctionProtoType>())
NoProtoType = Context.getFunctionNoProtoType(Proto->getResultType());
- return BuildDeclRefExpr(Func, NoProtoType, Loc, false, false, SS);
+ return BuildDeclRefExpr(Func, NoProtoType, Loc, SS);
}
}
@@ -1139,56 +1137,7 @@ Sema::BuildDeclarationNameExpr(const CXXScopeSpec *SS,
// If this reference is not in a block or if the referenced variable is
// within the block, create a normal DeclRefExpr.
- bool TypeDependent = false;
- bool ValueDependent = false;
- if (getLangOptions().CPlusPlus) {
- // C++ [temp.dep.expr]p3:
- // An id-expression is type-dependent if it contains:
- // - an identifier that was declared with a dependent type,
- if (VD->getType()->isDependentType())
- TypeDependent = true;
- // - FIXME: a template-id that is dependent,
- // - a conversion-function-id that specifies a dependent type,
- else if (Name.getNameKind() == DeclarationName::CXXConversionFunctionName &&
- Name.getCXXNameType()->isDependentType())
- TypeDependent = true;
- // - a nested-name-specifier that contains a class-name that
- // names a dependent type.
- else {
- for (DeclContext *DC = D->getDeclContext(); DC; DC = DC->getParent()) {
- // FIXME: could stop early at namespace scope.
- if (DC->isRecord()) {
- CXXRecordDecl *Record = cast<CXXRecordDecl>(DC);
- if (Context.getTypeDeclType(Record)->isDependentType()) {
- TypeDependent = true;
- break;
- }
- }
- }
- }
-
- // C++ [temp.dep.constexpr]p2:
- //
- // An identifier is value-dependent if it is:
- // - a name declared with a dependent type,
- if (TypeDependent)
- ValueDependent = true;
- // - the name of a non-type template parameter,
- else if (isa<NonTypeTemplateParmDecl>(VD))
- ValueDependent = true;
- // - a constant with integral or enumeration type and is
- // initialized with an expression that is value-dependent
- else if (const VarDecl *Dcl = dyn_cast<VarDecl>(VD)) {
- if (Context.getCanonicalType(Dcl->getType()).getCVRQualifiers()
- == Qualifiers::Const &&
- Dcl->getInit()) {
- ValueDependent = Dcl->getInit()->isValueDependent();
- }
- }
- }
-
- return BuildDeclRefExpr(VD, VD->getType().getNonReferenceType(), Loc,
- TypeDependent, ValueDependent, SS);
+ return BuildDeclRefExpr(VD, VD->getType().getNonReferenceType(), Loc, SS);
}
Sema::OwningExprResult Sema::ActOnPredefinedExpr(SourceLocation Loc,