Skip to content

Commit 2fbcb01

Browse files
Merge remote-tracking branch 'main' into pub-do-not-fold
2 parents ae61a4d + 9efd798 commit 2fbcb01

File tree

79 files changed

+1310
-945
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1310
-945
lines changed

clang-tools-extra/clangd/unittests/XRefsTests.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2303,7 +2303,15 @@ TEST(FindReferences, WithinAST) {
23032303
bool $decl[[operator]]"" _u^dl(unsigned long long value);
23042304
bool x = $(x)[[1_udl]];
23052305
)cpp",
2306-
};
2306+
R"cpp(
2307+
struct S {
2308+
public:
2309+
static void $decl(S)[[operator]] delete(void *);
2310+
static void deleteObject(S *S) {
2311+
$(S::deleteObject)[[de^lete]] S;
2312+
}
2313+
};
2314+
)cpp"};
23072315
for (const char *Test : Tests)
23082316
checkFindRefs(Test);
23092317
}

clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
6161

6262
mlir::Value getConstAPInt(mlir::Location loc, mlir::Type typ,
6363
const llvm::APInt &val) {
64-
return create<cir::ConstantOp>(loc, typ, getAttr<cir::IntAttr>(typ, val));
64+
return create<cir::ConstantOp>(loc, getAttr<cir::IntAttr>(typ, val));
6565
}
6666

6767
cir::ConstantOp getConstant(mlir::Location loc, mlir::TypedAttr attr) {
68-
return create<cir::ConstantOp>(loc, attr.getType(), attr);
68+
return create<cir::ConstantOp>(loc, attr);
6969
}
7070

7171
cir::ConstantOp getConstantInt(mlir::Location loc, mlir::Type ty,
@@ -83,21 +83,17 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
8383
return getConstPtrAttr(t, 0);
8484
}
8585

86-
mlir::TypedAttr getZeroAttr(mlir::Type t) {
87-
return cir::ZeroAttr::get(getContext(), t);
88-
}
89-
9086
mlir::TypedAttr getZeroInitAttr(mlir::Type ty) {
9187
if (mlir::isa<cir::IntType>(ty))
9288
return cir::IntAttr::get(ty, 0);
9389
if (cir::isAnyFloatingPointType(ty))
9490
return cir::FPAttr::getZero(ty);
9591
if (auto arrTy = mlir::dyn_cast<cir::ArrayType>(ty))
96-
return getZeroAttr(arrTy);
92+
return cir::ZeroAttr::get(arrTy);
9793
if (auto ptrTy = mlir::dyn_cast<cir::PointerType>(ty))
9894
return getConstNullPtrAttr(ptrTy);
9995
if (auto recordTy = mlir::dyn_cast<cir::RecordType>(ty))
100-
return getZeroAttr(recordTy);
96+
return cir::ZeroAttr::get(recordTy);
10197
if (mlir::isa<cir::BoolType>(ty)) {
10298
return getFalseAttr();
10399
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ def ZeroAttr : CIR_Attr<"Zero", "zero", [TypedAttrInterface]> {
7171
}];
7272

7373
let parameters = (ins AttributeSelfTypeParameter<"">:$type);
74+
75+
let builders = [
76+
AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{
77+
return $_get(type.getContext(), type);
78+
}]>
79+
];
80+
7481
let assemblyFormat = [{}];
7582
}
7683

@@ -86,6 +93,13 @@ def UndefAttr : CIR_Attr<"Undef", "undef", [TypedAttrInterface]> {
8693
}];
8794

