Skip to content

Commit 1bffdb3

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#3156)
2 parents c7e8239 + 65ef9a7 commit 1bffdb3

File tree

171 files changed

+7655
-5294
lines changed

Some content is hidden

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

171 files changed

+7655
-5294
lines changed

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6015,6 +6015,16 @@ the configuration (without a prefix: ``Auto``).
60156015
#include "B/A.h" #include "B/a.h"
60166016
#include "B/a.h" #include "a/b.h"
60176017

6018+
* ``bool IgnoreExtension`` When sorting includes in each block, only take file extensions into
6019+
account if two includes compare equal otherwise.
6020+
6021+
.. code-block:: c++
6022+
6023+
true: false:
6024+
# include "A.h" vs. # include "A-util.h"
6025+
# include "A.inc" # include "A.h"
6026+
# include "A-util.h" # include "A.inc"
6027+
60186028

60196029
.. _SortJavaStaticImport:
60206030

clang/include/clang/Format/Format.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4385,8 +4385,18 @@ struct FormatStyle {
43854385
/// #include "B/a.h" #include "a/b.h"
43864386
/// \endcode
43874387
bool IgnoreCase;
4388+
/// When sorting includes in each block, only take file extensions into
4389+
/// account if two includes compare equal otherwise.
4390+
/// \code
4391+
/// true: false:
4392+
/// # include "A.h" vs. # include "A-util.h"
4393+
/// # include "A.inc" # include "A.h"
4394+
/// # include "A-util.h" # include "A.inc"
4395+
/// \endcode
4396+
bool IgnoreExtension;
43884397
bool operator==(const SortIncludesOptions &R) const {
4389-
return Enabled == R.Enabled && IgnoreCase == R.IgnoreCase;
4398+
return Enabled == R.Enabled && IgnoreCase == R.IgnoreCase &&
4399+
IgnoreExtension == R.IgnoreExtension;
43904400
}
43914401
bool operator!=(const SortIncludesOptions &R) const {
43924402
return !(*this == R);

clang/include/clang/Sema/Overload.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,6 @@ class Sema;
350350
LLVM_PREFERRED_TYPE(bool)
351351
unsigned BindsToRvalue : 1;
352352

353-
/// Whether this was an identity conversion with qualification
354-
/// conversion for the implicit object argument.
355-
LLVM_PREFERRED_TYPE(bool)
356-
unsigned IsImplicitObjectArgumentQualificationConversion : 1;
357-
358353
/// Whether this binds an implicit object argument to a
359354
/// non-static member function without a ref-qualifier.
360355
LLVM_PREFERRED_TYPE(bool)
@@ -453,11 +448,11 @@ class Sema;
453448
#endif
454449
return true;
455450
}
451+
if (!C.hasSameType(getFromType(), getToType(2)))
452+
return false;
456453
if (BindsToRvalue && IsLvalueReference)
457454
return false;
458-
if (IsImplicitObjectArgumentQualificationConversion)
459-
return C.hasSameUnqualifiedType(getFromType(), getToType(2));
460-
return C.hasSameType(getFromType(), getToType(2));
455+
return true;
461456
}
462457

463458
ImplicitConversionRank getRank() const;

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7053,24 +7053,27 @@ SanitizerOrdinalToCheckLabel(SanitizerKind::SanitizerOrdinal Ordinal) {
70537053
llvm::DILocation *CodeGenFunction::SanitizerAnnotateDebugInfo(
70547054
ArrayRef<SanitizerKind::SanitizerOrdinal> Ordinals,
70557055
SanitizerHandler Handler) {
7056+
llvm::DILocation *CheckDebugLoc = Builder.getCurrentDebugLocation();
7057+
auto *DI = getDebugInfo();
7058+
if (!DI)
7059+
return CheckDebugLoc;
7060+
70567061
std::string Label;
70577062
if (Ordinals.size() == 1)
70587063
Label = SanitizerOrdinalToCheckLabel(Ordinals[0]);
70597064
else
70607065
Label = SanitizerHandlerToCheckLabel(Handler);
70617066

7062-
llvm::DILocation *CheckDI = Builder.getCurrentDebugLocation();
7063-
70647067
for (auto Ord : Ordinals) {
70657068
// TODO: deprecate ClArrayBoundsPseudoFn
70667069
if (((ClArrayBoundsPseudoFn && Ord == SanitizerKind::SO_ArrayBounds) ||
70677070
CGM.getCodeGenOpts().SanitizeAnnotateDebugInfo.has(Ord)) &&
7068-
CheckDI) {
7069-
return getDebugInfo()->CreateSyntheticInlineAt(CheckDI, Label);
7071+
CheckDebugLoc) {
7072+
return DI->CreateSyntheticInlineAt(CheckDebugLoc, Label);
70707073
}
70717074
}
70727075

7073-
return CheckDI;
7076+
return CheckDebugLoc;
70747077
}
70757078

70767079
SanitizerDebugLocation::SanitizerDebugLocation(

clang/lib/Format/Format.cpp

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -665,21 +665,25 @@ template <> struct MappingTraits<FormatStyle::SortIncludesOptions> {
665665
IO.enumCase(Value, "Never", FormatStyle::SortIncludesOptions({}));
666666
IO.enumCase(Value, "CaseInsensitive",
667667
FormatStyle::SortIncludesOptions({/*Enabled=*/true,
668-
/*IgnoreCase=*/true}));
668+
/*IgnoreCase=*/true,
669+
/*IgnoreExtension=*/false}));
669670
IO.enumCase(Value, "CaseSensitive",
670671
FormatStyle::SortIncludesOptions({/*Enabled=*/true,
671-
/*IgnoreCase=*/false}));
672+
/*IgnoreCase=*/false,
673+
/*IgnoreExtension=*/false}));
672674

