================
@@ -3092,6 +3094,65 @@ InitListChecker::CheckDesignatedInitializer(const 
InitializedEntity &Entity,
         PrevField = *FI;
       }
 
+      const auto GenerateDesignatedInitReorderingFixit =
+          [&](SemaBase::SemaDiagnosticBuilder &Diags) {
+            struct ReorderInfo {
+              int Pos{};
+              const Expr *InitExpr{};
+            };
+
+            llvm::SmallDenseMap<IdentifierInfo *, int> MemberNameInx{};
+            llvm::SmallVector<ReorderInfo, 16> ReorderedInitExprs{};
+
+            const auto *CxxRecord =
+                IList->getSemanticForm()->getType()->getAsCXXRecordDecl();
+
+            for (const auto &Field : CxxRecord->fields()) {
+              MemberNameInx[Field->getIdentifier()] = Field->getFieldIndex();
+            }
+
+            for (const auto *Init : IList->inits()) {
----------------
ojhunt wrote:

Nope, the rule is basically that if the type of the variable is not explicitly 
mentioned on the right hand side of the assignment it should be spelled out 
explicitly, so

```cpp
auto *Thing = Object->getAsCXXRecordDecl();
```
is fine, but
```
auto Thing = Object->something()
```
isn't, because a person reading this code does not know what the type of Thing 
is. If the RHS is a dependent type of course that's not an option, but in code 
where you have a known static type, something needs to say what the type is.

https://github.com/llvm/llvm-project/pull/173136
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to