Skip to content

Commit ab27814

Browse files
SC llvm teamSC llvm team
SC llvm team
authored and
SC llvm team
committed
Merged main:7539bcf994ed into amd-gfx:0e8798f5c1bd
Local branch amd-gfx 0e8798f Merged main:e86d6a43f03b into amd-gfx:caaa027161c5 Remote branch main 7539bcf [clang-format][NFC] AlignTokenSequence: Rename Changes[i] to CurrentC…
2 parents 0e8798f + 7539bcf commit ab27814

File tree

20 files changed

+253
-134
lines changed

20 files changed

+253
-134
lines changed

clang/lib/Format/WhitespaceManager.cpp

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,9 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End,
307307
SmallVector<unsigned, 16> ScopeStack;
308308

309309
for (unsigned i = Start; i != End; ++i) {
310+
auto &CurrentChange = Changes[i];
310311
if (ScopeStack.size() != 0 &&
311-
Changes[i].indentAndNestingLevel() <
312+
CurrentChange.indentAndNestingLevel() <
312313
Changes[ScopeStack.back()].indentAndNestingLevel()) {
313314
ScopeStack.pop_back();
314315
}
@@ -320,42 +321,42 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End,
320321
Changes[PreviousNonComment].Tok->is(tok::comment)) {
321322
--PreviousNonComment;
322323
}
323-
if (i != Start && Changes[i].indentAndNestingLevel() >
324+
if (i != Start && CurrentChange.indentAndNestingLevel() >
324325
Changes[PreviousNonComment].indentAndNestingLevel()) {
325326
ScopeStack.push_back(i);
326327
}
327328

328329
bool InsideNestedScope = ScopeStack.size() != 0;
329330
bool ContinuedStringLiteral = i > Start &&
330-
Changes[i].Tok->is(tok::string_literal) &&
331+
CurrentChange.Tok->is(tok::string_literal) &&
331332
Changes[i - 1].Tok->is(tok::string_literal);
332333
bool SkipMatchCheck = InsideNestedScope || ContinuedStringLiteral;
333334

334-
if (Changes[i].NewlinesBefore > 0 && !SkipMatchCheck) {
335+
if (CurrentChange.NewlinesBefore > 0 && !SkipMatchCheck) {
335336
Shift = 0;
336337
FoundMatchOnLine = false;
337338
}
338339

339340
// If this is the first matching token to be aligned, remember by how many
340341
// spaces it has to be shifted, so the rest of the changes on the line are
341342
// shifted by the same amount
342-
if (!FoundMatchOnLine && !SkipMatchCheck && Matches(Changes[i])) {
343+
if (!FoundMatchOnLine && !SkipMatchCheck && Matches(CurrentChange)) {
343344
FoundMatchOnLine = true;
344-
Shift = Column - (RightJustify ? Changes[i].TokenLength : 0) -
345-
Changes[i].StartOfTokenColumn;
346-
Changes[i].Spaces += Shift;
345+
Shift = Column - (RightJustify ? CurrentChange.TokenLength : 0) -
346+
CurrentChange.StartOfTokenColumn;
347+
CurrentChange.Spaces += Shift;
347348
// FIXME: This is a workaround that should be removed when we fix
348349
// http://llvm.org/PR53699. An assertion later below verifies this.
349-
if (Changes[i].NewlinesBefore == 0) {
350-
Changes[i].Spaces =
351-
std::max(Changes[i].Spaces,
352-
static_cast<int>(Changes[i].Tok->SpacesRequiredBefore));
350+
if (CurrentChange.NewlinesBefore == 0) {
351+
CurrentChange.Spaces =
352+
std::max(CurrentChange.Spaces,
353+
static_cast<int>(CurrentChange.Tok->SpacesRequiredBefore));
353354
}
354355
}
355356

356357
// This is for function parameters that are split across multiple lines,
357358
// as mentioned in the ScopeStack comment.
358-
if (InsideNestedScope && Changes[i].NewlinesBefore > 0) {
359+
if (InsideNestedScope && CurrentChange.NewlinesBefore > 0) {
359360
unsigned ScopeStart = ScopeStack.back();
360361
auto ShouldShiftBeAdded = [&] {
361362
// Function declaration
@@ -378,47 +379,47 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End,
378379
TT_TemplateCloser) &&
379380
Changes[ScopeStart - 1].Tok->is(tok::l_paren) &&
380381
Changes[ScopeStart].Tok->isNot(TT_LambdaLSquare)) {
381-
if (Changes[i].Tok->MatchingParen &&
382-
Changes[i].Tok->MatchingParen->is(TT_LambdaLBrace)) {
382+
if (CurrentChange.Tok->MatchingParen &&
383+
CurrentChange.Tok->MatchingParen->is(TT_LambdaLBrace)) {
383384
return false;
384385
}
385386
if (Changes[ScopeStart].NewlinesBefore > 0)
386387
return false;
387-
if (Changes[i].Tok->is(tok::l_brace) &&
388-
Changes[i].Tok->is(BK_BracedInit)) {
388+
if (CurrentChange.Tok->is(tok::l_brace) &&
389+
CurrentChange.Tok->is(BK_BracedInit)) {
389390
return true;
390391
}
391392
return Style.BinPackArguments;
392393
}
393394

394395
// Ternary operator
395-
if (Changes[i].Tok->is(TT_ConditionalExpr))
396+
if (CurrentChange.Tok->is(TT_ConditionalExpr))
396397
return true;
397398

398399
// Period Initializer .XXX = 1.
399-
if (Changes[i].Tok->is(TT_DesignatedInitializerPeriod))
400+
if (CurrentChange.Tok->is(TT_DesignatedInitializerPeriod))
400401
return true;
401402

402403
// Continued ternary operator
403-
if (Changes[i].Tok->Previous &&
404-
Changes[i].Tok->Previous->is(TT_ConditionalExpr)) {
404+
if (CurrentChange.Tok->Previous &&
405+
CurrentChange.Tok->Previous->is(TT_ConditionalExpr)) {
405406
return true;
406407
}
407408

408409
// Continued direct-list-initialization using braced list.
409410
if (ScopeStart > Start + 1 &&
410411
Changes[ScopeStart - 2].Tok->is(tok::identifier) &&
411412
Changes[ScopeStart - 1].Tok->is(tok::l_brace) &&
412-
Changes[i].Tok->is(tok::l_brace) &&
413-
Changes[i].Tok->is(BK_BracedInit)) {
413+
CurrentChange.Tok->is(tok::l_brace) &&
414+
CurrentChange.Tok->is(BK_BracedInit)) {
414415
return true;
415416
}
416417

417418
// Continued braced list.
418419
if (ScopeStart > Start + 1 &&
419420
Changes[ScopeStart - 2].Tok->isNot(tok::identifier) &&
420421
Changes[ScopeStart - 1].Tok->is(tok::l_brace) &&
421-
Changes[i].Tok->isNot(tok::r_brace)) {
422+
CurrentChange.Tok->isNot(tok::r_brace)) {
422423
for (unsigned OuterScopeStart : llvm::reverse(ScopeStack)) {
423424
// Lambda.
424425
if (OuterScopeStart > Start &&
@@ -439,26 +440,26 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End,
439440
};
440441

441442
if (ShouldShiftBeAdded())
442-
Changes[i].Spaces += Shift;
443+
CurrentChange.Spaces += Shift;
443444
}
444445

445446
if (ContinuedStringLiteral)
446-
Changes[i].Spaces += Shift;
447+
CurrentChange.Spaces += Shift;
447448

448449
// We should not remove required spaces unless we break the line before.
449450
assert(Shift >= 0 || Changes[i].NewlinesBefore > 0 ||
450-
Changes[i].Spaces >=
451+
CurrentChange.Spaces >=
451452
static_cast<int>(Changes[i].Tok->SpacesRequiredBefore) ||
452-
Changes[i].Tok->is(tok::eof));
453+
CurrentChange.Tok->is(tok::eof));
453454

454-
Changes[i].StartOfTokenColumn += Shift;
455+
CurrentChange.StartOfTokenColumn += Shift;
455456
if (i + 1 != Changes.size())
456457
Changes[i + 1].PreviousEndOfTokenColumn += Shift;
457458

458459
// If PointerAlignment is PAS_Right, keep *s or &s next to the token
459460
if ((Style.PointerAlignment == FormatStyle::PAS_Right ||
460461
Style.ReferenceAlignment == FormatStyle::RAS_Right) &&
461-
Changes[i].Spaces != 0) {
462+
CurrentChange.Spaces != 0) {
462463
const bool ReferenceNotRightAligned =
463464
Style.ReferenceAlignment != FormatStyle::RAS_Right &&
464465
Style.ReferenceAlignment != FormatStyle::RAS_Pointer;
@@ -579,16 +580,17 @@ static unsigned AlignTokens(const FormatStyle &Style, F &&Matches,
579580

580581
unsigned i = StartAt;
581582
for (unsigned e = Changes.size(); i != e; ++i) {
582-
if (Changes[i].indentAndNestingLevel() < IndentAndNestingLevel)
583+
auto &CurrentChange = Changes[i];
584+
if (CurrentChange.indentAndNestingLevel() < IndentAndNestingLevel)
583585
break;
584586

585-
if (Changes[i].NewlinesBefore != 0) {
587+
if (CurrentChange.NewlinesBefore != 0) {
586588
CommasBeforeMatch = 0;
587589
EndOfSequence = i;
588590

589591
// Whether to break the alignment sequence because of an empty line.
590592
bool EmptyLineBreak =
591-
(Changes[i].NewlinesBefore > 1) && !ACS.AcrossEmptyLines;
593+
(CurrentChange.NewlinesBefore > 1) && !ACS.AcrossEmptyLines;
592594

593595
// Whether to break the alignment sequence because of a line without a
594596
// match.
@@ -600,27 +602,27 @@ static unsigned AlignTokens(const FormatStyle &Style, F &&Matches,
600602

601603
// A new line starts, re-initialize line status tracking bools.
602604
// Keep the match state if a string literal is continued on this line.
603-
if (i == 0 || Changes[i].Tok->isNot(tok::string_literal) ||
605+
if (i == 0 || CurrentChange.Tok->isNot(tok::string_literal) ||
604606
Changes[i - 1].Tok->isNot(tok::string_literal)) {
605607
FoundMatchOnLine = false;
606608
}
607609
LineIsComment = true;
608610
}
609611

610-
if (Changes[i].Tok->isNot(tok::comment))
612+
if (CurrentChange.Tok->isNot(tok::comment))
611613
LineIsComment = false;
612614

613-
if (Changes[i].Tok->is(tok::comma)) {
615+
if (CurrentChange.Tok->is(tok::comma)) {
614616
++CommasBeforeMatch;
615-
} else if (Changes[i].indentAndNestingLevel() > IndentAndNestingLevel) {
617+
} else if (CurrentChange.indentAndNestingLevel() > IndentAndNestingLevel) {
616618
// Call AlignTokens recursively, skipping over this scope block.
617619
unsigned StoppedAt =
618620
AlignTokens(Style, Matches, Changes, i, ACS, RightJustify);
619621
i = StoppedAt - 1;
620622
continue;
621623
}
622624

623-
if (!Matches(Changes[i]))
625+
if (!Matches(CurrentChange))
624626
continue;
625627

626628
// If there is more than one matching token per line, or if the number of
@@ -634,16 +636,16 @@ static unsigned AlignTokens(const FormatStyle &Style, F &&Matches,
634636
if (StartOfSequence == 0)
635637
StartOfSequence = i;
636638

637-
unsigned ChangeWidthLeft = Changes[i].StartOfTokenColumn;
639+
unsigned ChangeWidthLeft = CurrentChange.StartOfTokenColumn;
638640
unsigned ChangeWidthAnchor = 0;
639641
unsigned ChangeWidthRight = 0;
640642
if (RightJustify)
641643
if (ACS.PadOperators)
642-
ChangeWidthAnchor = Changes[i].TokenLength;
644+
ChangeWidthAnchor = CurrentChange.TokenLength;
643645
else
644-
ChangeWidthLeft += Changes[i].TokenLength;
646+
ChangeWidthLeft += CurrentChange.TokenLength;
645647
else
646-
ChangeWidthRight = Changes[i].TokenLength;
648+
ChangeWidthRight = CurrentChange.TokenLength;
647649
for (unsigned j = i + 1; j != e && Changes[j].NewlinesBefore == 0; ++j) {
648650
ChangeWidthRight += Changes[j].Spaces;
649651
// Changes are generally 1:1 with the tokens, but a change could also be

clang/lib/Frontend/InitPreprocessor.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,8 +1081,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
10811081
DefineFloatMacros(Builder, "FLT", &TI.getFloatFormat(), "F");
10821082
DefineFloatMacros(Builder, "DBL", &TI.getDoubleFormat(), "");
10831083
DefineFloatMacros(Builder, "LDBL", &TI.getLongDoubleFormat(), "L");
1084-
if (TI.hasFloat128Type())
1085-
DefineFloatMacros(Builder, "FLT128", &TI.getFloat128Format(), "Q");
10861084

10871085
// Define a __POINTER_WIDTH__ macro for stdint.h.
10881086
Builder.defineMacro("__POINTER_WIDTH__",

clang/test/Preprocessor/init-x86.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,21 +1023,6 @@
10231023
// X86_64-LINUX:#define __DBL_MIN_EXP__ (-1021)
10241024
// X86_64-LINUX:#define __DBL_MIN__ 2.2250738585072014e-308
10251025
// X86_64-LINUX:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__
1026-
// X86_64-LINUX:#define __FLOAT128__ 1
1027-
// X86_64-LINUX:#define __FLT128_DECIMAL_DIG__ 36
1028-
// X86_64-LINUX:#define __FLT128_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966Q
1029-
// X86_64-LINUX:#define __FLT128_DIG__ 33
1030-
// X86_64-LINUX:#define __FLT128_EPSILON__ 1.92592994438723585305597794258492732e-34Q
1031-
// X86_64-LINUX:#define __FLT128_HAS_DENORM__ 1
1032-
// X86_64-LINUX:#define __FLT128_HAS_INFINITY__ 1
1033-
// X86_64-LINUX:#define __FLT128_HAS_QUIET_NAN__ 1
1034-
// X86_64-LINUX:#define __FLT128_MANT_DIG__ 113
1035-
// X86_64-LINUX:#define __FLT128_MAX_10_EXP__ 4932
1036-
// X86_64-LINUX:#define __FLT128_MAX_EXP__ 16384
1037-
// X86_64-LINUX:#define __FLT128_MAX__ 1.18973149535723176508575932662800702e+4932Q
1038-
// X86_64-LINUX:#define __FLT128_MIN_10_EXP__ (-4931)
1039-
// X86_64-LINUX:#define __FLT128_MIN_EXP__ (-16381)
1040-
// X86_64-LINUX:#define __FLT128_MIN__ 3.36210314311209350626267781732175260e-4932Q
10411026
// X86_64-LINUX:#define __FLT_DENORM_MIN__ 1.40129846e-45F
10421027
// X86_64-LINUX:#define __FLT_DIG__ 6
10431028
// X86_64-LINUX:#define __FLT_EPSILON__ 1.19209290e-7F

clang/test/Preprocessor/init.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,20 +1576,6 @@
15761576
// EMSCRIPTEN-NEXT:#define __EMSCRIPTEN__ 1
15771577
// WEBASSEMBLY-NEXT:#define __FINITE_MATH_ONLY__ 0
15781578
// WEBASSEMBLY-NEXT:#define __FLOAT128__ 1
1579-
// WEBASSEMBLY-NEXT:#define __FLT128_DECIMAL_DIG__ 36
1580-
// WEBASSEMBLY-NEXT:#define __FLT128_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966Q
1581-
// WEBASSEMBLY-NEXT:#define __FLT128_DIG__ 33
1582-
// WEBASSEMBLY-NEXT:#define __FLT128_EPSILON__ 1.92592994438723585305597794258492732e-34Q
1583-
// WEBASSEMBLY-NEXT:#define __FLT128_HAS_DENORM__ 1
1584-
// WEBASSEMBLY-NEXT:#define __FLT128_HAS_INFINITY__ 1
1585-
// WEBASSEMBLY-NEXT:#define __FLT128_HAS_QUIET_NAN__ 1
1586-
// WEBASSEMBLY-NEXT:#define __FLT128_MANT_DIG__ 113
1587-
// WEBASSEMBLY-NEXT:#define __FLT128_MAX_10_EXP__ 4932
1588-
// WEBASSEMBLY-NEXT:#define __FLT128_MAX_EXP__ 16384
1589-
// WEBASSEMBLY-NEXT:#define __FLT128_MAX__ 1.18973149535723176508575932662800702e+4932Q
1590-
// WEBASSEMBLY-NEXT:#define __FLT128_MIN_10_EXP__ (-4931)
1591-
// WEBASSEMBLY-NEXT:#define __FLT128_MIN_EXP__ (-16381)
1592-
// WEBASSEMBLY-NEXT:#define __FLT128_MIN__ 3.36210314311209350626267781732175260e-4932Q
15931579
// WEBASSEMBLY-NOT:#define __FLT16_DECIMAL_DIG__
15941580
// WEBASSEMBLY-NOT:#define __FLT16_DENORM_MIN__
15951581
// WEBASSEMBLY-NOT:#define __FLT16_DIG__

clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ Error linkBitcodeFiles(SmallVectorImpl<OffloadFile> &InputFiles,
595595
StringRef Arch = Args.getLastArgValue(OPT_arch_EQ);
596596

597597
SmallVector<OffloadFile, 4> BitcodeInputFiles;
598+
DenseSet<StringRef> StrongResolutions;
598599
DenseSet<StringRef> UsedInRegularObj;
599600
DenseSet<StringRef> UsedInSharedLib;
600601
BumpPtrAllocator Alloc;
@@ -608,6 +609,18 @@ Error linkBitcodeFiles(SmallVectorImpl<OffloadFile> &InputFiles,
608609
file_magic Type = identify_magic(Buffer.getBuffer());
609610
switch (Type) {
610611
case file_magic::bitcode: {
612+
Expected<IRSymtabFile> IRSymtabOrErr = readIRSymtab(Buffer);
613+
if (!IRSymtabOrErr)
614+
return IRSymtabOrErr.takeError();
615+
616+
// Check for any strong resolutions we need to preserve.
617+
for (unsigned I = 0; I != IRSymtabOrErr->Mods.size(); ++I) {
618+
for (const auto &Sym : IRSymtabOrErr->TheReader.module_symbols(I)) {
619+
if (!Sym.isFormatSpecific() && Sym.isGlobal() && !Sym.isWeak() &&
620+
!Sym.isUndefined())
621+
StrongResolutions.insert(Saver.save(Sym.Name));
622+
}
623+
}
611624
BitcodeInputFiles.emplace_back(std::move(File));
612625
continue;
613626
}
@@ -696,6 +709,7 @@ Error linkBitcodeFiles(SmallVectorImpl<OffloadFile> &InputFiles,
696709
// it is undefined or another definition has already been used.
697710
Res.Prevailing =
698711
!Sym.isUndefined() &&
712+
!(Sym.isWeak() && StrongResolutions.contains(Sym.getName())) &&
699713
PrevailingSymbols.insert(Saver.save(Sym.getName())).second;
700714

701715
// We need LTO to preseve the following global symbols:

0 commit comments

Comments
 (0)