[Mlir-commits] [mlir] 84430ab - [mlir][tblgen] Suppress deprecation warnings in deprecated create wrappers (#234953)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Oct 29 15:50:27 PDT 2026
Author: Morris Hafner
Date: 2026-10-29T15:50:22-07:00
New Revision: 84430ab8aaced85a8130877e298dcdf0831d214f
URL: https://github.com/llvm/llvm-project/commit/84430ab8aaced85a8130877e298dcdf0831d214f
DIFF: https://github.com/llvm/llvm-project/commit/84430ab8aaced85a8130877e298dcdf0831d214f.diff
LOG: [mlir][tblgen] Suppress deprecation warnings in deprecated create wrappers (#234953)
MSVC diagnoses `deprecated` calls inside `deprecated` functions.
Suppress such warnings by wrapping the deprecated function bodies with
warning suppression macros.
Assisted-by: Codex
Added:
Modified:
mlir/test/mlir-tblgen/op-decl-and-defs.td
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
Removed:
################################################################################
diff --git a/mlir/test/mlir-tblgen/op-decl-and-defs.td b/mlir/test/mlir-tblgen/op-decl-and-defs.td
index ed398e3319cb8e..5bc9117f450bb1 100644
--- a/mlir/test/mlir-tblgen/op-decl-and-defs.td
+++ b/mlir/test/mlir-tblgen/op-decl-and-defs.td
@@ -166,8 +166,26 @@ def NS_AOp : NS_Op<"a_op", [IsolatedFromAbove, IsolatedFromAbove]> {
// DEFS: ::mlir::detail::appendAttributeProperty(attrs, "attr1", prop.attr1);
// DEFS: void AOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes, unsigned numRegions) {
// DEFS: buildPropertiesAndDiscardableAttributes(odsState, attributes);
+// DEFS: AOp AOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes, unsigned numRegions) {
+// DEFS-NEXT: LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH
+// DEFS: build(builder, __state__,
+// DEFS: return ::llvm::cast<AOp>(__res__);
+// DEFS-NEXT: LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP
+// DEFS-NEXT: }
+// DEFS: AOp AOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes, unsigned numRegions) {
+// DEFS-NEXT: LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH
+// DEFS: return create(builder, builder.getLoc(),
+// DEFS-NEXT: LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP
+// DEFS-NEXT: }
// DEFS: void AOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes, unsigned numRegions) {
// DEFS: odsState.useProperties(const_cast<Properties&>(properties));
+// DEFS: AOp AOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes, unsigned numRegions) {
+// DEFS-NOT: LLVM_SUPPRESS_DEPRECATED_DECLARATIONS
+// DEFS: return ::llvm::cast<AOp>(__res__);
+// DEFS-NEXT: }
+// DEFS: AOp AOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes, unsigned numRegions) {
+// DEFS-NEXT: return create(builder, builder.getLoc(),
+// DEFS-NEXT: }
// DEFS-LABEL: void AOp::buildPropertiesAndDiscardableAttributes
// DEFS: Properties &properties = odsState.getOrAddProperties<Properties>();
// DEFS-NEXT: populateDefaultProperties(odsState.name, properties);
diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index 48158b6b148aab..62d057af2132b4 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -2446,13 +2446,25 @@ void OpEmitter::genInlineCreateBody(
nonBuilderStateArgs = ", " + nonBuilderStateArgs;
}
- if (cWithLoc)
+ // MSVC diagnoses deprecated calls even inside deprecated functions.
+ // Keep compatibility wrappers quiet without hiding warnings at call sites.
+ if (cWithLoc) {
+ if (deprecated)
+ cWithLoc->body() << "LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH\n";
cWithLoc->body() << llvm::formatv(inlineCreateBody, locParamName,
nonBuilderStateArgs,
opClass.getClassName());
- if (cImplicitLoc)
+ if (deprecated)
+ cWithLoc->body() << "LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP\n";
+ }
+ if (cImplicitLoc) {
+ if (deprecated)
+ cImplicitLoc->body() << "LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH\n";
cImplicitLoc->body() << llvm::formatv(inlineCreateBodyImplicitLoc,
nonBuilderStateArgs);
+ if (deprecated)
+ cImplicitLoc->body() << "LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP\n";
+ }
}
void OpEmitter::genSeparateArgParamBuilder() {
More information about the Mlir-commits
mailing list