[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
Thu Jun 18 15:31:50 PDT 2009


On Jun 18, 2009, at 3:08 PM, Douglas Gregor wrote:

>
> On Jun 17, 2009, at 5:28 PM, Chris Lattner wrote:
>
>> 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.
>
> Once we can deduce the length of a vector as part of template  
> argument deduction, it will become incredibly useful. We're not  
> quite there yet.

Ok!

>>> +++ 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.
>
> What isa/cast/dyn_cast devilry is this, and how did I go so long  
> without realizing it?

Template specialization of course!  From Type.h:

namespace llvm {
/// Implement simplify_type for QualType, so that we can dyn_cast from  
QualType
/// to a specific Type class.
template<> struct simplify_type<const ::clang::QualType> {
   typedef ::clang::Type* SimpleType;
   static SimpleType getSimplifiedValue(const ::clang::QualType &Val) {
     return Val.getTypePtr();
   }
};
template<> struct simplify_type< ::clang::QualType>
   : public simplify_type<const ::clang::QualType> {};


This sort of thing is very useful for smart pointers.

> Both fixed.
>
> Thanks!


Thanks Doug!

-Chris



More information about the cfe-commits mailing list