<div dir="ltr">I guess you need me or Michael to push this.  Happy to do so once you're happy with it.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 12, 2021 at 11:33 AM Daniele Castagna via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">dcastagna updated this revision to Diff 336912.<br>
dcastagna added a comment.<br>
<br>
clang-format again<br>
<br>
<br>
Repository:<br>
  rG LLVM Github Monorepo<br>
<br>
CHANGES SINCE LAST ACTION<br>
  <a href="https://reviews.llvm.org/D100310/new/" rel="noreferrer" target="_blank">https://reviews.llvm.org/D100310/new/</a><br>
<br>
<a href="https://reviews.llvm.org/D100310" rel="noreferrer" target="_blank">https://reviews.llvm.org/D100310</a><br>
<br>
Files:<br>
  clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h<br>
  clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp<br>
  clang/unittests/Rename/RenameClassTest.cpp<br>
<br>
<br>
Index: clang/unittests/Rename/RenameClassTest.cpp<br>
===================================================================<br>
--- clang/unittests/Rename/RenameClassTest.cpp<br>
+++ clang/unittests/Rename/RenameClassTest.cpp<br>
@@ -780,6 +780,27 @@<br>
   CompareSnippets(Expected, After);<br>
 }<br>
<br>
+TEST_F(ClangRenameTest, FieldDesignatedInitializers) {<br>
+  std::string Before = R"(<br>
+      struct S {<br>
+        int a;<br>
+      };<br>
+      void foo() {<br>
+        S s = { .a = 10 };<br>
+        s.a = 20;<br>
+      })";<br>
+  std::string Expected = R"(<br>
+      struct S {<br>
+        int b;<br>
+      };<br>
+      void foo() {<br>
+        S s = { .b = 10 };<br>
+        s.b = 20;<br>
+      })";<br>
+  std::string After = runClangRenameOnCode(Before, "S::a", "S::b");<br>
+  CompareSnippets(Expected, After);<br>
+}<br>
+<br>
 // FIXME: investigate why the test fails when adding a new USR to the USRSet.<br>
 TEST_F(ClangRenameTest, DISABLED_NestedTemplates) {<br>
   std::string Before = R"(<br>
Index: clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp<br>
===================================================================<br>
--- clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp<br>
+++ clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp<br>
@@ -226,6 +226,24 @@<br>
     return true;<br>
   }<br>
<br>
+  bool VisitDesignatedInitExpr(const DesignatedInitExpr *E) {<br>
+    for (const DesignatedInitExpr::Designator &D : E->designators()) {<br>
+      if (D.isFieldDesignator() && D.getField()) {<br>
+        const FieldDecl *Decl = D.getField();<br>
+        if (isInUSRSet(Decl)) {<br>
+          auto StartLoc = D.getFieldLoc();<br>
+          auto EndLoc = D.getFieldLoc();<br>
+          RenameInfos.push_back({StartLoc, EndLoc,<br>
+                                 /*FromDecl=*/nullptr,<br>
+                                 /*Context=*/nullptr,<br>
+                                 /*Specifier=*/nullptr,<br>
+                                 /*IgnorePrefixQualifiers=*/true});<br>
+        }<br>
+      }<br>
+    }<br>
+    return true;<br>
+  }<br>
+<br>
   bool VisitCXXConstructorDecl(const CXXConstructorDecl *CD) {<br>
     // Fix the constructor initializer when renaming class members.<br>
     for (const auto *Initializer : CD->inits()) {<br>
Index: clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h<br>
===================================================================<br>
--- clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h<br>
+++ clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h<br>
@@ -122,6 +122,17 @@<br>
     return BaseType::TraverseNestedNameSpecifierLoc(NNS);<br>
   }<br>
<br>
+  bool VisitDesignatedInitExpr(const DesignatedInitExpr *E) {<br>
+    for (const DesignatedInitExpr::Designator &D : E->designators()) {<br>
+      if (D.isFieldDesignator() && D.getField()) {<br>
+        const FieldDecl *Decl = D.getField();<br>
+        if (!visit(Decl, D.getFieldLoc(), D.getFieldLoc()))<br>
+          return false;<br>
+      }<br>
+    }<br>
+    return true;<br>
+  }<br>
+<br>
 private:<br>
   const SourceManager &SM;<br>
   const LangOptions &LangOpts;<br>
<br>
<br>
</blockquote></div>