673675
// For backward compatibility.
674676
IO.enumCase(Value, "false", FormatStyle::SortIncludesOptions({}));
675677
IO.enumCase(Value, "true",
676678
FormatStyle::SortIncludesOptions({/*Enabled=*/true,
677-
/*IgnoreCase=*/false}));
679+
/*IgnoreCase=*/false,
680+
/*IgnoreExtension=*/false}));
678681
}
679682

680683
static void mapping(IO &IO, FormatStyle::SortIncludesOptions &Value) {
681684
IO.mapOptional("Enabled", Value.Enabled);
682685
IO.mapOptional("IgnoreCase", Value.IgnoreCase);
686+
IO.mapOptional("IgnoreExtension", Value.IgnoreExtension);
683687
}
684688
};
685689

@@ -1650,7 +1654,8 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
16501654
LLVMStyle.SeparateDefinitionBlocks = FormatStyle::SDS_Leave;
16511655
LLVMStyle.ShortNamespaceLines = 1;
16521656
LLVMStyle.SkipMacroDefinitionBody = false;
1653-
LLVMStyle.SortIncludes = {/*Enabled=*/true, /*IgnoreCase=*/false};
1657+
LLVMStyle.SortIncludes = {/*Enabled=*/true, /*IgnoreCase=*/false,
1658+
/*IgnoreExtension=*/false};
16541659
LLVMStyle.SortJavaStaticImport = FormatStyle::SJSIO_Before;
16551660
LLVMStyle.SortUsingDeclarations = FormatStyle::SUD_LexicographicNumeric;
16561661
LLVMStyle.SpaceAfterCStyleCast = false;
@@ -3239,19 +3244,27 @@ static void sortCppIncludes(const FormatStyle &Style,
32393244
SmallVector<unsigned, 16> Indices =
32403245
llvm::to_vector<16>(llvm::seq<unsigned>(0, Includes.size()));
32413246

3242-
if (Style.SortIncludes.Enabled && Style.SortIncludes.IgnoreCase) {
3247+
if (Style.SortIncludes.Enabled) {
32433248
stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
3244-
const auto LHSFilenameLower = Includes[LHSI].Filename.lower();
3245-
const auto RHSFilenameLower = Includes[RHSI].Filename.lower();
3246-
return std::tie(Includes[LHSI].Priority, LHSFilenameLower,
3247-
Includes[LHSI].Filename) <
3248-
std::tie(Includes[RHSI].Priority, RHSFilenameLower,
3249-
Includes[RHSI].Filename);
3250-
});
3251-
} else {
3252-
stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
3253-
return std::tie(Includes[LHSI].Priority, Includes[LHSI].Filename) <
3254-
std::tie(Includes[RHSI].Priority, Includes[RHSI].Filename);
3249+
SmallString<128> LHSStem, RHSStem;
3250+
if (Style.SortIncludes.IgnoreExtension) {
3251+
LHSStem = Includes[LHSI].Filename;
3252+
RHSStem = Includes[RHSI].Filename;
3253+
llvm::sys::path::replace_extension(LHSStem, "");
3254+
llvm::sys::path::replace_extension(RHSStem, "");
3255+
}
3256+
std::string LHSStemLower, RHSStemLower;
3257+
std::string LHSFilenameLower, RHSFilenameLower;
3258+
if (Style.SortIncludes.IgnoreCase) {
3259+
LHSStemLower = LHSStem.str().lower();
3260+
RHSStemLower = RHSStem.str().lower();
3261+
LHSFilenameLower = Includes[LHSI].Filename.lower();
3262+
RHSFilenameLower = Includes[RHSI].Filename.lower();
3263+
}
3264+
return std::tie(Includes[LHSI].Priority, LHSStemLower, LHSStem,
3265+
LHSFilenameLower, Includes[LHSI].Filename) <
3266+
std::tie(Includes[RHSI].Priority, RHSStemLower, RHSStem,
3267+
RHSFilenameLower, Includes[RHSI].Filename);
32553268
});
32563269
}
32573270

