Skip to content

Commit d3020e4

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:772b1b0cb26c66804d0a7e416dc7a5742b7f8db2 into amd-gfx:43125be5ad0d
Local branch amd-gfx 43125be Merged main:f97f039e0bb7bb60c9cc437f678059c5ee19c8da into amd-gfx:ce126627c1f0 Remote branch main 772b1b0 [scudo] Move the chunk update into functions (llvm#83493)
2 parents 43125be + 772b1b0 commit d3020e4

Some content is hidden

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

53 files changed

+873
-251
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ C++ Specific Potentially Breaking Changes
5151
- The behavior controlled by the `-frelaxed-template-template-args` flag is now
5252
on by default, and the flag is deprecated. Until the flag is finally removed,
5353
it's negative spelling can be used to obtain compatibility with previous
54-
versions of clang.
54+
versions of clang. The deprecation warning for the negative spelling can be
55+
disabled with `-Wno-deprecated-no-relaxed-template-template-args`.
5556

5657
- Clang now rejects pointer to member from parenthesized expression in unevaluated context such as ``decltype(&(foo::bar))``. (#GH40906).
5758

@@ -713,6 +714,9 @@ Bug Fixes to C++ Support
713714
- Correctly treat the compound statement of an ``if consteval`` as an immediate context. Fixes (#GH91509).
714715
- When partial ordering alias templates against template template parameters,
715716
allow pack expansions when the alias has a fixed-size parameter list. Fixes (#GH62529).
717+
- Clang now ignores template parameters only used within the exception specification of candidate function
718+
templates during partial ordering when deducing template arguments from a function declaration or when
719+
taking the address of a function template.
716720

717721
Bug Fixes to AST Handling
718722
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,9 @@ def warn_drv_clang_unsupported : Warning<
436436
"the clang compiler does not support '%0'">;
437437
def warn_drv_deprecated_arg : Warning<
438438
"argument '%0' is deprecated%select{|, use '%2' instead}1">, InGroup<Deprecated>;
439+
def warn_drv_deprecated_arg_no_relaxed_template_template_args : Warning<
440+
"argument '-fno-relaxed-template-template-args' is deprecated">,
441+
InGroup<DeprecatedNoRelaxedTemplateTemplateArgs>;
439442
def warn_drv_deprecated_custom : Warning<
440443
"argument '%0' is deprecated, %1">, InGroup<Deprecated>;
441444
def warn_drv_assuming_mfloat_abi_is : Warning<

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def EnumConversion : DiagGroup<"enum-conversion",
104104
[EnumEnumConversion,
105105
EnumFloatConversion,
106106
EnumCompareConditional]>;
107+
def DeprecatedNoRelaxedTemplateTemplateArgs : DiagGroup<"deprecated-no-relaxed-template-template-args">;
107108
def ObjCSignedCharBoolImplicitIntConversion :
108109
DiagGroup<"objc-signed-char-bool-implicit-int-conversion">;
109110
def Shorten64To32 : DiagGroup<"shorten-64-to-32">;
@@ -228,6 +229,7 @@ def Deprecated : DiagGroup<"deprecated", [DeprecatedAnonEnumEnumConversion,
228229
DeprecatedLiteralOperator,
229230
DeprecatedPragma,
230231
DeprecatedRegister,
232+
DeprecatedNoRelaxedTemplateTemplateArgs,
231233
DeprecatedThisCapture,
232234
DeprecatedType,
233235
DeprecatedVolatile,

clang/include/clang/Driver/Options.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6647,7 +6647,9 @@ def fdebug_unparse : Flag<["-"], "fdebug-unparse">, Group<Action_Group>,
66476647
DocBrief<[{Run the parser and the semantic checks. Then unparse the
66486648
parse-tree and output the generated Fortran source file.}]>;
66496649
def fdebug_unparse_with_symbols : Flag<["-"], "fdebug-unparse-with-symbols">, Group<Action_Group>,
6650-
HelpText<"Unparse and stop.">;
6650+
HelpText<"Unparse with symbols and stop.">;
6651+
def fdebug_unparse_with_modules : Flag<["-"], "fdebug-unparse-with-modules">, Group<Action_Group>,
6652+
HelpText<"Unparse with dependent modules and stop.">;
66516653
def fdebug_dump_symbols : Flag<["-"], "fdebug-dump-symbols">, Group<Action_Group>,
66526654
HelpText<"Dump symbols after the semantic analysis">;
66536655
def fdebug_dump_parse_tree : Flag<["-"], "fdebug-dump-parse-tree">, Group<Action_Group>,

clang/lib/CodeGen/CoverageMappingGen.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,10 @@ struct CounterCoverageMappingBuilder
14391439
terminateRegion(S);
14401440
}
14411441

1442+
void VisitCoroutineSuspendExpr(const CoroutineSuspendExpr *E) {
1443+
Visit(E->getOperand());
1444+
}
1445+
14421446
void VisitCXXThrowExpr(const CXXThrowExpr *E) {
14431447
extendRegion(E);
14441448
if (E->getSubExpr())
@@ -2173,6 +2177,10 @@ struct CounterCoverageMappingBuilder
21732177
// propagate counts into them.
21742178
}
21752179

2180+
void VisitArrayInitLoopExpr(const ArrayInitLoopExpr *AILE) {
2181+
Visit(AILE->getCommonExpr()->getSourceExpr());
2182+
}
2183+
21762184
void VisitPseudoObjectExpr(const PseudoObjectExpr *POE) {
21772185
// Just visit syntatic expression as this is what users actually write.
21782186
VisitStmt(POE->getSyntacticForm());

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7253,10 +7253,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
72537253
if (Arg *A =
72547254
Args.getLastArg(options::OPT_frelaxed_template_template_args,
72557255
options::OPT_fno_relaxed_template_template_args)) {
7256-
D.Diag(diag::warn_drv_deprecated_arg)
7257-
<< A->getAsString(Args) << /*hasReplacement=*/false;
7258-
if (A->getOption().matches(options::OPT_fno_relaxed_template_template_args))
7256+
if (A->getOption().matches(
7257+
options::OPT_fno_relaxed_template_template_args)) {
7258+
D.Diag(diag::warn_drv_deprecated_arg_no_relaxed_template_template_args);
72597259
CmdArgs.push_back("-fno-relaxed-template-template-args");
7260+
} else {
7261+
D.Diag(diag::warn_drv_deprecated_arg)
7262+
<< A->getAsString(Args) << /*hasReplacement=*/false;
7263+
}
72607264
}
72617265

72627266
// -fsized-deallocation is off by default, as it is an ABI-breaking change for

clang/lib/Sema/SemaTemplateDeduction.cpp

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5453,7 +5453,7 @@ static bool isAtLeastAsSpecializedAs(Sema &S, SourceLocation Loc,
54535453
// is used.
54545454
if (DeduceTemplateArgumentsByTypeMatch(
54555455
S, TemplateParams, FD2->getType(), FD1->getType(), Info, Deduced,
5456-
TDF_None,
5456+
TDF_AllowCompatibleFunctionType,
54575457
/*PartialOrdering=*/true) != TemplateDeductionResult::Success)
54585458
return false;
54595459
break;
@@ -5485,20 +5485,40 @@ static bool isAtLeastAsSpecializedAs(Sema &S, SourceLocation Loc,
54855485
switch (TPOC) {
54865486
case TPOC_Call:
54875487
for (unsigned I = 0, N = Args2.size(); I != N; ++I)
5488-
::MarkUsedTemplateParameters(S.Context, Args2[I], false,
5489-
TemplateParams->getDepth(),
5490-
UsedParameters);
5488+
::MarkUsedTemplateParameters(S.Context, Args2[I], /*OnlyDeduced=*/false,
5489+
TemplateParams->getDepth(), UsedParameters);
54915490
break;
54925491

54935492
case TPOC_Conversion:
5494-
::MarkUsedTemplateParameters(S.Context, Proto2->getReturnType(), false,
5493+
::MarkUsedTemplateParameters(S.Context, Proto2->getReturnType(),
5494+
/*OnlyDeduced=*/false,
54955495
TemplateParams->getDepth(), UsedParameters);
54965496
break;
54975497

54985498
case TPOC_Other:
5499-
::MarkUsedTemplateParameters(S.Context, FD2->getType(), false,
5500-
TemplateParams->getDepth(),
5501-
UsedParameters);
5499+
// We do not deduce template arguments from the exception specification
5500+
// when determining the primary template of a function template
5501+
// specialization or when taking the address of a function template.
5502+
// Therefore, we do not mark template parameters in the exception
5503+
// specification as used during partial ordering to prevent the following
5504+
// from being ambiguous:
5505+
//
5506+
// template<typename T, typename U>
5507+
// void f(U) noexcept(noexcept(T())); // #1
5508+
//
5509+
// template<typename T>
5510+
// void f(T*) noexcept; // #2
5511+
//
5512+
// template<>
5513+
// void f<int>(int*) noexcept; // explicit specialization of #2
5514+
//
5515+
// Although there is no corresponding wording in the standard, this seems
5516+
// to be the intended behavior given the definition of
5517+
// 'deduction substitution loci' in [temp.deduct].
5518+
::MarkUsedTemplateParameters(
5519+
S.Context,
5520+
S.Context.getFunctionTypeWithExceptionSpec(FD2->getType(), EST_None),
5521+
/*OnlyDeduced=*/false, TemplateParams->getDepth(), UsedParameters);
55025522
break;
55035523
}
55045524

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// RUN: %clang_cc1 -fsyntax-only -verify %s
2+
// expected-no-diagnostics
3+
4+
template<bool B>
5+
struct A { };
6+
7+
constexpr A<false> a;
8+
constexpr A<false> b;
9+
10+
constexpr int* x = nullptr;
11+
constexpr short* y = nullptr;
12+
13+
namespace ExplicitArgs {
14+
template<typename T, typename U>
15+
constexpr int f(U) noexcept(noexcept(T())) {
16+
return 0;
17+
}
18+
19+
template<typename T>
20+
constexpr int f(T*) noexcept {
21+
return 1;
22+
}
23+
24+
template<>
25+
constexpr int f<int>(int*) noexcept {
26+
return 2;
27+
}
28+
29+
static_assert(f<int>(1) == 0);
30+
static_assert(f<short>(y) == 1);
31+
static_assert(f<int>(x) == 2);
32+
33+
template<typename T, typename U>
34+
constexpr int g(U*) noexcept(noexcept(T())) {
35+
return 3;
36+
}
37+
38+
template<typename T>
39+
constexpr int g(T) noexcept {
40+
return 4;
41+
}
42+
43+
template<>
44+
constexpr int g<int>(int*) noexcept {
45+
return 5;
46+
}
47+
48+
static_assert(g<int>(y) == 3);
49+
static_assert(g<short>(1) == 4);
50+
static_assert(g<int>(x) == 5);
51+
} // namespace ExplicitArgs
52+
53+
namespace DeducedArgs {
54+
template<typename T, bool B>
55+
constexpr int f(T, A<B>) noexcept(B) {
56+
return 0;
57+
}
58+
59+
template<typename T, bool B>
60+
constexpr int f(T*, A<B>) noexcept(B && B) {
61+
return 1;
62+
}
63+
64+
template<>
65+
constexpr int f(int*, A<false>) {
66+
return 2;
67+
}
68+
69+
static_assert(f<int*>(x, a) == 0);
70+
static_assert(f<short>(y, a) == 1);
71+
static_assert(f<int>(x, a) == 2);
72+
} // namespace DeducedArgs

clang/test/CoverageMapping/coroutine.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ struct std::coroutine_traits<int, int> {
3232
suspend_always final_suspend() noexcept;
3333
void unhandled_exception() noexcept;
3434
void return_value(int);
35+
suspend_always yield_value(int);
3536
};
3637
};
3738

@@ -45,3 +46,21 @@ int f1(int x) { // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+8]]:2 = #0
4546
} // CHECK-NEXT: File 0, [[@LINE-2]]:10 -> [[@LINE]]:4 = (#0 - #1)
4647
co_return x; // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE]]:3 = #1
4748
} // CHECK-NEXT: File 0, [[@LINE-1]]:3 -> [[@LINE-1]]:14 = #1
49+
50+
// CHECK-LABEL: _Z2f2i:
51+
// CHECK-NEXT: File 0, [[@LINE+1]]:15 -> [[@LINE+15]]:2 = #0
52+
int f2(int x) {
53+
// CHECK-NEXT: File 0, [[@LINE+5]]:13 -> [[@LINE+5]]:18 = #0
54+
// CHECK-NEXT: Branch,File 0, [[@LINE+4]]:13 -> [[@LINE+4]]:18 = #1, (#0 - #1)
55+
// CHECK-NEXT: Gap,File 0, [[@LINE+3]]:20 -> [[@LINE+3]]:21 = #1
56+
// CHECK-NEXT: File 0, [[@LINE+2]]:21 -> [[@LINE+2]]:37 = #1
57+
// CHECK-NEXT: File 0, [[@LINE+1]]:40 -> [[@LINE+1]]:56 = (#0 - #1)
58+
co_await (x > 0 ? suspend_always{} : suspend_always{});
59+
// CHECK-NEXT: File 0, [[@LINE+5]]:12 -> [[@LINE+5]]:17 = #0
60+
// CHECK-NEXT: Branch,File 0, [[@LINE+4]]:12 -> [[@LINE+4]]:17 = #2, (#0 - #2)
61+
// CHECK-NEXT: Gap,File 0, [[@LINE+3]]:19 -> [[@LINE+3]]:20 = #2
62+
// CHECK-NEXT: File 0, [[@LINE+2]]:20 -> [[@LINE+2]]:21 = #2
63+
// CHECK-NEXT: File 0, [[@LINE+1]]:24 -> [[@LINE+1]]:25 = (#0 - #2)
64+
co_yield x > 0 ? 1 : 2;
65+
co_return 0;
66+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -triple %itanium_abi_triple -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
2+
3+
// CHECK-LABEL: _Z19array_decompositioni:
4+
// CHECK-NEXT: File 0, [[@LINE+6]]:32 -> {{[0-9]+}}:2 = #0
5+
// CHECK-NEXT: File 0, [[@LINE+8]]:20 -> [[@LINE+8]]:25 = #0
6+
// CHECK-NEXT: Branch,File 0, [[@LINE+7]]:20 -> [[@LINE+7]]:25 = #1, (#0 - #1)
7+
// CHECK-NEXT: Gap,File 0, [[@LINE+6]]:27 -> [[@LINE+6]]:28 = #1
8+
// CHECK-NEXT: File 0, [[@LINE+5]]:28 -> [[@LINE+5]]:29 = #1
9+
// CHECK-NEXT: File 0, [[@LINE+4]]:32 -> [[@LINE+4]]:33 = (#0 - #1)
10+
int array_decomposition(int i) {
11+
int a[] = {1, 2, 3};
12+
int b[] = {4, 5, 6};
13+
auto [x, y, z] = i > 0 ? a : b;
14+
return x + y + z;
15+
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// RUN: %clang -fsyntax-only -### %s 2>&1 | FileCheck --check-prefix=CHECK-DEF %s
22
// RUN: %clang -fsyntax-only -frelaxed-template-template-args %s 2>&1 | FileCheck --check-prefix=CHECK-ON %s
33
// RUN: %clang -fsyntax-only -fno-relaxed-template-template-args %s 2>&1 | FileCheck --check-prefix=CHECK-OFF %s
4+
// RUN: %clang -fsyntax-only -fno-relaxed-template-template-args -Wno-deprecated-no-relaxed-template-template-args %s 2>&1 | FileCheck --check-prefix=CHECK-DIS --allow-empty %s
45

56
// CHECK-DEF-NOT: "-cc1"{{.*}} "-fno-relaxed-template-template-args"
67
// CHECK-ON: warning: argument '-frelaxed-template-template-args' is deprecated [-Wdeprecated]
7-
// CHECK-OFF: warning: argument '-fno-relaxed-template-template-args' is deprecated [-Wdeprecated]
8+
// CHECK-OFF: warning: argument '-fno-relaxed-template-template-args' is deprecated [-Wdeprecated-no-relaxed-template-template-args]
9+
// CHECK-DIS-NOT: warning: argument '-fno-relaxed-template-template-args' is deprecated

0 commit comments

Comments
 (0)