[clang] [HLSL] Add implicit resource element type concepts to AST (PR #112600)
Damyan Pepper via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 18 09:48:47 PDT 2024
================
@@ -483,10 +573,103 @@ static BuiltinTypeDeclBuilder setupBufferType(CXXRecordDecl *Decl, Sema &S,
.addDefaultHandleConstructor(S, RC);
}
+BinaryOperator *getSizeOfLEQ16Expr(clang::ASTContext &context,
+ SourceLocation NameLoc,
+ TemplateTypeParmDecl *T) {
+ // Obtain the QualType for 'unsigned long'
+ clang::QualType unsignedLongType = context.UnsignedLongTy;
+
+ // Create a QualType that points to this TemplateTypeParmDecl
+ clang::QualType TType = context.getTypeDeclType(T);
+
+ // Create a TypeSourceInfo for the template type parameter 'T'
+ clang::TypeSourceInfo *TTypeSourceInfo =
+ context.getTrivialTypeSourceInfo(TType, NameLoc);
+
+ clang::UnaryExprOrTypeTraitExpr *sizeOfExpr = new (context)
+ clang::UnaryExprOrTypeTraitExpr(clang::UETT_SizeOf, TTypeSourceInfo,
+ unsignedLongType, NameLoc, NameLoc);
+
+ // Create an IntegerLiteral for the value '16' with size type
+ clang::QualType sizeType = context.getSizeType();
+ llvm::APInt sizeValue = llvm::APInt(context.getTypeSize(sizeType), 16);
+ clang::IntegerLiteral *sizeLiteral = new (context)
+ clang::IntegerLiteral(context, sizeValue, sizeType, NameLoc);
----------------
damyanp wrote:
These variables don't follow the expected naming convention (of starting with a capital letter).
* `sizeOfExpr`
* `sizeType`
* `sizeLiteral`
https://github.com/llvm/llvm-project/pull/112600
More information about the cfe-commits
mailing list