[clang-tools-extra] [clang-tidy] Add MLIR check for old op builder usage. (PR #149148)
Jacques Pienaar via cfe-commits
cfe-commits at lists.llvm.org
Sun Jul 20 05:09:00 PDT 2025
================
@@ -0,0 +1,51 @@
+// RUN: %check_clang_tidy --match-partial-fixes %s llvm-mlir-op-builder %t
+
+namespace mlir {
+class Location {};
+class OpBuilder {
+public:
+ template <typename OpTy, typename... Args>
+ OpTy create(Location location, Args &&...args) {
+ return OpTy(args...);
+ }
+ Location getUnknownLoc() { return Location(); }
+};
+class ImplicitLocOpBuilder : public OpBuilder {
+public:
+ template <typename OpTy, typename... Args>
+ OpTy create(Args &&...args) {
+ return OpTy(args...);
+ }
+};
+struct ModuleOp {
+ ModuleOp() {}
+ static ModuleOp create(OpBuilder &builder, Location location) {
+ return ModuleOp();
+ }
+};
+struct NamedOp {
+ NamedOp(const char* name) {}
+ static NamedOp create(OpBuilder &builder, Location location, const char* name) {
+ return NamedOp(name);
+ }
+};
+} // namespace mlir
+
+void f() {
----------------
jpienaar wrote:
For the macro case, the matcher matches, but the rewrite is never attempted. Its been a few years since I last wrote a clang-tidy check, so not sure why. If I change to a noopEdit then it is flagged not sure if due to returning an ASTEdit rather than EditGenerator. Using the latter may be possible, is rather low level but perhaps possible. Is there a pattern I'm missing here?
https://github.com/llvm/llvm-project/pull/149148
More information about the cfe-commits
mailing list