Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:22

0001 //===--- DesignatedInitializers.h - clang-tidy ------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 ///
0009 /// \file
0010 /// This file provides utilities for designated initializers.
0011 ///
0012 //===----------------------------------------------------------------------===//
0013 
0014 #include "clang/AST/Expr.h"
0015 #include "clang/Basic/SourceLocation.h"
0016 #include "llvm/ADT/DenseMap.h"
0017 
0018 namespace clang::tidy::utils {
0019 
0020 /// Get designators describing the elements of a (syntactic) init list.
0021 ///
0022 /// Given for example the type
0023 /// \code
0024 /// struct S { int i, j; };
0025 /// \endcode
0026 /// and the definition
0027 /// \code
0028 ///  S s{1, 2};
0029 /// \endcode
0030 /// calling `getUnwrittenDesignators` for the initializer list expression
0031 /// `{1, 2}` would produce the map `{loc(1): ".i", loc(2): ".j"}`.
0032 ///
0033 /// It does not produce designators for any explicitly-written nested lists,
0034 /// e.g. `{1, .j=2}` would only return `{loc(1): ".i"}`.
0035 ///
0036 /// It also considers structs with fields of record types like
0037 /// `struct T { S s; };`. In this case, there would be designators of the
0038 /// form `.s.i` and `.s.j` in the returned map.
0039 llvm::DenseMap<clang::SourceLocation, std::string>
0040 getUnwrittenDesignators(const clang::InitListExpr *Syn);
0041 
0042 } // namespace clang::tidy::utils