Skip to content

Commit 78ee0b9

Browse files
trivial member
1 parent 33178d4 commit 78ee0b9

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2595,6 +2595,11 @@ def CIR_FuncOp : CIR_Op<"func", [
25952595
/// Returns the kind of assignment operator (move, copy) this function
25962596
/// represents, if any.
25972597
std::optional<AssignKind> getCxxSpecialAssignKind();
2598+
2599+
/// Returns true if the function is a trivial C++ member functions such as
2600+
/// trivial default constructor, copy/move constructor, copy/move assignment,
2601+
/// or destructor.
2602+
bool isCxxTrivialMemberFunction();
25982603
}];
25992604

26002605
let hasCustomAssemblyFormat = 1;
@@ -4173,7 +4178,7 @@ def CIR_ObjSizeOp : CIR_Op<"objsize", [Pure]> {
41734178
When the `min` attribute is present, the operation returns the minimum
41744179
guaranteed accessible size. When absent (max mode), it returns the maximum
41754180
possible object size. Corresponds to `llvm.objectsize`'s `min` argument.
4176-
4181+
41774182
The `dynamic` attribute determines if the value should be evaluated at
41784183
runtime. Corresponds to `llvm.objectsize`'s `dynamic` argument.
41794184

clang/lib/CIR/Dialect/IR/CIRDialect.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "clang/CIR/Dialect/IR/CIROpsEnums.h"
1717
#include "clang/CIR/Dialect/IR/CIRTypes.h"
1818

19+
#include "mlir/IR/Attributes.h"
1920
#include "mlir/IR/DialectImplementation.h"
2021
#include "mlir/Interfaces/ControlFlowInterfaces.h"
2122
#include "mlir/Interfaces/FunctionImplementation.h"
@@ -1872,7 +1873,7 @@ bool cir::FuncOp::isCxxSpecialAssignment() {
18721873
}
18731874

18741875
std::optional<CtorKind> cir::FuncOp::getCxxConstructorKind() {
1875-
auto attr = getCxxSpecialMemberAttr();
1876+
mlir::Attribute attr = getCxxSpecialMemberAttr();
18761877
if (attr) {
18771878
if (auto ctor = dyn_cast<CXXCtorAttr>(attr))
18781879
return ctor.getCtorKind();
@@ -1881,14 +1882,27 @@ std::optional<CtorKind> cir::FuncOp::getCxxConstructorKind() {
18811882
}
18821883

18831884
std::optional<AssignKind> cir::FuncOp::getCxxSpecialAssignKind() {
1884-
auto attr = getCxxSpecialMemberAttr();
1885+
mlir::Attribute attr = getCxxSpecialMemberAttr();
18851886
if (attr) {
18861887
if (auto assign = dyn_cast<CXXAssignAttr>(attr))
18871888
return assign.getAssignKind();
18881889
}
18891890
return std::nullopt;
18901891
}
18911892

1893+
bool cir::FuncOp::isCxxTrivialMemberFunction() {
1894+
mlir::Attribute attr = getCxxSpecialMemberAttr();
1895+
if (attr) {
1896+
if (auto ctor = dyn_cast<CXXCtorAttr>(attr))
1897+
return ctor.getIsTrivial();
1898+
if (auto dtor = dyn_cast<CXXDtorAttr>(attr))
1899+
return dtor.getIsTrivial();
1900+
if (auto assign = dyn_cast<CXXAssignAttr>(attr))
1901+
return assign.getIsTrivial();
1902+
}
1903+
return false;
1904+
}
1905+
18921906
mlir::Region *cir::FuncOp::getCallableRegion() {
18931907
// TODO(CIR): This function will have special handling for aliases and a
18941908
// check for an external function, once those features have been upstreamed.

0 commit comments

Comments
 (0)