[clang-tools-extra] [clang-reorder-fields] Support designated initializers (PR #142150)

Alexander Shaposhnikov via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 22 07:26:10 PDT 2025


================
@@ -0,0 +1,158 @@
+//===-- tools/extra/clang-reorder-fields/utils/Designator.h -----*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the declarations of the DesignatorIter and Designators
+/// utility class.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_REORDER_FIELDS_UTILS_DESIGNATOR_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_REORDER_FIELDS_UTILS_DESIGNATOR_H
+
+#include "clang/AST/Decl.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/Type.h"
+
+namespace clang {
+namespace reorder_fields {
+
+class DesignatorIter {
----------------
alexander-shaposhnikov wrote:

1. Would be good to add a class-level comment.
2. I don't have a strong opinion, so up to you, but I'd consider renaming this class to `Designator`. 
Yes, it resembles an iterator, but not really suitable for use with any standard algorithms, so, perhaps,
we can rename operator++ to advanceToNextElement()


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


More information about the cfe-commits mailing list