clang/lib/Sema/SemaOverload.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ void StandardConversionSequence::setAsIdentityConversion() {
246246
IsLvalueReference = true;
247247
BindsToFunctionLvalue = false;
248248
BindsToRvalue = false;
249-
IsImplicitObjectArgumentQualificationConversion = false;
250249
BindsImplicitObjectArgumentWithoutRefQualifier = false;
251250
ObjCLifetimeConversionBinding = false;
252251
FromBracedInitList = false;
@@ -5319,7 +5318,6 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType,
53195318
ICS.Standard.DirectBinding = BindsDirectly;
53205319
ICS.Standard.IsLvalueReference = !isRValRef;
53215320
ICS.Standard.BindsToFunctionLvalue = T2->isFunctionType();
5322-
ICS.Standard.IsImplicitObjectArgumentQualificationConversion = false;
53235321
ICS.Standard.BindsToRvalue = InitCategory.isRValue();
53245322
ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier = false;
53255323
ICS.Standard.ObjCLifetimeConversionBinding =
@@ -5499,7 +5497,6 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType,
54995497
ICS.Standard.IsLvalueReference = !isRValRef;
55005498
ICS.Standard.BindsToFunctionLvalue = false;
55015499
ICS.Standard.BindsToRvalue = true;
5502-
ICS.Standard.IsImplicitObjectArgumentQualificationConversion = false;
55035500
ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier = false;
55045501
ICS.Standard.ObjCLifetimeConversionBinding = false;
55055502
} else if (ICS.isUserDefined()) {
@@ -5522,8 +5519,6 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType,
55225519
ICS.UserDefined.After.IsLvalueReference = !isRValRef;
55235520
ICS.UserDefined.After.BindsToFunctionLvalue = false;
55245521
ICS.UserDefined.After.BindsToRvalue = !LValRefType;
5525-
ICS.UserDefined.After.IsImplicitObjectArgumentQualificationConversion =
5526-
false;
55275522
ICS.UserDefined.After.BindsImplicitObjectArgumentWithoutRefQualifier = false;
55285523
ICS.UserDefined.After.ObjCLifetimeConversionBinding = false;
55295524
ICS.UserDefined.After.FromBracedInitList = false;
@@ -5808,7 +5803,6 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
58085803
StandardConversionSequence &SCS = Result.isStandard() ? Result.Standard :
58095804
Result.UserDefined.After;
58105805
SCS.ReferenceBinding = true;
5811-
SCS.IsImplicitObjectArgumentQualificationConversion = false;
58125806
SCS.IsLvalueReference = ToType->isLValueReferenceType();
58135807
SCS.BindsToRvalue = true;
58145808
SCS.BindsToFunctionLvalue = false;
@@ -6006,12 +6000,8 @@ static ImplicitConversionSequence TryObjectArgumentInitialization(
60066000
// affects the conversion rank.
60076001
QualType ClassTypeCanon = S.Context.getCanonicalType(ClassType);
60086002
ImplicitConversionKind SecondKind;
6009-
bool IsQualificationConversion = false;
6010-
if (ImplicitParamType.getCanonicalType() == FromTypeCanon) {
6003+
if (ClassTypeCanon == FromTypeCanon.getLocalUnqualifiedType()) {
60116004
SecondKind = ICK_Identity;
6012-
} else if (ClassTypeCanon == FromTypeCanon.getLocalUnqualifiedType()) {
6013-
SecondKind = ICK_Identity;
6014-
IsQualificationConversion = true;
60156005
} else if (S.IsDerivedFrom(Loc, FromType, ClassType)) {
60166006
SecondKind = ICK_Derived_To_Base;
60176007
} else if (!Method->isExplicitObjectMemberFunction()) {
@@ -6052,8 +6042,6 @@ static ImplicitConversionSequence TryObjectArgumentInitialization(
60526042
ICS.Standard.setFromType(FromType);
60536043
ICS.Standard.setAllToTypes(ImplicitParamType);
60546044
ICS.Standard.ReferenceBinding = true;
6055-
ICS.Standard.IsImplicitObjectArgumentQualificationConversion =
6056-
IsQualificationConversion;
60576045
ICS.Standard.DirectBinding = true;
60586046
ICS.Standard.IsLvalueReference = Method->getRefQualifier() != RQ_RValue;
60596047
ICS.Standard.BindsToFunctionLvalue = false;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: %clangxx -g -fsanitize=null -fsanitize-trap=all -fsanitize-annotate-debug-info=all -O2 -std=c++17 -c -o /dev/null %s
2+
3+
struct foo {
4+
foo(int, long, const int & = int());
5+
} foo(0, 0);

clang/test/Driver/frame-pointer-elim.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
// RUN: FileCheck --check-prefix=KEEP-ALL %s
163163
// RUN: %clang -### --target=riscv64-linux-android -O1 -S %s 2>&1 | \
164164
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
165-
// RUN: not %clang -### --target=riscv64-linux-android -mbig-endian -O1 -S %s 2>&1 | \
165+
// RUN: %clang -### --target=riscv64-linux-android -mbig-endian -O1 -S %s 2>&1 | \
166166
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
167167

168168
// On ARM backend bare metal targets, frame pointer is omitted

clang/test/SemaCXX/overload-resolution-deferred-templates.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -283,31 +283,3 @@ void f() {
283283
}
284284

285285
#endif
286-
287-
namespace GH147374 {
288-
289-
struct String {};
290-
template <typename T> void operator+(T, String &&) = delete;
291-
292-
struct Bar {
293-
void operator+(String) const; // expected-note {{candidate function}}
294-
friend void operator+(Bar, String) {}; // expected-note {{candidate function}}
295-
};
296-
297-
struct Baz {
298-
void operator+(String); // expected-note {{candidate function}}
299-
friend void operator+(Baz, String) {}; // expected-note {{candidate function}}
300-
};
301-
302-
void test() {
303-
Bar a;
304-
String b;
305-
a + b;
306-
//expected-error@-1 {{use of overloaded operator '+' is ambiguous (with operand types 'Bar' and 'String')}}
307-
308-
Baz z;
309-
z + b;
310-
//expected-error@-1 {{use of overloaded operator '+' is ambiguous (with operand types 'Baz' and 'String')}}
311-
}
312-
313-
}

clang/unittests/Format/ConfigParseTest.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ TEST(ConfigParseTest, ParsesConfigurationBools) {
259259
CHECK_PARSE_NESTED_BOOL(SpacesInParensOptions, Other);
260260
CHECK_PARSE_NESTED_BOOL(SortIncludes, Enabled);
261261
CHECK_PARSE_NESTED_BOOL(SortIncludes, IgnoreCase);
262+
CHECK_PARSE_NESTED_BOOL(SortIncludes, IgnoreExtension);
262263
}
263264

264265
#undef CHECK_PARSE_BOOL
@@ -980,17 +981,20 @@ TEST(ConfigParseTest, ParsesConfiguration) {
980981
IncludeStyle.IncludeIsMainSourceRegex, "abc$");
981982

982983
Style.SortIncludes = {};
983-
CHECK_PARSE("SortIncludes: true", SortIncludes,
984-
FormatStyle::SortIncludesOptions(
985-
{/*Enabled=*/true, /*IgnoreCase=*/false}));
984+
CHECK_PARSE(
985+
"SortIncludes: true", SortIncludes,
986+
FormatStyle::SortIncludesOptions(
987+
{/*Enabled=*/true, /*IgnoreCase=*/false, /*IgnoreExtension=*/false}));
986988
CHECK_PARSE("SortIncludes: false", SortIncludes,
987989
FormatStyle::SortIncludesOptions({}));
988-
CHECK_PARSE("SortIncludes: CaseInsensitive", SortIncludes,
989-
FormatStyle::SortIncludesOptions(
990-
{/*Enabled=*/true, /*IgnoreCase=*/true}));
991-
CHECK_PARSE("SortIncludes: CaseSensitive", SortIncludes,
992-
FormatStyle::SortIncludesOptions(
993-
{/*Enabled=*/true, /*IgnoreCase=*/false}));
990+
CHECK_PARSE(
991+
"SortIncludes: CaseInsensitive", SortIncludes,
992+
FormatStyle::SortIncludesOptions(
993+
{/*Enabled=*/true, /*IgnoreCase=*/true, /*IgnoreExtension=*/false}));
994+
CHECK_PARSE(
995+
"SortIncludes: CaseSensitive", SortIncludes,
996+
FormatStyle::SortIncludesOptions(
997+
{/*Enabled=*/true, /*IgnoreCase=*/false, /*IgnoreExtension=*/false}));
994998
CHECK_PARSE("SortIncludes: Never", SortIncludes,
995999
FormatStyle::SortIncludesOptions({}));
9961000

0 commit comments

Comments
 (0)