summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-12-10 20:57:37 +0000
committerDouglas Gregor <dgregor@apple.com>2008-12-10 20:57:37 +0000
commit872ffce2578cec519a1220e99f17e33c9515da2c (patch)
tree6afdc0cdd51567136672b65781c9362a8fd71ae6
parent13ac125edf4c57bc08cf861efb8fce243ac3388d (diff)
downloadbcm5719-llvm-872ffce2578cec519a1220e99f17e33c9515da2c.tar.gz
bcm5719-llvm-872ffce2578cec519a1220e99f17e33c9515da2c.zip
Some cleanups to the dependent-types commit, as suggested by Sebastian
llvm-svn: 60848
-rw-r--r--clang/lib/AST/ASTContext.cpp4
-rw-r--r--clang/lib/Sema/SemaExpr.cpp74
2 files changed, 37 insertions, 41 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 241dce6c95a..233a661a4c9 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1210,7 +1210,6 @@ QualType ASTContext::getCanonicalType(QualType T) {
DSAT->getSizeModifier(),
DSAT->getIndexTypeQualifier());
- // FIXME: What is the ownership of size expressions in VLAs?
VariableArrayType *VAT = cast<VariableArrayType>(AT);
return getVariableArrayType(NewEltTy, VAT->getSizeExpr(),
VAT->getSizeModifier(),
@@ -1283,8 +1282,6 @@ const ArrayType *ASTContext::getAsArrayType(QualType T) {
IAT->getSizeModifier(),
IAT->getIndexTypeQualifier()));
- // FIXME: What is the ownership of size expressions in
- // dependent-sized array types?
if (const DependentSizedArrayType *DSAT
= dyn_cast<DependentSizedArrayType>(ATy))
return cast<ArrayType>(
@@ -1293,7 +1290,6 @@ const ArrayType *ASTContext::getAsArrayType(QualType T) {
DSAT->getSizeModifier(),
DSAT->getIndexTypeQualifier()));
- // FIXME: What is the ownership of size expressions in VLAs?
const VariableArrayType *VAT = cast<VariableArrayType>(ATy);
return cast<ArrayType>(getVariableArrayType(NewEltTy, VAT->getSizeExpr(),
VAT->getSizeModifier(),
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index a2dc7f7c891..a36bcf58806 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -510,48 +510,48 @@ Sema::ExprResult Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
// If this reference is not in a block or if the referenced variable is
// within the block, create a normal DeclRefExpr.
- // C++ [temp.dep.expr]p3:
- // An id-expression is type-dependent if it contains:
bool TypeDependent = false;
-
- // - 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 if (SS && !SS->isEmpty()) {
- for (DeclContext *DC = static_cast<DeclContext*>(SS->getScopeRep());
- DC; DC = DC->getParent()) {
- // FIXME: could stop early at namespace scope.
- if (DC->isCXXRecord()) {
- CXXRecordDecl *Record = cast<CXXRecordDecl>(DC);
- if (Context.getTypeDeclType(Record)->isDependentType()) {
- TypeDependent = true;
- break;
+ 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 if (SS && !SS->isEmpty()) {
+ for (DeclContext *DC = static_cast<DeclContext*>(SS->getScopeRep());
+ DC; DC = DC->getParent()) {
+ // FIXME: could stop early at namespace scope.
+ if (DC->isCXXRecord()) {
+ 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:
- bool ValueDependent = false;
-
- // - 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
- // (FIXME!).
+ // 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
+ // (FIXME!).
+ }
return new DeclRefExpr(VD, VD->getType().getNonReferenceType(), Loc,
TypeDependent, ValueDependent);
OpenPOWER on IntegriCloud