tools/clang/lib/AST/HlslTypes.cpp
/// <summary>Returns the number of elements in the specified vector
/// type.</summary>
Returns the number of elements in the specified vector
type.
Returns the number of elements in the specified vector type .
uint32_t GetHLSLVecSize(clang::QualType type) {
  type = GetStructuralForm(type);
  const Type *Ty = type.getCanonicalType().getTypePtr();
  const RecordType *RT = dyn_cast<RecordType>(Ty);
  assert(RT != nullptr && "otherwise caller shouldn't be invoking this");
  const ClassTemplateSpecializationDecl *templateDecl =
      dyn_cast<ClassTemplateSpecializationDecl>(RT->getAsCXXRecordDecl());
  assert(templateDecl != nullptr &&
         "otherwise caller shouldn't be invoking this");
  assert(templateDecl->getName() == "vector" &&
         "otherwise caller shouldn't be invoking this");
  const TemplateArgumentList &argList = templateDecl->getTemplateArgs();
  const TemplateArgument &arg0 = argList[0];
  const TemplateArgument &arg1 = argList[1];
  QualType elemTy = arg0.getAsType();
  llvm::APSInt vecSize = arg1.getAsIntegral();
  return vecSize.getLimitedValue();
}
uint32_t GetHLSLVecSize ( clang :: QualType type ) { type = GetStructuralForm ( type ) ; const Type * Ty = type . getCanonicalType ( ) . getTypePtr ( ) ; const RecordType * RT = dyn_cast < RecordType > ( Ty ) ; assert ( RT != nullptr && " " ) ; const ClassTemplateSpecializationDecl * templateDecl = dyn_cast < ClassTemplateSpecializationDecl > ( RT -> getAsCXXRecordDecl ( ) ) ; assert ( templateDecl != nullptr && " " ) ; assert ( templateDecl -> getName ( ) == " " && " " ) ; const TemplateArgumentList & argList = templateDecl -> getTemplateArgs ( ) ; const TemplateArgument & arg0 = argList [ 0 ] ; const TemplateArgument & arg1 = argList [ 1 ] ; QualType elemTy = arg0 . getAsType ( ) ; llvm :: APSInt vecSize = arg1 . getAsIntegral ( ) ; return vecSize . getLimitedValue ( ) ; }
<summary>Returns the number of elements in the specified vector
type.</summary>
<summary > Returns the number of elements in the specified vector type . < / summary >