xref: /freebsd/contrib/llvm-project/clang/lib/CIR/CodeGen/CIRGenCXX.cpp (revision 700637cbb5e582861067a11aaca4d053546871d2)
1*700637cbSDimitry Andric //===----------------------------------------------------------------------===//
2*700637cbSDimitry Andric //
3*700637cbSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*700637cbSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*700637cbSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*700637cbSDimitry Andric //
7*700637cbSDimitry Andric //===----------------------------------------------------------------------===//
8*700637cbSDimitry Andric //
9*700637cbSDimitry Andric // This contains code dealing with C++ code generation.
10*700637cbSDimitry Andric //
11*700637cbSDimitry Andric //===----------------------------------------------------------------------===//
12*700637cbSDimitry Andric 
13*700637cbSDimitry Andric #include "CIRGenFunction.h"
14*700637cbSDimitry Andric #include "CIRGenModule.h"
15*700637cbSDimitry Andric 
16*700637cbSDimitry Andric #include "clang/AST/GlobalDecl.h"
17*700637cbSDimitry Andric #include "clang/CIR/MissingFeatures.h"
18*700637cbSDimitry Andric 
19*700637cbSDimitry Andric using namespace clang;
20*700637cbSDimitry Andric using namespace clang::CIRGen;
21*700637cbSDimitry Andric 
codegenCXXStructor(GlobalDecl gd)22*700637cbSDimitry Andric cir::FuncOp CIRGenModule::codegenCXXStructor(GlobalDecl gd) {
23*700637cbSDimitry Andric   const CIRGenFunctionInfo &fnInfo =
24*700637cbSDimitry Andric       getTypes().arrangeCXXStructorDeclaration(gd);
25*700637cbSDimitry Andric   cir::FuncType funcType = getTypes().getFunctionType(fnInfo);
26*700637cbSDimitry Andric   cir::FuncOp fn = getAddrOfCXXStructor(gd, &fnInfo, /*FnType=*/nullptr,
27*700637cbSDimitry Andric                                         /*DontDefer=*/true, ForDefinition);
28*700637cbSDimitry Andric   setFunctionLinkage(gd, fn);
29*700637cbSDimitry Andric   CIRGenFunction cgf{*this, builder};
30*700637cbSDimitry Andric   curCGF = &cgf;
31*700637cbSDimitry Andric   {
32*700637cbSDimitry Andric     mlir::OpBuilder::InsertionGuard guard(builder);
33*700637cbSDimitry Andric     cgf.generateCode(gd, fn, funcType);
34*700637cbSDimitry Andric   }
35*700637cbSDimitry Andric   curCGF = nullptr;
36*700637cbSDimitry Andric 
37*700637cbSDimitry Andric   setNonAliasAttributes(gd, fn);
38*700637cbSDimitry Andric   assert(!cir::MissingFeatures::opFuncAttributesForDefinition());
39*700637cbSDimitry Andric   return fn;
40*700637cbSDimitry Andric }
41