[cfe-commits] r60848 - in /cfe/trunk/lib: AST/ASTContext.cpp Sema/SemaExpr.cpp

Douglas Gregor dgregor at apple.com
Wed Dec 10 12:57:42 PST 2008


Author: dgregor
Date: Wed Dec 10 14:57:37 2008
New Revision: 60848

URL: http://llvm.org/viewvc/llvm-project?rev=60848&view=rev
Log:
Some cleanups to the dependent-types commit, as suggested by Sebastian

Modified:
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=60848&r1=60847&r2=60848&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Dec 10 14:57:37 2008
@@ -1210,7 +1210,6 @@
                                       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 @@
                                                   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 @@
                                                 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(),

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=60848&r1=60847&r2=60848&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Dec 10 14:57:37 2008
@@ -510,48 +510,48 @@
   // 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);





More information about the cfe-commits mailing list