Skip to content

Commit 0d909bc

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#3038)
2 parents 2a34bb1 + 79b29d1 commit 0d909bc

File tree

261 files changed

+54791
-89221
lines changed

Some content is hidden

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

261 files changed

+54791
-89221
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,7 @@ Bug Fixes to C++ Support
942942
- Fix a bug where private access specifier of overloaded function not respected. (#GH107629)
943943
- Correctly handle allocations in the condition of a ``if constexpr``.(#GH120197) (#GH134820)
944944
- Fixed a crash when handling invalid member using-declaration in C++20+ mode. (#GH63254)
945+
- Fix name lookup in lambda appearing in the body of a requires expression. (#GH147650)
945946
- Fix a crash when trying to instantiate an ambiguous specialization. (#GH51866)
946947
- Improved handling of variables with ``consteval`` constructors, to
947948
consistently treat the initializer as manifestly constant-evaluated.

clang/include/clang/CIR/Dialect/IR/CIRAttrs.td

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -489,28 +489,28 @@ def BitfieldInfoAttr : CIR_Attr<"BitfieldInfo", "bitfield_info"> {
489489
is 4 bits wide, starts at offset 0, and is signed.
490490
}];
491491
let parameters = (ins "mlir::StringAttr":$name,
492-
"mlir::Type":$storageType,
492+
"mlir::Type":$storage_type,
493493
"uint64_t":$size,
494494
"uint64_t":$offset,
495-
"bool":$isSigned);
495+
"bool":$is_signed);
496496

497497
let assemblyFormat = [{`<` struct($name,
498-
$storageType,
498+
$storage_type,
499499
$size,
500500
$offset,
501-
$isSigned)
501+
$is_signed)
502502
`>`
503503
}];
504504

505505
let builders = [
506506
AttrBuilder<(ins "llvm::StringRef":$name,
507-
"mlir::Type":$storageType,
507+
"mlir::Type":$storage_type,
508508
"uint64_t":$size,
509509
"uint64_t":$offset,
510-
"bool":$isSigned
510+
"bool":$is_signed
511511
), [{
512-
return $_get($_ctxt, mlir::StringAttr::get($_ctxt, name), storageType,
513-
size, offset, isSigned);
512+
return $_get($_ctxt, mlir::StringAttr::get($_ctxt, name), storage_type,
513+
size, offset, is_signed);
514514
}]>
515515
];
516516
}

clang/lib/AST/ExprConstant.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,11 +1428,11 @@ namespace {
14281428
}
14291429
bool destroy(bool RunDestructors = true) {
14301430
bool OK = cleanup(Info, RunDestructors, OldStackSize);
1431-
OldStackSize = -1U;
1431+
OldStackSize = std::numeric_limits<unsigned>::max();
14321432
return OK;
14331433
}
14341434
~ScopeRAII() {
1435-
if (OldStackSize != -1U)
1435+
if (OldStackSize != std::numeric_limits<unsigned>::max())
14361436
destroy(false);
14371437
// Body moved to a static method to encourage the compiler to inline away
14381438
// instances of this class.

clang/lib/AST/ItaniumMangle.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,9 @@ void CXXNameMangler::mangleNameWithAbiTags(GlobalDecl GD,
10881088
return;
10891089
}
10901090

1091+
while (DC->isRequiresExprBody())
1092+
DC = DC->getParent();
1093+
10911094
if (DC->isTranslationUnit() || isStdNamespace(DC)) {
10921095
// Check if we have a template.
10931096
const TemplateArgumentList *TemplateArgs = nullptr;

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6352,7 +6352,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
63526352

63536353
if (getLastProfileSampleUseArg(Args) &&
63546354
Args.hasFlag(options::OPT_fsample_profile_use_profi,
6355-
options::OPT_fno_sample_profile_use_profi, false)) {
6355+
options::OPT_fno_sample_profile_use_profi, true)) {
63566356
CmdArgs.push_back("-mllvm");
63576357
CmdArgs.push_back("-sample-profile-use-profi");
63586358
}

clang/lib/Format/Format.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
#include "UnwrappedLineFormatter.h"
2323
#include "UsingDeclarationsSorter.h"
2424
#include "clang/Tooling/Inclusions/HeaderIncludes.h"
25+
2526
#include "llvm/ADT/Sequence.h"
27+
#include <limits>
2628

2729
#define DEBUG_TYPE "format-formatter"
2830

@@ -777,7 +779,7 @@ template <> struct MappingTraits<FormatStyle::SpacesInLineComment> {
777779
IO.mapOptional("Maximum", signedMaximum);
778780
Space.Maximum = static_cast<unsigned>(signedMaximum);
779781

780-
if (Space.Maximum != -1u)
782+
if (Space.Maximum < std::numeric_limits<unsigned>::max())
781783
Space.Minimum = std::min(Space.Minimum, Space.Maximum);
782784
}
783785
};
@@ -1672,7 +1674,8 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
16721674
LLVMStyle.SpacesBeforeTrailingComments = 1;
16731675
LLVMStyle.SpacesInAngles = FormatStyle::SIAS_Never;
16741676
LLVMStyle.SpacesInContainerLiterals = true;
1675-
LLVMStyle.SpacesInLineCommentPrefix = {/*Minimum=*/1, /*Maximum=*/-1u};
1677+
LLVMStyle.SpacesInLineCommentPrefix = {
1678+
/*Minimum=*/1, /*Maximum=*/std::numeric_limits<unsigned>::max()};
16761679
LLVMStyle.SpacesInParens = FormatStyle::SIPO_Never;
16771680
LLVMStyle.SpacesInSquareBrackets = false;
16781681
LLVMStyle.Standard = FormatStyle::LS_Latest;
@@ -3168,11 +3171,12 @@ static bool affectsRange(ArrayRef<tooling::Range> Ranges, unsigned Start,
31683171
// the index of the first of the duplicates as the others are going to be
31693172
// removed. OffsetToEOL describes the cursor's position relative to the end of
31703173
// its current line.
3171-
// If `Cursor` is not on any #include, `Index` will be UINT_MAX.
3174+
// If `Cursor` is not on any #include, `Index` will be
3175+
// std::numeric_limits<unsigned>::max().
31723176
static std::pair<unsigned, unsigned>
31733177
FindCursorIndex(const ArrayRef<IncludeDirective> &Includes,
31743178
const ArrayRef<unsigned> &Indices, unsigned Cursor) {
3175-
unsigned CursorIndex = UINT_MAX;
3179+
unsigned CursorIndex = std::numeric_limits<unsigned>::max();
31763180
unsigned OffsetToEOL = 0;
31773181
for (int i = 0, e = Includes.size(); i != e; ++i) {
31783182
unsigned Start = Includes[Indices[i]].Offset;
@@ -3440,11 +3444,12 @@ tooling::Replacements sortCppIncludes(const FormatStyle &Style, StringRef Code,
34403444
return Replaces;
34413445
}
34423446

3443-
// Returns group number to use as a first order sort on imports. Gives UINT_MAX
3444-
// if the import does not match any given groups.
3447+
// Returns group number to use as a first order sort on imports. Gives
3448+
// std::numeric_limits<unsigned>::max() if the import does not match any given
3449+
// groups.
34453450
static unsigned findJavaImportGroup(const FormatStyle &Style,
34463451
StringRef ImportIdentifier) {
3447-
unsigned LongestMatchIndex = UINT_MAX;
3452+
unsigned LongestMatchIndex = std::numeric_limits<unsigned>::max();
34483453
unsigned LongestMatchLength = 0;
34493454
for (unsigned I = 0; I < Style.JavaImportGroups.size(); I++) {
34503455
const std::string &GroupPrefix = Style.JavaImportGroups[I];
@@ -3673,13 +3678,15 @@ formatReplacements(StringRef Code, const tooling::Replacements &Replaces,
36733678
namespace {
36743679

36753680
inline bool isHeaderInsertion(const tooling::Replacement &Replace) {
3676-
return Replace.getOffset() == UINT_MAX && Replace.getLength() == 0 &&
3681+
return Replace.getOffset() == std::numeric_limits<unsigned>::max() &&
3682+
Replace.getLength() == 0 &&
36773683
tooling::HeaderIncludes::IncludeRegex.match(
36783684
Replace.getReplacementText());
36793685
}
36803686

36813687
inline bool isHeaderDeletion(const tooling::Replacement &Replace) {
3682-
return Replace.getOffset() == UINT_MAX && Replace.getLength() == 1;
3688+
return Replace.getOffset() == std::numeric_limits<unsigned>::max() &&
3689+
Replace.getLength() == 1;
36833690
}
36843691

36853692
// FIXME: insert empty lines between newly created blocks.
@@ -3699,7 +3706,7 @@ fixCppIncludeInsertions(StringRef Code, const tooling::Replacements &Replaces,
36993706
consumeError(HeaderInsertions.add(R));
37003707
} else if (isHeaderDeletion(R)) {
37013708
HeadersToDelete.insert(R.getReplacementText());
3702-
} else if (R.getOffset() == UINT_MAX) {
3709+
} else if (R.getOffset() == std::numeric_limits<unsigned>::max()) {
37033710
llvm::errs() << "Insertions other than header #include insertion are "
37043711
"not supported! "
37053712
<< R.getReplacementText() << "\n";

clang/lib/Lex/Lexer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <cstddef>
4242
#include <cstdint>
4343
#include <cstring>
44+
#include <limits>
4445
#include <optional>
4546
#include <string>
4647
#include <tuple>
@@ -3456,7 +3457,7 @@ std::optional<uint32_t> Lexer::tryReadNumericUCN(const char *&StartPtr,
34563457
}
34573458

34583459
unsigned Value = llvm::hexDigitValue(C);
3459-
if (Value == -1U) {
3460+
if (Value == std::numeric_limits<unsigned>::max()) {
34603461
if (!Delimited)
34613462
break;
34623463
if (Diagnose)

clang/lib/Sema/SemaExpr.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
#include "llvm/Support/SaveAndRestore.h"
6767
#include "llvm/Support/TimeProfiler.h"
6868
#include "llvm/Support/TypeSize.h"
69+
#include <limits>
6970
#include <optional>
7071

7172
using namespace clang;
@@ -1907,7 +1908,7 @@ ExprResult Sema::CreateGenericSelectionExpr(
19071908
}
19081909

19091910
SmallVector<unsigned, 1> CompatIndices;
1910-
unsigned DefaultIndex = -1U;
1911+
unsigned DefaultIndex = std::numeric_limits<unsigned>::max();
19111912
// Look at the canonical type of the controlling expression in case it was a
19121913
// deduced type like __auto_type. However, when issuing diagnostics, use the
19131914
// type the user wrote in source rather than the canonical one.
@@ -1962,7 +1963,8 @@ ExprResult Sema::CreateGenericSelectionExpr(
19621963
// C11 6.5.1.1p2 "If a generic selection has no default generic association,
19631964
// its controlling expression shall have type compatible with exactly one of
19641965
// the types named in its generic association list."
1965-
if (DefaultIndex == -1U && CompatIndices.size() == 0) {
1966+
if (DefaultIndex == std::numeric_limits<unsigned>::max() &&
1967+
CompatIndices.size() == 0) {
19661968
auto P = GetControllingRangeAndType(ControllingExpr, ControllingType);
19671969
SourceRange SR = P.first;
19681970
Diag(SR.getBegin(), diag::err_generic_sel_no_match) << SR << P.second;

clang/lib/Sema/SemaLambda.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,6 @@ Sema::createLambdaClosureType(SourceRange IntroducerRange, TypeSourceInfo *Info,
249249
unsigned LambdaDependencyKind,
250250
LambdaCaptureDefault CaptureDefault) {
251251
DeclContext *DC = CurContext;
252-
while (!(DC->isFunctionOrMethod() || DC->isRecord() || DC->isFileContext()))
253-
DC = DC->getParent();
254252

255253
bool IsGenericLambda =
256254
Info && getGenericLambdaTemplateParameterList(getCurLambda(), *this);

clang/test/CIR/CodeGen/bitfields.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ typedef struct {
1313
} A;
1414

1515
// CIR-DAG: !rec_A = !cir.record<struct "A" packed padded {!s8i, !s8i, !s8i, !u16i, !cir.array<!u8i x 3>}>
16-
// CIR-DAG: #bfi_more_bits = #cir.bitfield_info<name = "more_bits", storageType = !u16i, size = 4, offset = 3, isSigned = false>
16+
// CIR-DAG: #bfi_more_bits = #cir.bitfield_info<name = "more_bits", storage_type = !u16i, size = 4, offset = 3, is_signed = false>
1717
// LLVM-DAG: %struct.A = type <{ i8, i8, i8, i16, [3 x i8] }>
1818
// OGCG-DAG: %struct.A = type <{ i8, i8, i8, i16, [3 x i8] }>
1919

@@ -35,7 +35,7 @@ typedef struct {
3535
int e : 15;
3636
unsigned f; // type other than int above, not a bitfield
3737
} S;
38-
// CIR-DAG: #bfi_c = #cir.bitfield_info<name = "c", storageType = !u64i, size = 17, offset = 32, isSigned = true>
38+
// CIR-DAG: #bfi_c = #cir.bitfield_info<name = "c", storage_type = !u64i, size = 17, offset = 32, is_signed = true>
3939
// CIR-DAG: !rec_S = !cir.record<struct "S" {!u64i, !u16i, !u32i}>
4040
// LLVM-DAG: %struct.S = type { i64, i16, i32 }
4141
// OGCG-DAG: %struct.S = type { i64, i16, i32 }

0 commit comments

Comments
 (0)