[clang-tools-extra] Support renaming designated initializers (PR #86976)

Edwin Vane via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 2 05:34:17 PDT 2024


================
@@ -367,6 +367,25 @@ class RenamerClangTidyVisitor
     return true;
   }
 
+  bool VisitDesignatedInitExpr(DesignatedInitExpr *Expr) {
+    for (const auto &Designator : Expr->designators()) {
+      if (!Designator.isFieldDesignator())
+        continue;
+      auto *FieldDecl = Designator.getFieldDecl();
+      if (!FieldDecl)
+        continue;
+      auto *II = FieldDecl->getIdentifier();
+      if (!II)
+        continue;
+      SourceRange FixLocation{
+          Designator.getFieldLoc(),
+          Designator.getFieldLoc().getLocWithOffset(II->getLength())};
----------------
revane wrote:

You're right. Good to know!

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


More information about the cfe-commits mailing list