]> granicus.if.org Git - clang/commitdiff
Some cleanups to the dependent-types commit, as suggested by Sebastian
authorDouglas Gregor <dgregor@apple.com>
Wed, 10 Dec 2008 20:57:37 +0000 (20:57 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 10 Dec 2008 20:57:37 +0000 (20:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60848 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp
lib/Sema/SemaExpr.cpp

index 241dce6c95abf893e43d45373e0bf5a96965f10f..233a661a4c9a0e62953a4282948422a30f3d2940 100644 (file)
@@ -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(),
index a2dc7f7c891367f89a4b84b45dd1d95a1a0e4fe2..a36bcf588065bedd45eb8ead6a11f39627f2b43b 100644 (file)
@@ -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);