[Mlir-commits] [mlir] [MLIR] Fix TypeID anonymous namespace check to handle GCC's __PRETTY_FUNCTION__ format (PR #199634)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue May 26 01:52:29 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir-core

Author: Mieszko Dziadowiec (mieshkiwrk)

<details>
<summary>Changes</summary>

The anonymous namespace detection in `FallbackTypeIDResolver::registerImplicitTypeID` only checked for Clang's `(anonymous namespace)` and MSVC's `anonymous-namespace` formats. GCC produces `{anonymous}` in `__PRETTY_FUNCTION__`, silently bypassing the check.

---
Full diff: https://github.com/llvm/llvm-project/pull/199634.diff


1 Files Affected:

- (modified) mlir/lib/Support/TypeID.cpp (+7-5) 


``````````diff
diff --git a/mlir/lib/Support/TypeID.cpp b/mlir/lib/Support/TypeID.cpp
index 3526a0d49cc79..2c6193e78743e 100644
--- a/mlir/lib/Support/TypeID.cpp
+++ b/mlir/lib/Support/TypeID.cpp
@@ -30,12 +30,14 @@ struct ImplicitTypeIDRegistry {
     // Perform a heuristic check to see if this type is in an anonymous
     // namespace. String equality is not valid for anonymous types, so we try to
     // abort whenever we see them.
+    // Check all known anonymous-namespace markers unconditionally:
+    //   Clang : "(anonymous namespace)"
+    //   GCC   : "{anonymous}"
+    //   MSVC  : "anonymous-namespace"
 #ifndef NDEBUG
-#if defined(_MSC_VER)
-    if (typeName.contains("anonymous-namespace")) {
-#else
-    if (typeName.contains("anonymous namespace")) {
-#endif
+    if (typeName.contains("anonymous namespace") ||
+        typeName.contains("{anonymous}") ||
+        typeName.contains("anonymous-namespace")) {
       std::string errorStr;
       {
         llvm::raw_string_ostream errorOS(errorStr);

``````````

</details>


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


More information about the Mlir-commits mailing list