]> granicus.if.org Git - clang/commitdiff
Some cleanups suggested by Chris
authorDouglas Gregor <dgregor@apple.com>
Thu, 18 Jun 2009 18:45:36 +0000 (18:45 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 18 Jun 2009 18:45:36 +0000 (18:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73713 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Type.h
lib/AST/Type.cpp
lib/Sema/SemaTemplateDeduction.cpp
lib/Sema/SemaTemplateInstantiate.cpp

index f108bd5a45ee7a780b2a063ec5972c2424b2823d..ca55ea670b248a8a2db34cb2cba064bf59827f23 100644 (file)
@@ -994,7 +994,7 @@ public:
   }
 };
 
-/// DependentSizedExtVectorType - This type represent an ext vectory type
+/// DependentSizedExtVectorType - This type represent an extended vector type
 /// where either the type or size is dependent. For example:
 /// @code
 /// template<typename T, int Size>
@@ -1016,7 +1016,7 @@ class DependentSizedExtVectorType : public Type {
   virtual void Destroy(ASTContext& C);
 
 public:
-  Expr *getSizeExpr() const { return SizeExpr; }
+  const Expr *getSizeExpr() const { return SizeExpr; }
   QualType getElementType() const { return ElementType; }
   SourceLocation getAttributeLoc() const { return loc; }
 
index 1db666fdaeb8e424f657e1af0f30273b909c27cd..7b45b21e5d0c6697079c2b676712b10a905ad716 100644 (file)
@@ -1378,7 +1378,7 @@ void DependentSizedArrayType::getAsStringInternal(std::string &S, const Printing
 void DependentSizedExtVectorType::getAsStringInternal(std::string &S, const PrintingPolicy &Policy) const {
   getElementType().getAsStringInternal(S, Policy);
 
-  S += " __attribute__((ext_vector_  type(";
+  S += " __attribute__((ext_vector_type(";
   if (getSizeExpr()) {
     std::string SStr;
     llvm::raw_string_ostream s(SStr);
index 935883312e42243a2b63c71f87ba4c425c7b4aa8..784e451804aa90e9d54b50b37472d4ed5e565101 100644 (file)
@@ -725,12 +725,13 @@ MarkDeducedTemplateParameters(Sema &SemaRef,
 /// \brief Mark the template arguments that are deduced by the given
 /// expression.
 static void 
-MarkDeducedTemplateParameters(Expr *E, llvm::SmallVectorImpl<bool> &Deduced) {
-  DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E);
+MarkDeducedTemplateParameters(const Expr *E, 
+                              llvm::SmallVectorImpl<bool> &Deduced) {
+  const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E);
   if (!E)
     return;
 
-  NonTypeTemplateParmDecl *NTTP 
+  const NonTypeTemplateParmDecl *NTTP 
     = dyn_cast<NonTypeTemplateParmDecl>(DRE->getDecl());
   if (!NTTP)
     return;
@@ -751,26 +752,26 @@ MarkDeducedTemplateParameters(Sema &SemaRef, QualType T,
   switch (T->getTypeClass()) {
   case Type::ExtQual:
     MarkDeducedTemplateParameters(SemaRef, 
-                QualType(cast<ExtQualType>(T.getTypePtr())->getBaseType(), 0),
+                              QualType(cast<ExtQualType>(T)->getBaseType(), 0),
                                   Deduced);
     break;
 
   case Type::Pointer:
     MarkDeducedTemplateParameters(SemaRef,
-                          cast<PointerType>(T.getTypePtr())->getPointeeType(),
+                                  cast<PointerType>(T)->getPointeeType(),
                                   Deduced);
     break;
 
   case Type::BlockPointer:
     MarkDeducedTemplateParameters(SemaRef,
-                     cast<BlockPointerType>(T.getTypePtr())->getPointeeType(),
+                                  cast<BlockPointerType>(T)->getPointeeType(),
                                   Deduced);
     break;
 
   case Type::LValueReference:
   case Type::RValueReference:
     MarkDeducedTemplateParameters(SemaRef,
-                        cast<ReferenceType>(T.getTypePtr())->getPointeeType(),
+                                  cast<ReferenceType>(T)->getPointeeType(),
                                   Deduced);
     break;
 
@@ -783,35 +784,34 @@ MarkDeducedTemplateParameters(Sema &SemaRef, QualType T,
   }
 
   case Type::DependentSizedArray:
-    MarkDeducedTemplateParameters(
-                 cast<DependentSizedArrayType>(T.getTypePtr())->getSizeExpr(),
+    MarkDeducedTemplateParameters(cast<DependentSizedArrayType>(T)->getSizeExpr(),
                                   Deduced);
     // Fall through to check the element type
 
   case Type::ConstantArray:
   case Type::IncompleteArray:
     MarkDeducedTemplateParameters(SemaRef,
-                            cast<ArrayType>(T.getTypePtr())->getElementType(),
+                                  cast<ArrayType>(T)->getElementType(),
                                   Deduced);
     break;
 
   case Type::Vector:
   case Type::ExtVector:
     MarkDeducedTemplateParameters(SemaRef,
-                           cast<VectorType>(T.getTypePtr())->getElementType(),
+                                  cast<VectorType>(T)->getElementType(),
                                   Deduced);
     break;
 
   case Type::DependentSizedExtVector: {
     const DependentSizedExtVectorType *VecType
-    = cast<DependentSizedExtVectorType>(T.getTypePtr());
+      = cast<DependentSizedExtVectorType>(T);
     MarkDeducedTemplateParameters(SemaRef, VecType->getElementType(), Deduced);
     MarkDeducedTemplateParameters(VecType->getSizeExpr(), Deduced);
     break;
   }
 
   case Type::FunctionProto: {
-    const FunctionProtoType *Proto = cast<FunctionProtoType>(T.getTypePtr());
+    const FunctionProtoType *Proto = cast<FunctionProtoType>(T);
     MarkDeducedTemplateParameters(SemaRef, Proto->getResultType(), Deduced);
     for (unsigned I = 0, N = Proto->getNumArgs(); I != N; ++I)
       MarkDeducedTemplateParameters(SemaRef, Proto->getArgType(I), Deduced);
@@ -819,12 +819,12 @@ MarkDeducedTemplateParameters(Sema &SemaRef, QualType T,
   }
 
   case Type::TemplateTypeParm:
-    Deduced[cast<TemplateTypeParmType>(T.getTypePtr())->getIndex()] = true;
+    Deduced[cast<TemplateTypeParmType>(T)->getIndex()] = true;
     break;
 
   case Type::TemplateSpecialization: {
     const TemplateSpecializationType *Spec 
-      = cast<TemplateSpecializationType>(T.getTypePtr());
+      = cast<TemplateSpecializationType>(T);
     if (TemplateDecl *Template = Spec->getTemplateName().getAsTemplateDecl())
       if (TemplateTemplateParmDecl *TTP 
             = dyn_cast<TemplateTemplateParmDecl>(Template))
index 72f9511fdd816d240e04140d10aeb9da25b09e73..3992f8cbe53671d0ce6dd88713cea179a8bcc736 100644 (file)
@@ -435,7 +435,7 @@ TemplateTypeInstantiator::
 InstantiateDependentSizedExtVectorType(const DependentSizedExtVectorType *T,
                                    unsigned Quals) const {
 
-  // Instantiate the element type if needed
+  // Instantiate the element type if needed.
   QualType ElementType = T->getElementType();
   if (ElementType->isDependentType()) {
     ElementType = Instantiate(ElementType);
@@ -443,10 +443,10 @@ InstantiateDependentSizedExtVectorType(const DependentSizedExtVectorType *T,
       return QualType();
   }
 
-  // Instantiate the size expression
-  Expr *SizeExpr = T->getSizeExpr();
+  // Instantiate the size expression.
+  const Expr *SizeExpr = T->getSizeExpr();
   Sema::OwningExprResult InstantiatedArraySize = 
-    SemaRef.InstantiateExpr(SizeExpr, TemplateArgs);
+    SemaRef.InstantiateExpr(const_cast<Expr *>(SizeExpr), TemplateArgs);
   if (InstantiatedArraySize.isInvalid())
     return QualType();