8895
let parameters = (ins AttributeSelfTypeParameter<"">:$type);
96+
97+
let builders = [
98+
AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{
99+
return $_get(type.getContext(), type);
100+
}]>
101+
];
102+
89103
let assemblyFormat = [{}];
90104
}
91105

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -288,18 +288,9 @@ def ConstantOp : CIR_Op<"const",
288288
```
289289
}];
290290

291-
// The constant operation takes an attribute as the only input.
292291
let arguments = (ins TypedAttrInterface:$value);
293-
294-
// The constant operation returns a single value of CIR_AnyType.
295292
let results = (outs CIR_AnyType:$res);
296293

297-
let builders = [
298-
OpBuilder<(ins "cir::BoolAttr":$value), [{
299-
build($_builder, $_state, value.getType(), value);
300-
}]>
301-
];
302-
303294
let assemblyFormat = "attr-dict $value";
304295

305296
let hasVerifier = 1;

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9079,6 +9079,7 @@ def _SLASH_clr : CLJoined<"clr">;
90799079
def _SLASH_d1 : CLJoined<"d1">;
90809080
def _SLASH_d2 : CLJoined<"d2">;
90819081
def _SLASH_doc : CLJoined<"doc">;
9082+
def _SLASH_dynamicdeopt : CLJoined<"dynamicdeopt">;
90829083
def _SLASH_experimental : CLJoined<"experimental:">;
90839084
def _SLASH_exportHeader : CLFlag<"exportHeader">;
90849085
def _SLASH_external : CLJoined<"external:">;

clang/lib/CIR/CodeGen/CIRGenBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
185185
// Creates constant nullptr for pointer type ty.
186186
cir::ConstantOp getNullPtr(mlir::Type ty, mlir::Location loc) {
187187
assert(!cir::MissingFeatures::targetCodeGenInfoGetNullPointer());
188-
return create<cir::ConstantOp>(loc, ty, getConstPtrAttr(ty, 0));
188+
return create<cir::ConstantOp>(loc, getConstPtrAttr(ty, 0));
189189
}
190190

191191
mlir::Value createNeg(mlir::Value value) {

clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ emitArrayConstant(CIRGenModule &cgm, mlir::Type desiredType,
183183
}
184184

185185
if (nonzeroLength == 0)
186-
return cir::ZeroAttr::get(builder.getContext(), desiredType);
186+
return cir::ZeroAttr::get(desiredType);
187187

188188
const unsigned trailingZeroes = arrayBound - nonzeroLength;
189189

clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
138138
mlir::Value VisitIntegerLiteral(const IntegerLiteral *e) {
139139
mlir::Type type = cgf.convertType(e->getType());
140140
return builder.create<cir::ConstantOp>(
141-
cgf.getLoc(e->getExprLoc()), type,
141+
cgf.getLoc(e->getExprLoc()),
142142
builder.getAttr<cir::IntAttr>(type, e->getValue()));
143143
}
144144

@@ -147,7 +147,7 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
147147
assert(mlir::isa<cir::CIRFPTypeInterface>(type) &&
148148
"expect floating-point type");
149149
return builder.create<cir::ConstantOp>(
150-
cgf.getLoc(e->getExprLoc()), type,
150+
cgf.getLoc(e->getExprLoc()),
151151
builder.getAttr<cir::FPAttr>(type, e->getValue()));
152152
}
153153

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ llvm::SmallVector<MemorySlot> cir::AllocaOp::getPromotableSlots() {
3434

3535
Value cir::AllocaOp::getDefaultValue(const MemorySlot &slot,
3636
OpBuilder &builder) {
37-
return builder.create<cir::ConstantOp>(
38-
getLoc(), slot.elemType, builder.getAttr<cir::UndefAttr>(slot.elemType));
37+
return builder.create<cir::ConstantOp>(getLoc(),
38+
cir::UndefAttr::get(slot.elemType));
3939
}
4040

4141
void cir::AllocaOp::handleBlockArgument(const MemorySlot &slot,

clang/lib/Index/IndexBody.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,20 @@ class BodyIndexer : public RecursiveASTVisitor<BodyIndexer> {
153153
ParentDC);
154154
}
155155

156+
bool VisitCXXNewExpr(CXXNewExpr *E) {
157+
if (E->isGlobalNew() || !E->getOperatorNew())
158+
return true;
159+
return IndexCtx.handleReference(E->getOperatorNew(), E->getBeginLoc(),
160+
Parent, ParentDC);
161+
}
162+
163+
bool VisitCXXDeleteExpr(CXXDeleteExpr *E) {
164+
if (E->isGlobalDelete() || !E->getOperatorDelete())
165+
return true;
166+
return IndexCtx.handleReference(E->getOperatorDelete(), E->getBeginLoc(),
167+
Parent, ParentDC);
168+
}
169+
156170
bool VisitLabelStmt(LabelStmt *S) {
157171
if (IndexCtx.shouldIndexFunctionLocalSymbols())
158172
return IndexCtx.handleDecl(S->getDecl());

0 commit comments

Comments
 (0)