Skip to content

Commit 9939a0f

Browse files
committed
refactor
1 parent c9164ce commit 9939a0f

File tree

5 files changed

+31
-27
lines changed

5 files changed

+31
-27
lines changed

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

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,7 @@ def CIR_CXXCtorAttr : CIR_Attr<"CXXCtor", "cxx_ctor"> {
12991299
AttrBuilderWithInferredContext<(ins "mlir::Type":$type,
13001300
CArg<"CtorKind", "cir::CtorKind::Custom">:$ctorKind,
13011301
CArg<"std::optional<const clang::CXXRecordDecl *>",
1302-
"std::nullopt">:$recordDecl), [{
1302+
"std::nullopt">:$recordDecl), [{
13031303
return $_get(type.getContext(), type, ctorKind, recordDecl);
13041304
}]>
13051305
];
@@ -1310,27 +1310,18 @@ def CIR_CXXDtorAttr : CIR_Attr<"CXXDtor", "cxx_dtor"> {
13101310
let description = [{
13111311
Functions with this attribute are CXX destructors
13121312
}];
1313-
<<<<<<< HEAD
13141313
let parameters = (ins "mlir::Type":$type,
13151314
OptionalParameter<"std::optional<const clang::CXXRecordDecl *>">:$recordDecl);
1316-
=======
1317-
let parameters = (ins "mlir::Type":$type);
1318-
>>>>>>> origin/main
13191315

13201316
let assemblyFormat = [{
13211317
`<` $type `>`
13221318
}];
13231319

13241320
let builders = [
1325-
<<<<<<< HEAD
13261321
AttrBuilderWithInferredContext<(ins "mlir::Type":$type,
13271322
CArg<"std::optional<const clang::CXXRecordDecl *>",
1328-
"std::nullopt">:$recordDecl), [{
1323+
"std::nullopt">:$recordDecl), [{
13291324
return $_get(type.getContext(), type, recordDecl);
1330-
=======
1331-
AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{
1332-
return $_get(type.getContext(), type);
1333-
>>>>>>> origin/main
13341325
}]>
13351326
];
13361327
}

clang/test/CIR/Inputs/std-cxx.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,13 +288,13 @@ namespace std {
288288
typedef __vector_iterator<T, T *, T &> iterator;
289289
typedef __vector_iterator<T, const T *, const T &> const_iterator;
290290

291-
vector() : _start(0), _finish(0), _end_of_storage(0) {} // expected-remark {{found call to std::vector_cxx_ctor()}}
291+
vector() : _start(0), _finish(0), _end_of_storage(0) {}
292292
template <typename InputIterator>
293293
vector(InputIterator first, InputIterator last);
294294
vector(const vector &other);
295295
vector(vector &&other);
296296
explicit vector(size_type count);
297-
~vector(); // expected-remark{{found call to std::vector_cxx_dtor()}}
297+
~vector();
298298

299299
size_t size() const {
300300
return size_t(_finish - _start);

clang/test/CIR/Transforms/idiom-recognizer.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,3 @@ void iter_test() {
4747
yolo::array<unsigned char, 3> v = {1, 2, 3};
4848
(void)v.begin(); // no remark should be produced.
4949
}
50-
51-
void vector_test() {
52-
std::vector<int> v; // expected-remark {{found call to std::vector_cxx_ctor()}}
53-
54-
// BEFORE-IDIOM: cir.call @_ZNSt6vectorIiEC1Ev(
55-
// BEFORE-IDIOM: cir.call @_ZNSt6vectorIiED1Ev(
56-
// AFTER-IDIOM: cir.std.vector_cxx_ctor(
57-
// AFTER-IDIOM: cir.std.vector_cxx_dtor(
58-
// AFTER-LOWERING-PREPARE: cir.call @_ZNSt6vectorIiEC1Ev(
59-
// AFTER-LOWERING-PREPARE: cir.call @_ZNSt6vectorIiED1Ev(
60-
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -fclangir-idiom-recognizer -emit-cir -I%S/../Inputs -mmlir --mlir-print-ir-after-all %s -o - 2>&1 | FileCheck %s -check-prefix=PASS_ENABLED
2+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -fclangir -emit-cir -I%S/../Inputs -fclangir-idiom-recognizer="remarks=found-calls" -clangir-verify-diagnostics %s -o %t.cir
3+
4+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -fclangir -fclangir-idiom-recognizer -emit-cir -I%S/../Inputs -mmlir --mlir-print-ir-before=cir-idiom-recognizer %s -o - 2>&1 | FileCheck %s -check-prefix=BEFORE-IDIOM
5+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -fclangir -fclangir-idiom-recognizer -emit-cir -I%S/../Inputs -mmlir --mlir-print-ir-after=cir-idiom-recognizer %s -o - 2>&1 | FileCheck %s -check-prefix=AFTER-IDIOM
6+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -fclangir -fclangir-idiom-recognizer -emit-cir -I%S/../Inputs -mmlir --mlir-print-ir-after=cir-lowering-prepare %s -o - 2>&1 | FileCheck %s -check-prefix=AFTER-LOWERING-PREPARE
7+
8+
// PASS_ENABLED: IR Dump After IdiomRecognizer (cir-idiom-recognizer)
9+
10+
namespace std {
11+
template <typename T> class vector {
12+
public:
13+
vector() {} // expected-remark {{found call to std::vector_cxx_ctor()}}
14+
~vector() {}; // expected-remark{{found call to std::vector_cxx_dtor()}}
15+
};
16+
17+
void vector_test() {
18+
vector<int> v; // expected-remark {{found call to std::vector_cxx_ctor()}}
19+
20+
// BEFORE-IDIOM: cir.call @_ZNSt6vectorIiEC1Ev(
21+
// BEFORE-IDIOM: cir.call @_ZNSt6vectorIiED1Ev(
22+
// AFTER-IDIOM: cir.std.vector_cxx_ctor(
23+
// AFTER-IDIOM: cir.std.vector_cxx_dtor(
24+
// AFTER-LOWERING-PREPARE: cir.call @_ZNSt6vectorIiEC1Ev(
25+
// AFTER-LOWERING-PREPARE: cir.call @_ZNSt6vectorIiED1Ev(
26+
}
27+
}; // namespace std

code.c

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)