@@ -46,8 +46,11 @@ using namespace mlir::cir;
4646// CIR AST Attr helpers
4747// ===----------------------------------------------------------------------===//
4848
49- mlir::Attribute mlir::cir::makeAstDeclAttr (const clang::Decl *decl,
50- mlir::MLIRContext *ctx) {
49+ namespace mlir {
50+ namespace cir {
51+
52+ mlir::Attribute makeAstDeclAttr (const clang::Decl *decl,
53+ mlir::MLIRContext *ctx) {
5154 if (auto ast = clang::dyn_cast<clang::CXXConstructorDecl>(decl))
5255 return ASTCXXConstructorDeclAttr::get (ctx, ast);
5356 if (auto ast = clang::dyn_cast<clang::CXXConversionDecl>(decl))
@@ -78,6 +81,33 @@ mlir::Attribute mlir::cir::makeAstDeclAttr(const clang::Decl *decl,
7881 return ASTDeclAttr::get (ctx, decl);
7982};
8083
84+ mlir::Attribute makeFuncDeclAttr (const clang::Decl *decl,
85+ mlir::MLIRContext *ctx) {
86+ return llvm::TypeSwitch<const clang::Decl *, mlir::Attribute>(decl)
87+ .Case ([ctx](const clang::CXXConstructorDecl *ast) {
88+ return ASTCXXConstructorDeclAttr::get (ctx, ast);
89+ })
90+ .Case ([ctx](const clang::CXXConversionDecl *ast) {
91+ return ASTCXXConversionDeclAttr::get (ctx, ast);
92+ })
93+ .Case ([ctx](const clang::CXXDestructorDecl *ast) {
94+ return ASTCXXDestructorDeclAttr::get (ctx, ast);
95+ })
96+ .Case ([ctx](const clang::CXXMethodDecl *ast) {
97+ return ASTCXXMethodDeclAttr::get (ctx, ast);
98+ })
99+ .Case ([ctx](const clang::FunctionDecl *ast) {
100+ return ASTFunctionDeclAttr::get (ctx, ast);
101+ })
102+ .Default ([](auto ) {
103+ llvm_unreachable (" unexpected Decl kind" );
104+ return mlir::Attribute ();
105+ });
106+ }
107+
108+ } // namespace cir
109+ } // namespace mlir
110+
81111// ===----------------------------------------------------------------------===//
82112// General CIR parsing / printing
83113// ===----------------------------------------------------------------------===//
0 commit comments