Skip to content

Commit 7e4c488

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#2643)
2 parents 7c6635b + e1d5ab2 commit 7e4c488

File tree

140 files changed

+3562
-2335
lines changed

Some content is hidden

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

140 files changed

+3562
-2335
lines changed

bolt/lib/Passes/RetpolineInsertion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ std::string createRetpolineFunctionTag(BinaryContext &BC,
195195

196196
TagOS << "+";
197197
if (MemRef.DispExpr)
198-
MemRef.DispExpr->print(TagOS, BC.AsmInfo.get());
198+
BC.AsmInfo->printExpr(TagOS, *MemRef.DispExpr);
199199
else
200200
TagOS << MemRef.DispImm;
201201

bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#include "MCTargetDesc/RISCVMCExpr.h"
13+
#include "MCTargetDesc/RISCVMCAsmInfo.h"
1414
#include "MCTargetDesc/RISCVMCTargetDesc.h"
1515
#include "bolt/Core/MCPlusBuilder.h"
1616
#include "llvm/BinaryFormat/ELF.h"
@@ -33,8 +33,8 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
3333

3434
bool equals(const MCSpecifierExpr &A, const MCSpecifierExpr &B,
3535
CompFuncTy Comp) const override {
36-
const auto &RISCVExprA = cast<RISCVMCExpr>(A);
37-
const auto &RISCVExprB = cast<RISCVMCExpr>(B);
36+
const auto &RISCVExprA = cast<MCSpecifierExpr>(A);
37+
const auto &RISCVExprB = cast<MCSpecifierExpr>(B);
3838
if (RISCVExprA.getSpecifier() != RISCVExprB.getSpecifier())
3939
return false;
4040

@@ -245,7 +245,7 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
245245
MCContext *Ctx) {
246246
Inst.setOpcode(Opcode);
247247
Inst.clear();
248-
Inst.addOperand(MCOperand::createExpr(RISCVMCExpr::create(
248+
Inst.addOperand(MCOperand::createExpr(MCSpecifierExpr::create(
249249
MCSymbolRefExpr::create(Target, MCSymbolRefExpr::VK_None, *Ctx),
250250
ELF::R_RISCV_CALL_PLT, *Ctx)));
251251
}
@@ -342,7 +342,7 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
342342
}
343343

344344
const MCSymbol *getTargetSymbol(const MCExpr *Expr) const override {
345-
auto *RISCVExpr = dyn_cast<RISCVMCExpr>(Expr);
345+
auto *RISCVExpr = dyn_cast<MCSpecifierExpr>(Expr);
346346
if (RISCVExpr && RISCVExpr->getSubExpr())
347347
return getTargetSymbol(RISCVExpr->getSubExpr());
348348

@@ -435,19 +435,19 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
435435
case ELF::R_RISCV_TLS_GD_HI20:
436436
// The GOT is reused so no need to create GOT relocations
437437
case ELF::R_RISCV_PCREL_HI20:
438-
return RISCVMCExpr::create(Expr, ELF::R_RISCV_PCREL_HI20, Ctx);
438+
return MCSpecifierExpr::create(Expr, ELF::R_RISCV_PCREL_HI20, Ctx);
439439
case ELF::R_RISCV_PCREL_LO12_I:
440440
case ELF::R_RISCV_PCREL_LO12_S:
441-
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_PCREL_LO, Ctx);
441+
return MCSpecifierExpr::create(Expr, RISCV::S_PCREL_LO, Ctx);
442442
case ELF::R_RISCV_HI20:
443-
return RISCVMCExpr::create(Expr, ELF::R_RISCV_HI20, Ctx);
443+
return MCSpecifierExpr::create(Expr, ELF::R_RISCV_HI20, Ctx);
444444
case ELF::R_RISCV_LO12_I:
445445
case ELF::R_RISCV_LO12_S:
446-
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_LO, Ctx);
446+
return MCSpecifierExpr::create(Expr, RISCV::S_LO, Ctx);
447447
case ELF::R_RISCV_CALL:
448-
return RISCVMCExpr::create(Expr, ELF::R_RISCV_CALL_PLT, Ctx);
448+
return MCSpecifierExpr::create(Expr, ELF::R_RISCV_CALL_PLT, Ctx);
449449
case ELF::R_RISCV_CALL_PLT:
450-
return RISCVMCExpr::create(Expr, ELF::R_RISCV_CALL_PLT, Ctx);
450+
return MCSpecifierExpr::create(Expr, ELF::R_RISCV_CALL_PLT, Ctx);
451451
}
452452
}
453453

