[Mlir-commits] [mlir] [mlir][ODS] Add namespace filtering to `-gen-enum-*` (PR #89627)

Jeff Niu llvmlistbot at llvm.org
Mon Apr 22 10:56:32 PDT 2024


================
@@ -23,18 +25,32 @@
 #include "llvm/TableGen/Record.h"
 #include "llvm/TableGen/TableGenBackend.h"
 
+using namespace mlir;
+using namespace mlir::tblgen;
+
 using llvm::formatv;
 using llvm::isDigit;
 using llvm::PrintFatalError;
 using llvm::raw_ostream;
 using llvm::Record;
 using llvm::RecordKeeper;
-using llvm::StringRef;
-using mlir::tblgen::Attribute;
-using mlir::tblgen::EnumAttr;
-using mlir::tblgen::EnumAttrCase;
-using mlir::tblgen::FmtContext;
-using mlir::tblgen::tgfmt;
+
+/// Returns true if 'subNamespace' is a sub-namespace of 'parentNamespace'.
+/// I.e. 'subNamespace' is contained within 'parentNamespace'.
+static bool isSubNamespace(ArrayRef<StringRef> subNamespace,
+                           StringRef parentNamespace) {
+  SmallVector<StringRef> parentNamespaces;
+  llvm::SplitString(parentNamespace, parentNamespaces, "::");
----------------
Mogball wrote:

would be better to use a regex match here

https://github.com/llvm/llvm-project/pull/89627


More information about the Mlir-commits mailing list