[PATCH] D147411: [clang-tidy] Fix readability-static-accessed-through-instance check for anonymous structs

Carlos Galvez via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 2 08:24:23 PDT 2023


carlosgalvezp added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp:78
+  // Ignore anonymous structs/classes
+  if (StringRef(BaseTypeName).contains("(unnamed "))
+    return;
----------------
AMS21 wrote:
> I wonder if there's a cleaner and more performant way to check this.
> I've tried `isAnonymousStructOrUnion()` from the `RecordDecl` but that seems to be about something else.
Indeed this seems brittle. Since `RecordDecl` inherits from `NamedDecl`, have you tried the `getName()` function? Hopefully it's an empty string and we can use that instead?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147411/new/

https://reviews.llvm.org/D147411



More information about the cfe-commits mailing list