@@ -466,10 +466,10 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
466466
return false;
467467

468468
const auto *ImmExpr = ImmOp.getExpr();
469-
if (!isa<RISCVMCExpr>(ImmExpr))
469+
if (!isa<MCSpecifierExpr>(ImmExpr))
470470
return false;
471471

472-
switch (cast<RISCVMCExpr>(ImmExpr)->getSpecifier()) {
472+
switch (cast<MCSpecifierExpr>(ImmExpr)->getSpecifier()) {
473473
default:
474474
return false;
475475
case ELF::R_RISCV_CALL_PLT:

clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ getNewFieldsOrder(const RecordDecl *Definition,
8686
static void
8787
addReplacement(SourceRange Old, SourceRange New, const ASTContext &Context,
8888
std::map<std::string, tooling::Replacements> &Replacements) {
89+
if (Old.getBegin().isMacroID())
90+
Old = Context.getSourceManager().getExpansionRange(Old).getAsRange();
91+
if (New.getBegin().isMacroID())
92+
New = Context.getSourceManager().getExpansionRange(New).getAsRange();
8993
StringRef NewText =
9094
Lexer::getSourceText(CharSourceRange::getTokenRange(New),
9195
Context.getSourceManager(), Context.getLangOpts());
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: clang-reorder-fields -record-name ::bar::Foo -fields-order z,y,x %s -- | FileCheck %s
2+
3+
namespace bar {
4+
5+
#define INT_DECL(NAME) int NAME // CHECK: {{^#define INT_DECL\(NAME\) int NAME}}
6+
#define MACRO_DECL int x; // CHECK-NEXT: {{^#define MACRO_DECL int x;}}
7+
8+
struct Foo {
9+
MACRO_DECL // CHECK: {{^ INT_DECL\(z\);}}
10+
int y; // CHECK-NEXT: {{^ int y;}}
11+
INT_DECL(z); // CHECK-NEXT: {{^ MACRO_DECL}}
12+
};
13+
14+
#define FOO 0 // CHECK: {{^#define FOO 0}}
15+
#define BAR 1 // CHECK-NEXT: {{^#define BAR 1}}
16+
#define BAZ 2 // CHECK-NEXT: {{^#define BAZ 2}}
17+
18+
struct Foo foo = {
19+
FOO, // CHECK: {{^ BAZ,}}
20+
BAR, // CHECK-NEXT: {{^ BAR,}}
21+
BAZ, // CHECK-NEXT: {{^ FOO,}}
22+
};
23+
24+
} // end namespace bar

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1779,7 +1779,7 @@ def note_unsatisfied_trait_reason
17791779
"%HasArcLifetime{has an ARC lifetime qualifier}|"
17801780
"%VLA{is a variably-modified type}|"
17811781
"%VBase{has a virtual base %1}|"
1782-
"%NotScalarOrClass{not %select{a|an array of objects of}1 scalar or "
1782+
"%NotScalarOrClass{is not %select{a|an array of objects of}1 scalar or "
17831783
"class type}|"
17841784
"%NTRBase{has a non-trivially-relocatable base %1}|"
17851785
"%NTRField{has a non-trivially-relocatable member %1 of type %2}|"

clang/lib/Basic/Targets/AVR.cpp

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,9 @@ static MCUInfo AVRMcus[] = {
336336
{"attiny1624", "__AVR_ATtiny1624__", "103", 1},
337337
{"attiny1626", "__AVR_ATtiny1626__", "103", 1},
338338
{"attiny1627", "__AVR_ATtiny1627__", "103", 1},
339+
{"attiny3224", "__AVR_ATtiny3224__", "103", 1},
340+
{"attiny3226", "__AVR_ATtiny3226__", "103", 1},
341+
{"attiny3227", "__AVR_ATtiny3227__", "103", 1},
339342
{"atmega808", "__AVR_ATmega808__", "103", 1},
340343
{"atmega809", "__AVR_ATmega809__", "103", 1},
341344
{"atmega1608", "__AVR_ATmega1608__", "103", 1},
@@ -344,6 +347,72 @@ static MCUInfo AVRMcus[] = {
344347
{"atmega3209", "__AVR_ATmega3209__", "103", 1},
345348
{"atmega4808", "__AVR_ATmega4808__", "103", 1},
346349
{"atmega4809", "__AVR_ATmega4809__", "103", 1},
350+
351+
// gcc 14 additions:
352+
353+
{"avr64da28", "__AVR_AVR64DA28__", "102", 1},
354+
{"avr64da32", "__AVR_AVR64DA32__", "102", 1},
355+
{"avr64da48", "__AVR_AVR64DA48__", "102", 1},
356+
{"avr64da64", "__AVR_AVR64DA64__", "102", 1},
357+
{"avr64db28", "__AVR_AVR64DB28__", "102", 1},
358+
{"avr64db32", "__AVR_AVR64DB32__", "102", 1},
359+
{"avr64db48", "__AVR_AVR64DB48__", "102", 1},
360+
{"avr64db64", "__AVR_AVR64DB64__", "102", 1},
361+
{"avr64dd14", "__AVR_AVR64DD14__", "102", 1},
362+
{"avr64dd20", "__AVR_AVR64DD20__", "102", 1},
363+
{"avr64dd28", "__AVR_AVR64DD28__", "102", 1},
364+
{"avr64dd32", "__AVR_AVR64DD32__", "102", 1},
365+
{"avr64du28", "__AVR_AVR64DU28__", "102", 1},
366+
{"avr64du32", "__AVR_AVR64DU32__", "102", 1},
367+
{"avr64ea28", "__AVR_AVR64EA28__", "102", 1},
368+
{"avr64ea32", "__AVR_AVR64EA32__", "102", 1},
369+
{"avr64ea48", "__AVR_AVR64EA48__", "102", 1},
370+
{"avr64sd28", "__AVR_AVR64SD28__", "102", 1},
371+
{"avr64sd32", "__AVR_AVR64SD32__", "102", 1},
372+
{"avr64sd48", "__AVR_AVR64SD48__", "102", 1},
373+
374+
{"avr16dd20", "__AVR_AVR16DD20__", "103", 1},
375+
{"avr16dd28", "__AVR_AVR16DD28__", "103", 1},
376+
{"avr16dd32", "__AVR_AVR16DD32__", "103", 1},
377+
{"avr16du14", "__AVR_AVR16DU14__", "103", 1},
378+
{"avr16du20", "__AVR_AVR16DU20__", "103", 1},
379+
{"avr16du28", "__AVR_AVR16DU28__", "103", 1},
380+
{"avr16du32", "__AVR_AVR16DU32__", "103", 1},
381+
{"avr32da28", "__AVR_AVR32DA28__", "103", 1},
382+
{"avr32da32", "__AVR_AVR32DA32__", "103", 1},
383+
{"avr32da48", "__AVR_AVR32DA48__", "103", 1},
384+
{"avr32db28", "__AVR_AVR32DB28__", "103", 1},
385+
{"avr32db32", "__AVR_AVR32DB32__", "103", 1},
386+
{"avr32db48", "__AVR_AVR32DB48__", "103", 1},
387+
{"avr32dd14", "__AVR_AVR32DD14__", "103", 1},
388+
{"avr32dd20", "__AVR_AVR32DD20__", "103", 1},
389+
{"avr32dd28", "__AVR_AVR32DD28__", "103", 1},
390+
{"avr32dd32", "__AVR_AVR32DD32__", "103", 1},
391+
{"avr32du14", "__AVR_AVR32DU14__", "103", 1},
392+
{"avr32du20", "__AVR_AVR32DU20__", "103", 1},
393+
{"avr32du28", "__AVR_AVR32DU28__", "103", 1},
394+
{"avr32du32", "__AVR_AVR32DU32__", "103", 1},
395+
{"avr16eb14", "__AVR_AVR16EB14__", "103", 1},
396+
{"avr16eb20", "__AVR_AVR16EB20__", "103", 1},
397+
{"avr16eb28", "__AVR_AVR16EB28__", "103", 1},
398+
{"avr16eb32", "__AVR_AVR16EB32__", "103", 1},
399+
{"avr16ea28", "__AVR_AVR16EA28__", "103", 1},
400+
{"avr16ea32", "__AVR_AVR16EA32__", "103", 1},
401+
{"avr16ea48", "__AVR_AVR16EA48__", "103", 1},
402+
{"avr32ea28", "__AVR_AVR32EA28__", "103", 1},
403+
{"avr32ea32", "__AVR_AVR32EA32__", "103", 1},
404+
{"avr32ea48", "__AVR_AVR32EA48__", "103", 1},
405+
{"avr32sd20", "__AVR_AVR32SD20__", "103", 1},
406+
{"avr32sd28", "__AVR_AVR32SD28__", "103", 1},
407+
{"avr32sd32", "__AVR_AVR32SD32__", "103", 1},
408+
{"avr128da28", "__AVR_AVR128DA28__", "104", 2},
409+
{"avr128da32", "__AVR_AVR128DA32__", "104", 2},
410+
{"avr128da48", "__AVR_AVR128DA48__", "104", 2},
411+
{"avr128da64", "__AVR_AVR128DA64__", "104", 2},
412+
{"avr128db28", "__AVR_AVR128DB28__", "104", 2},
413+
{"avr128db32", "__AVR_AVR128DB32__", "104", 2},
414+
{"avr128db48", "__AVR_AVR128DB48__", "104", 2},
415+
{"avr128db64", "__AVR_AVR128DB64__", "104", 2},
347416
};
348417

349418
} // namespace targets

clang/lib/Driver/ToolChains/AVR.cpp

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,78 @@ constexpr struct {
326326
{"attiny1624", "avrxmega3", "avrxmega3", 0x803800},
327327
{"attiny1626", "avrxmega3", "avrxmega3", 0x803800},
328328
{"attiny1627", "avrxmega3", "avrxmega3", 0x803800},
329+
{"attiny3224", "avrxmega3", "avrxmega3", 0x803400},
330+
{"attiny3226", "avrxmega3", "avrxmega3", 0x803400},
331+
{"attiny3227", "avrxmega3", "avrxmega3", 0x803400},
329332
{"attiny3216", "avrxmega3", "avrxmega3", 0x803800},
330333
{"attiny3217", "avrxmega3", "avrxmega3", 0x803800},
334+
335+
// gcc 14 additions:
336+
337+
{"avr64da28", "avrxmega2", "avrxmega2", 0x806000},
338+
{"avr64da32", "avrxmega2", "avrxmega2", 0x806000},
339+
{"avr64da48", "avrxmega2", "avrxmega2", 0x806000},
340+
{"avr64da64", "avrxmega2", "avrxmega2", 0x806000},
341+
{"avr64db28", "avrxmega2", "avrxmega2", 0x806000},
342+
{"avr64db32", "avrxmega2", "avrxmega2", 0x806000},
343+
{"avr64db48", "avrxmega2", "avrxmega2", 0x806000},
344+
{"avr64db64", "avrxmega2", "avrxmega2", 0x806000},
345+
{"avr64dd14", "avrxmega2", "avrxmega2", 0x806000},
346+
{"avr64dd20", "avrxmega2", "avrxmega2", 0x806000},
347+
{"avr64dd28", "avrxmega2", "avrxmega2", 0x806000},
348+
{"avr64dd32", "avrxmega2", "avrxmega2", 0x806000},
349+
{"avr64du28", "avrxmega2", "avrxmega2", 0x806000},
350+
{"avr64du32", "avrxmega2", "avrxmega2", 0x806000},
351+
{"avr64ea28", "avrxmega2", "avrxmega2", 0x806800},
352+
{"avr64ea32", "avrxmega2", "avrxmega2", 0x806800},
353+
{"avr64ea48", "avrxmega2", "avrxmega2", 0x806800},
354+
{"avr64sd28", "avrxmega2", "avrxmega2", 0x806000},
355+
{"avr64sd32", "avrxmega2", "avrxmega2", 0x806000},
356+
{"avr64sd48", "avrxmega2", "avrxmega2", 0x806000},
357+
358+
{"avr16dd20", "avrxmega3", "avrxmega3", 0x807800},
359+
{"avr16dd28", "avrxmega3", "avrxmega3", 0x807800},
360+
{"avr16dd32", "avrxmega3", "avrxmega3", 0x807800},
361+
{"avr16du14", "avrxmega3", "avrxmega3", 0x807800},
362+
{"avr16du20", "avrxmega3", "avrxmega3", 0x807800},
363+
{"avr16du28", "avrxmega3", "avrxmega3", 0x807800},
364+
{"avr16du32", "avrxmega3", "avrxmega3", 0x807800},
365+
{"avr32da28", "avrxmega3", "avrxmega3", 0x807000},
366+
{"avr32da32", "avrxmega3", "avrxmega3", 0x807000},
367+
{"avr32da48", "avrxmega3", "avrxmega3", 0x807000},
368+
{"avr32db28", "avrxmega3", "avrxmega3", 0x807000},
369+
{"avr32db32", "avrxmega3", "avrxmega3", 0x807000},
370+
{"avr32db48", "avrxmega3", "avrxmega3", 0x807000},
371+
{"avr32dd14", "avrxmega3", "avrxmega3", 0x807000},
372+
{"avr32dd20", "avrxmega3", "avrxmega3", 0x807000},
373+
{"avr32dd28", "avrxmega3", "avrxmega3", 0x807000},
374+
{"avr32dd32", "avrxmega3", "avrxmega3", 0x807000},
375+
{"avr32du14", "avrxmega3", "avrxmega3", 0x807000},
376+
{"avr32du20", "avrxmega3", "avrxmega3", 0x807000},
377+
{"avr32du28", "avrxmega3", "avrxmega3", 0x807000},
378+
{"avr32du32", "avrxmega3", "avrxmega3", 0x807000},
379+
{"avr16eb14", "avrxmega3", "avrxmega3", 0x807800},
380+
{"avr16eb20", "avrxmega3", "avrxmega3", 0x807800},
381+
{"avr16eb28", "avrxmega3", "avrxmega3", 0x807800},
382+
{"avr16eb32", "avrxmega3", "avrxmega3", 0x807800},
383+
{"avr16ea28", "avrxmega3", "avrxmega3", 0x807800},
384+
{"avr16ea32", "avrxmega3", "avrxmega3", 0x807800},
385+
{"avr16ea48", "avrxmega3", "avrxmega3", 0x807800},
386+
{"avr32ea28", "avrxmega3", "avrxmega3", 0x807000},
387+
{"avr32ea32", "avrxmega3", "avrxmega3", 0x807000},
388+
{"avr32ea48", "avrxmega3", "avrxmega3", 0x807000},
389+
{"avr32sd20", "avrxmega3", "avrxmega3", 0x807000},
390+
{"avr32sd28", "avrxmega3", "avrxmega3", 0x807000},
391+
{"avr32sd32", "avrxmega3", "avrxmega3", 0x807000},
392+
{"avr128da28", "avrxmega4", "avrxmega4", 0x804000},
393+
{"avr128da32", "avrxmega4", "avrxmega4", 0x804000},
394+
{"avr128da48", "avrxmega4", "avrxmega4", 0x804000},
395+
{"avr128da64", "avrxmega4", "avrxmega4", 0x804000},
396+
{"avr128db28", "avrxmega4", "avrxmega4", 0x804000},
397+
{"avr128db32", "avrxmega4", "avrxmega4", 0x804000},
398+
{"avr128db48", "avrxmega4", "avrxmega4", 0x804000},
399+
{"avr128db64", "avrxmega4", "avrxmega4", 0x804000},
400+
331401
};
332402

333403
std::string GetMCUSubPath(StringRef MCUName) {

clang/lib/Format/ContinuationIndenter.cpp

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,9 @@ bool ContinuationIndenter::canBreak(const LineState &State) {
329329
// statement and we are aligning lambda blocks to their signatures.
330330
if (Previous.is(tok::l_brace) && State.Stack.size() > 1 &&
331331
State.Stack[State.Stack.size() - 2].NestedBlockInlined &&
332-
State.Stack[State.Stack.size() - 2].HasMultipleNestedBlocks &&
333-
Style.LambdaBodyIndentation == FormatStyle::LBI_Signature) {
334-
return false;
332+
State.Stack[State.Stack.size() - 2].HasMultipleNestedBlocks) {
333+
return Style.isCpp() &&
334+
Style.LambdaBodyIndentation == FormatStyle::LBI_OuterScope;
335335
}
336336

337337
// Don't break after very short return types (e.g. "void") as that is often
@@ -706,42 +706,48 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
706706
const FormatToken &Previous = *State.NextToken->Previous;
707707
auto &CurrentState = State.Stack.back();
708708

709-
bool DisallowLineBreaksOnThisLine =
710-
Style.LambdaBodyIndentation == FormatStyle::LBI_Signature &&
711-
// Deal with lambda arguments in C++. The aim here is to ensure that we
712-
// don't over-indent lambda function bodies when lambdas are passed as
713-
// arguments to function calls. We do this by ensuring that either all
714-
// arguments (including any lambdas) go on the same line as the function
715-
// call, or we break before the first argument.
716-
Style.isCpp() && [&] {
717-
// For example, `/*Newline=*/false`.
718-
if (Previous.is(TT_BlockComment) && Current.SpacesRequiredBefore == 0)
719-
return false;
720-
const auto *PrevNonComment = Current.getPreviousNonComment();
721-
if (!PrevNonComment || PrevNonComment->isNot(tok::l_paren))
722-
return false;
723-
if (Current.isOneOf(tok::comment, tok::l_paren, TT_LambdaLSquare))
724-
return false;
725-
auto BlockParameterCount = PrevNonComment->BlockParameterCount;
726-
if (BlockParameterCount == 0)
727-
return false;
709+
// Deal with lambda arguments in C++. The aim here is to ensure that we don't
710+
// over-indent lambda function bodies when lambdas are passed as arguments to
711+
// function calls. We do this by ensuring that either all arguments (including
712+
// any lambdas) go on the same line as the function call, or we break before
713+
// the first argument.
714+
auto DisallowLineBreaks = [&] {
715+
if (!Style.isCpp() ||
716+
Style.LambdaBodyIndentation == FormatStyle::LBI_OuterScope) {
717+
return false;
718+
}
728719

729-
// Multiple lambdas in the same function call.
730-
if (BlockParameterCount > 1)
731-
return true;
720+
// For example, `/*Newline=*/false`.
721+
if (Previous.is(TT_BlockComment) && Current.SpacesRequiredBefore == 0)
722+
return false;
732723

733-
// A lambda followed by another arg.
734-
if (!PrevNonComment->Role)
735-
return false;
736-
auto Comma = PrevNonComment->Role->lastComma();
737-
if (!Comma)
738-
return false;
739-
auto Next = Comma->getNextNonComment();
740-
return Next &&
741-
!Next->isOneOf(TT_LambdaLSquare, tok::l_brace, tok::caret);
742-
}();
724+
if (Current.isOneOf(tok::comment, tok::l_paren, TT_LambdaLSquare))
725+
return false;
726+
727+
const auto *Prev = Current.getPreviousNonComment();
728+
if (!Prev || Prev->isNot(tok::l_paren))
729+
return false;
730+
731+
if (Prev->BlockParameterCount == 0)
732+
return false;
733+
734+
// Multiple lambdas in the same function call.
735+
if (Prev->BlockParameterCount > 1)
736+
return true;
737+
738+
// A lambda followed by another arg.
739+
if (!Prev->Role)
740+
return false;
741+
742+
const auto *Comma = Prev->Role->lastComma();
743+
if (!Comma)
744+
return false;
745+
746+
const auto *Next = Comma->getNextNonComment();
747+
return Next && !Next->isOneOf(TT_LambdaLSquare, tok::l_brace, tok::caret);
748+
};
743749

744-
if (DisallowLineBreaksOnThisLine)
750+
if (DisallowLineBreaks())
745751
State.NoLineBreak = true;
746752

747753
if (Current.is(tok::equal) &&

0 commit comments

Comments
 (0)