tools/clang/lib/AST/ASTContextHLSL.cpp
/// <summary>Creates a typedef for a vector shorthand (eg, float3).</summary>
Creates a typedef for a vector shorthand .
Creates a typedef for a vector shorthand .
TypedefDecl* hlsl::CreateVectorSpecializationShorthand(
  ASTContext& context,
  QualType vectorSpecialization,
  HLSLScalarType scalarType,
  size_t colCount)
{
  DXASSERT(colCount <= 4, "else caller didn't validate colCount");
  char typeName[64];
  sprintf_s(typeName, _countof(typeName), "%s%u",
    HLSLScalarTypeNames[scalarType], (unsigned)colCount);
  IdentifierInfo& typedefId = context.Idents.get(StringRef(typeName), tok::TokenKind::identifier);
  DeclContext* currentDeclContext = context.getTranslationUnitDecl();
  TypedefDecl* decl = TypedefDecl::Create(context, currentDeclContext, NoLoc, NoLoc, &typedefId,
    context.getTrivialTypeSourceInfo(vectorSpecialization, NoLoc));
  decl->setImplicit(true);
  currentDeclContext->addDecl(decl);
  return decl;
}
TypedefDecl * hlsl :: CreateVectorSpecializationShorthand ( ASTContext & context , QualType vectorSpecialization , HLSLScalarType scalarType , size_t colCount ) { DXASSERT ( colCount <= 4 , " " ) ; char typeName [ 64 ] ; sprintf_s ( typeName , _countof ( typeName ) , " " , HLSLScalarTypeNames [ scalarType ] , ( unsigned ) colCount ) ; IdentifierInfo & typedefId = context . Idents . get ( StringRef ( typeName ) , tok :: TokenKind :: identifier ) ; DeclContext * currentDeclContext = context . getTranslationUnitDecl ( ) ; TypedefDecl * decl = TypedefDecl :: Create ( context , currentDeclContext , NoLoc , NoLoc , & typedefId , context . getTrivialTypeSourceInfo ( vectorSpecialization , NoLoc ) ) ; decl -> setImplicit ( true ) ; currentDeclContext -> addDecl ( decl ) ; return decl ; }
<summary>Creates a typedef for a vector shorthand (eg, float3).</summary>
<summary > Creates a typedef for a vector shorthand ( eg float3 ) . < / summary >