[clang] [clang][ThreadSafety] Resolve fields named from nested struct/union members (PR #233965)

Marco Elver via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 26 03:53:46 PDT 2026


================
@@ -645,35 +645,73 @@ class PrettyPrinter {
     }
   }
 
+  // An anonymous struct/union member has no name to print. This includes the
+  // implicit member -fms-extensions adds for a tagged anonymous struct.
+  static bool isAnonymousProjection(const Project *E) {
----------------
melver wrote:

When Cvdecl has an empty DeclarationName, Cvdecl->getDeclName().isIdentifier() is false, so E->slotName() populates the `std::optional<std::string>` cache via llvm::raw_string_ostream and Cvdecl->printName(OS) just to produce "". Checking getDeclName().isEmpty() directly avoids that overhead:

```
       static bool isAnonymousProjection(const Project *E) {
    -    return E->slotName().empty();
    +    return E->clangDecl()->getDeclName().isEmpty();
       }
```

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


More information about the cfe-commits mailing list