[cfe-commits] r73641 - in /cfe/trunk: include/clang/AST/ASTContext.h include/clang/AST/Type.h include/clang/AST/TypeNodes.def lib/AST/ASTContext.cpp lib/AST/Type.cpp lib/Sema/Sema.h lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclAttr.cpp lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaDeclObjC.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaTemplate.cpp lib/Sema/SemaTemplateDeduction.cpp lib/Sema/SemaTemplateInstantiate.cpp lib/Sema/SemaType.cpp test/SemaTemplate/ext-vector-type.cpp

Chris Lattner clattner at apple.com
Wed Jun 17 17:28:34 PDT 2009


On Jun 17, 2009, at 2:52 PM, Douglas Gregor wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=73641&view=rev
> Log:
> Support dependent extended vector types and template instantiation
> thereof. Patch by Anders Johnsen!

Very cool!  This is a big enough feature that we should probably  
mention this in the user's manual, this is incredibly useful for  
vector programming.


+  /// getDependentSizedExtVectorType - Returns a non-unique reference  
to
+  /// the type for a dependently-sized vector of the specified element
+  /// type. FIXME: We will need these to be uniqued, or at least
+  /// comparable, at some point.
+  QualType getDependentSizedExtVectorType(QualType VectorType,
+                                          Expr *SizeExpr,
+                                          SourceLocation AttrLoc);

If this includes a Loc, uniquing will never reuse a type.  Is there  
really any reason to unique these?

> +++ cfe/trunk/include/clang/AST/Type.h Wed Jun 17 16:51:59 2009
> @@ -992,6 +992,41 @@
>
> +/// DependentSizedExtVectorType - This type represent an ext  
> vectory type

"This type represents an extended vector type..."

> +class DependentSizedExtVectorType : public Type {
> +  Expr *SizeExpr;
> +  /// ElementType - The element type of the array.
> +  QualType ElementType;
> +  SourceLocation loc;
> +
> +  DependentSizedExtVectorType(QualType ElementType, QualType can,
> +                              Expr *SizeExpr, SourceLocation loc)
> +    : Type (DependentSizedExtVector, can, true),
> +    SizeExpr(SizeExpr), ElementType(ElementType), loc(loc) {}
> +  friend class ASTContext;
> +  virtual void Destroy(ASTContext& C);
> +
> +public:
> +  Expr *getSizeExpr() const { return SizeExpr; }

This should return a const Expr*.

> @@ -1356,6 +1363,19 @@
>   getElementType().getAsStringInternal(S, Policy);
> }
>
> +void DependentSizedExtVectorType::getAsStringInternal(std::string  
> &S, const PrintingPolicy &Policy) const {
> +  getElementType().getAsStringInternal(S, Policy);
> +
> +  S += " __attribute__((ext_vector_  type(";

"  " typo?

> +++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Wed Jun 17 16:51:59  
> 2009
> @@ -802,6 +802,14 @@
>                                   Deduced);
>     break;
>
> +  case Type::DependentSizedExtVector: {
> +    const DependentSizedExtVectorType *VecType
> +    = cast<DependentSizedExtVectorType>(T.getTypePtr());

You shouldn't need ".getTypePtr()" here.  It looks like this file has  
the same issue in many places.

> +++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Wed Jun 17  
> 16:51:59 2009
> @@ -431,6 +431,32 @@
> }
>
> QualType
> +TemplateTypeInstantiator::
> +InstantiateDependentSizedExtVectorType(const  
> DependentSizedExtVectorType *T,
> +                                   unsigned Quals) const {
> +
> +  // Instantiate the element type if needed

Please end sentence comments with proper punctuation ("." in this case).
>
> +
> +  // Instantiate the size expression

likewise.

-Chris




More information about the cfe-commits mailing list