Skip to content

Commit 432cf6b

Browse files
authored
Merge pull request llvm#568 from AMD-Lightning-Internal/upstream_merge_202502080708
merge main into amd-staging
2 parents f5f9c70 + 44568b1 commit 432cf6b

File tree

81 files changed

+488
-501
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+488
-501
lines changed

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,6 +2182,24 @@ the configuration (without a prefix: ``Auto``).
21822182
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
21832183
}
21842184

2185+
.. _BinPackLongBracedList:
2186+
2187+
**BinPackLongBracedList** (``Boolean``) :versionbadge:`clang-format 21` :ref:`<BinPackLongBracedList>`
2188+
If ``BinPackLongBracedList`` is ``true`` it overrides
2189+
``BinPackArguments`` if there are 20 or more items in a braced
2190+
initializer list.
2191+
2192+
.. code-block:: c++
2193+
2194+
BinPackLongBracedList: false vs. BinPackLongBracedList: true
2195+
vector<int> x{ vector<int> x{1, 2, ...,
2196+
20, 21};
2197+
1,
2198+
2,
2199+
...,
2200+
20,
2201+
21};
2202+
21852203
.. _BinPackParameters:
21862204

21872205
**BinPackParameters** (``BinPackParametersStyle``) :versionbadge:`clang-format 3.7` :ref:`<BinPackParameters>`

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ Bug Fixes to C++ Support
151151
^^^^^^^^^^^^^^^^^^^^^^^^
152152

153153
- Clang is now better at keeping track of friend function template instance contexts. (#GH55509)
154+
- The initialization kind of elements of structured bindings
155+
direct-list-initialized from an array is corrected to direct-initialization.
154156

155157
Bug Fixes to AST Handling
156158
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -237,6 +239,8 @@ clang-format
237239
------------
238240

239241
- Adds ``BreakBeforeTemplateCloser`` option.
242+
- Adds ``BinPackLongBracedList`` option to override bin packing options in
243+
long (20 item or more) braced list initializer lists.
240244

241245
libclang
242246
--------

clang/include/clang/Format/Format.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,22 @@ struct FormatStyle {
12121212
/// \version 3.7
12131213
bool BinPackArguments;
12141214

1215+
/// If ``BinPackLongBracedList`` is ``true`` it overrides
1216+
/// ``BinPackArguments`` if there are 20 or more items in a braced
1217+
/// initializer list.
1218+
/// \code
1219+
/// BinPackLongBracedList: false vs. BinPackLongBracedList: true
1220+
/// vector<int> x{ vector<int> x{1, 2, ...,
1221+
/// 20, 21};
1222+
/// 1,
1223+
/// 2,
1224+
/// ...,
1225+
/// 20,
1226+
/// 21};
1227+
/// \endcode
1228+
/// \version 21
1229+
bool BinPackLongBracedList;
1230+
12151231
/// Different way to try to fit all parameters on a line.
12161232
enum BinPackParametersStyle : int8_t {
12171233
/// Bin-pack parameters.
@@ -5266,6 +5282,7 @@ struct FormatStyle {
52665282
R.AlwaysBreakBeforeMultilineStrings &&
52675283
AttributeMacros == R.AttributeMacros &&
52685284
BinPackArguments == R.BinPackArguments &&
5285+
BinPackLongBracedList == R.BinPackLongBracedList &&
52695286
BinPackParameters == R.BinPackParameters &&
52705287
BitFieldColonSpacing == R.BitFieldColonSpacing &&
52715288
BracedInitializerIndentWidth == R.BracedInitializerIndentWidth &&

clang/lib/Format/Format.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,7 @@ template <> struct MappingTraits<FormatStyle> {
995995
Style.AlwaysBreakBeforeMultilineStrings);
996996
IO.mapOptional("AttributeMacros", Style.AttributeMacros);
997997
IO.mapOptional("BinPackArguments", Style.BinPackArguments);
998+
IO.mapOptional("BinPackLongBracedList", Style.BinPackLongBracedList);
998999
IO.mapOptional("BinPackParameters", Style.BinPackParameters);
9991000
IO.mapOptional("BitFieldColonSpacing", Style.BitFieldColonSpacing);
10001001
IO.mapOptional("BracedInitializerIndentWidth",
@@ -1507,6 +1508,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
15071508
LLVMStyle.AlwaysBreakBeforeMultilineStrings = false;
15081509
LLVMStyle.AttributeMacros.push_back("__capability");
15091510
LLVMStyle.BinPackArguments = true;
1511+
LLVMStyle.BinPackLongBracedList = true;
15101512
LLVMStyle.BinPackParameters = FormatStyle::BPPS_BinPack;
15111513
LLVMStyle.BitFieldColonSpacing = FormatStyle::BFCS_Both;
15121514
LLVMStyle.BracedInitializerIndentWidth = std::nullopt;

clang/lib/Format/FormatToken.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ void CommaSeparatedList::precomputeFormattingInfos(const FormatToken *Token) {
175175
// have many items (20 or more) or we allow bin-packing of function call
176176
// arguments.
177177
if (Style.Cpp11BracedListStyle && !Style.BinPackArguments &&
178-
Commas.size() < 19) {
178+
(Commas.size() < 19 || !Style.BinPackLongBracedList)) {
179179
return;
180180
}
181181

clang/lib/Sema/SemaInit.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4862,9 +4862,13 @@ static void TryListInitialization(Sema &S,
48624862
assert(
48634863
S.Context.hasSameUnqualifiedType(SubInit[0]->getType(), DestType) &&
48644864
"Deduced to other type?");
4865+
assert(Kind.getKind() == clang::InitializationKind::IK_DirectList &&
4866+
"List-initialize structured bindings but not "
4867+
"direct-list-initialization?");
48654868
TryArrayCopy(S,
4866-
InitializationKind::CreateCopy(Kind.getLocation(),
4867-
InitList->getLBraceLoc()),
4869+
InitializationKind::CreateDirect(Kind.getLocation(),
4870+
InitList->getLBraceLoc(),
4871+
InitList->getRBraceLoc()),
48684872
Entity, SubInit[0], DestType, Sequence,
48694873
TreatUnavailableAsInvalid);
48704874
if (Sequence)

clang/test/SemaCXX/cxx1z-decomposition.cpp

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -200,38 +200,32 @@ namespace lambdas {
200200

201201
namespace by_value_array_copy {
202202
struct explicit_copy {
203-
explicit_copy() = default; // expected-note 2{{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
204-
explicit explicit_copy(const explicit_copy&) = default; // expected-note 2{{explicit constructor is not a candidate}}
203+
explicit_copy() = default; // expected-note {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
204+
explicit explicit_copy(const explicit_copy&) = default; // expected-note {{explicit constructor is not a candidate}}
205205
};
206206

207-
constexpr int direct_initialization_for_elements() {
208-
explicit_copy ec_arr[2];
209-
auto [a1, b1](ec_arr);
207+
constexpr int simple_array_elements() {
208+
int arr[2]{1, 2};
210209

211-
int arr[3]{1, 2, 3};
212-
auto [a2, b2, c2](arr);
213-
arr[0]--;
214-
return a2 + b2 + c2 + arr[0];
215-
}
216-
static_assert(direct_initialization_for_elements() == 6);
210+
auto [a1, a2] = arr;
211+
auto [b1, b2](arr);
212+
auto [c1, c2]{arr}; // GH31813
217213

218-
constexpr int copy_initialization_for_elements() {
219-
int arr[2]{4, 5};
220-
auto [a1, b1] = arr;
221-
auto [a2, b2]{arr}; // GH31813
222214
arr[0] = 0;
223-
return a1 + b1 + a2 + b2 + arr[0];
215+
return arr[0] + a1 + a2 + b1 + b2 + c1 + c2;
224216
}
225-
static_assert(copy_initialization_for_elements() == 18);
217+
static_assert(simple_array_elements() == 9);
218+
219+
void explicit_copy_ctor_array_elements() {
220+
explicit_copy ec_arr[1];
226221

227-
void copy_initialization_for_elements_with_explicit_copy_ctor() {
228-
explicit_copy ec_arr[2];
229-
auto [a1, b1] = ec_arr; // expected-error {{no matching constructor for initialization of 'explicit_copy[2]'}}
230-
auto [a2, b2]{ec_arr}; // expected-error {{no matching constructor for initialization of 'explicit_copy[2]'}}
222+
auto [a] = ec_arr; // expected-error {{no matching constructor for initialization of 'explicit_copy[1]'}}
223+
auto [b](ec_arr);
224+
auto [c]{ec_arr};
231225

232226
// Test prvalue
233-
using T = explicit_copy[2];
234-
auto [a3, b3] = T{};
235-
auto [a4, b4]{T{}};
227+
using T = explicit_copy[1];
228+
auto [d] = T{};
236229
}
230+
237231
} // namespace by_value_array_copy

clang/unittests/Format/ConfigParseTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ TEST(ConfigParseTest, ParsesConfigurationBools) {
168168
CHECK_PARSE_BOOL(AllowShortLoopsOnASingleLine);
169169
CHECK_PARSE_BOOL(AllowShortNamespacesOnASingleLine);
170170
CHECK_PARSE_BOOL(BinPackArguments);
171+
CHECK_PARSE_BOOL(BinPackLongBracedList);
171172
CHECK_PARSE_BOOL(BreakAdjacentStringLiterals);
172173
CHECK_PARSE_BOOL(BreakAfterJavaFieldAnnotations);
173174
CHECK_PARSE_BOOL(BreakBeforeTemplateCloser);

clang/unittests/Format/FormatTest.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14420,6 +14420,51 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) {
1442014420
"};",
1442114421
NoBinPacking);
1442214422

14423+
NoBinPacking.BinPackLongBracedList = false;
14424+
verifyFormat("const Aaaaaa aaaaa = {aaaaa,\n"
14425+
" bbbbb,\n"
14426+
" ccccc,\n"
14427+
" ddddd,\n"
14428+
" eeeee,\n"
14429+
" ffffff,\n"
14430+
" ggggg,\n"
14431+
" hhhhhh,\n"
14432+
" iiiiii,\n"
14433+
" jjjjjj,\n"
14434+
" kkkkkk,\n"
14435+
" aaaaa,\n"
14436+
" bbbbb,\n"
14437+
" ccccc,\n"
14438+
" ddddd,\n"
14439+
" eeeee,\n"
14440+
" ffffff,\n"
14441+
" ggggg,\n"
14442+
" hhhhhh,\n"
14443+
" iiiiii};",
14444+
NoBinPacking);
14445+
verifyFormat("const Aaaaaa aaaaa = {\n"
14446+
" aaaaa,\n"
14447+
" bbbbb,\n"
14448+
" ccccc,\n"
14449+
" ddddd,\n"
14450+
" eeeee,\n"
14451+
" ffffff,\n"
14452+
" ggggg,\n"
14453+
" hhhhhh,\n"
14454+
" iiiiii,\n"
14455+
" jjjjjj,\n"
14456+
" kkkkkk,\n"
14457+
" aaaaa,\n"
14458+
" bbbbb,\n"
14459+
" ccccc,\n"
14460+
" ddddd,\n"
14461+
" eeeee,\n"
14462+
" ffffff,\n"
14463+
" ggggg,\n"
14464+
" hhhhhh,\n"
14465+
"};",
14466+
NoBinPacking);
14467+
1442314468
NoBinPacking.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
1442414469
verifyFormat("static uint8 CddDp83848Reg[] = {\n"
1442514470
" CDDDP83848_BMCR_REGISTER,\n"

lldb/include/lldb/ValueObject/ValueObject.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -865,17 +865,18 @@ class ValueObject {
865865

866866
virtual void SetLanguageFlags(uint64_t flags) { m_language_flags = flags; }
867867

868-
/// Returns the size of the local buffer if it's available.
868+
/// Returns the local buffer that this ValueObject points to if it's
869+
/// available.
869870
/// \return
870-
/// The size of the local buffer if this value object's value points to a
871-
/// host address, and if that size can be determined. Otherwise, returns
872-
/// LLDB_INVALID_ADDRESS.
871+
/// The local buffer if this value object's value points to a
872+
/// host address, and if that buffer can be determined. Otherwise, returns
873+
/// an empty ArrayRef.
873874
///
874875
/// TODO: Because a ValueObject's Value can point to any arbitrary memory
875-
/// location, it is possible that the size of the local buffer can't be
876-
/// determined at all. See the comment in Value::m_value for a more thorough
877-
/// explanation of why that is.
878-
uint64_t GetLocalBufferSize();
876+
/// location, it is possible that we can't find what what buffer we're
877+
/// pointing to, and thus also can't know its size. See the comment in
878+
/// Value::m_value for a more thorough explanation of why that is.
879+
llvm::ArrayRef<uint8_t> GetLocalBuffer() const;
879880

880881
protected:
881882
typedef ClusterManager<ValueObject> ValueObjectManager;

0 commit comments

Comments
 (0)