Skip to content

Commit b433a27

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:cbf7d5f82b72 into amd-gfx:8494c22787c6
Local branch amd-gfx 8494c22 Merged main:3694697003bb into amd-gfx:6ae8b419f903 Remote branch main cbf7d5f [AArch64] Fix -Wunused-variable in AArch64LowerHomogeneousPrologEpilog.cpp (NFC)
2 parents 8494c22 + cbf7d5f commit b433a27

37 files changed

+1321
-104
lines changed

.github/workflows/docs.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# LLVM Documentation CI
2+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3+
# See https://llvm.org/LICENSE.txt for license information.
4+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
6+
name: "Test documentation build"
7+
8+
permissions:
9+
contents: read
10+
11+
on:
12+
push:
13+
branches:
14+
- 'main'
15+
paths:
16+
- 'llvm/docs/**'
17+
pull_request:
18+
paths:
19+
- 'llvm/docs/**'
20+
21+
jobs:
22+
check-docs-build:
23+
name: "Test documentation build"
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Fetch LLVM sources
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 1
30+
- name: Setup Python env
31+
uses: actions/setup-python@v4
32+
with:
33+
python-version: '3.11'
34+
cache: 'pip'
35+
cache-dependency-path: 'llvm/docs/requirements.txt'
36+
- name: Install python dependencies
37+
run: pip install -r llvm/docs/requirements.txt
38+
- name: Install system dependencies
39+
run: |
40+
sudo apt-get update
41+
sudo apt-get install -y cmake ninja-build
42+
- name: Build docs
43+
run: |
44+
mkdir build
45+
cd build
46+
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_SPHINX=ON -DSPHINX_OUTPUT_HTML=ON -DSPHINX_OUTPUT_MAN=ON ../llvm
47+
TZ=UTC ninja docs-llvm-html docs-llvm-man
48+

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -516,10 +516,9 @@ Bug Fixes to C++ Support
516516
rather than prefer the non-templated constructor as specified in
517517
[standard.group]p3.
518518

519-
- Fix a bug where implicit deduction guides are not correctly generated for nested template
520-
classes. Fixes:
521-
(`#46200 <https://github.com/llvm/llvm-project/issues/46200>`_)
522-
(`#57812 <https://github.com/llvm/llvm-project/issues/57812>`_)
519+
- Fixed a crash caused by incorrect handling of dependence on variable templates
520+
with non-type template parameters of reference type. Fixes:
521+
(`#65153 <https://github.com/llvm/llvm-project/issues/65153>`_)
523522

524523
Bug Fixes to AST Handling
525524
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/ExprCXX.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3191,7 +3191,8 @@ class UnresolvedLookupExpr final
31913191
const DeclarationNameInfo &NameInfo, bool RequiresADL,
31923192
bool Overloaded,
31933193
const TemplateArgumentListInfo *TemplateArgs,
3194-
UnresolvedSetIterator Begin, UnresolvedSetIterator End);
3194+
UnresolvedSetIterator Begin, UnresolvedSetIterator End,
3195+
bool KnownDependent);
31953196

31963197
UnresolvedLookupExpr(EmptyShell Empty, unsigned NumResults,
31973198
bool HasTemplateKWAndArgsInfo);
@@ -3211,12 +3212,15 @@ class UnresolvedLookupExpr final
32113212
const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded,
32123213
UnresolvedSetIterator Begin, UnresolvedSetIterator End);
32133214

3215+
// After canonicalization, there may be dependent template arguments in
3216+
// CanonicalConverted But none of Args is dependent. When any of
3217+
// CanonicalConverted dependent, KnownDependent is true.
32143218
static UnresolvedLookupExpr *
32153219
Create(const ASTContext &Context, CXXRecordDecl *NamingClass,
32163220
NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
32173221
const DeclarationNameInfo &NameInfo, bool RequiresADL,
32183222
const TemplateArgumentListInfo *Args, UnresolvedSetIterator Begin,
3219-
UnresolvedSetIterator End);
3223+
UnresolvedSetIterator End, bool KnownDependent);
32203224

32213225
static UnresolvedLookupExpr *CreateEmpty(const ASTContext &Context,
32223226
unsigned NumResults,

clang/lib/AST/ASTImporter.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8395,10 +8395,13 @@ ASTNodeImporter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
83958395
if (!ToTemplateKeywordLocOrErr)
83968396
return ToTemplateKeywordLocOrErr.takeError();
83978397

8398+
const bool KnownDependent =
8399+
(E->getDependence() & ExprDependence::TypeValue) ==
8400+
ExprDependence::TypeValue;
83988401
return UnresolvedLookupExpr::Create(
83998402
Importer.getToContext(), *ToNamingClassOrErr, *ToQualifierLocOrErr,
84008403
*ToTemplateKeywordLocOrErr, ToNameInfo, E->requiresADL(), &ToTAInfo,
8401-
ToDecls.begin(), ToDecls.end());
8404+
ToDecls.begin(), ToDecls.end(), KnownDependent);
84028405
}
84038406

84048407
return UnresolvedLookupExpr::Create(

clang/lib/AST/ExprCXX.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,10 @@ UnresolvedLookupExpr::UnresolvedLookupExpr(
354354
NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
355355
const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded,
356356
const TemplateArgumentListInfo *TemplateArgs, UnresolvedSetIterator Begin,
357-
UnresolvedSetIterator End)
357+
UnresolvedSetIterator End, bool KnownDependent)
358358
: OverloadExpr(UnresolvedLookupExprClass, Context, QualifierLoc,
359-
TemplateKWLoc, NameInfo, TemplateArgs, Begin, End, false,
360-
false, false),
359+
TemplateKWLoc, NameInfo, TemplateArgs, Begin, End,
360+
KnownDependent, false, false),
361361
NamingClass(NamingClass) {
362362
UnresolvedLookupExprBits.RequiresADL = RequiresADL;
363363
UnresolvedLookupExprBits.Overloaded = Overloaded;
@@ -380,25 +380,25 @@ UnresolvedLookupExpr *UnresolvedLookupExpr::Create(
380380
void *Mem = Context.Allocate(Size, alignof(UnresolvedLookupExpr));
381381
return new (Mem) UnresolvedLookupExpr(Context, NamingClass, QualifierLoc,
382382
SourceLocation(), NameInfo, RequiresADL,
383-
Overloaded, nullptr, Begin, End);
383+
Overloaded, nullptr, Begin, End, false);
384384
}
385385

386386
UnresolvedLookupExpr *UnresolvedLookupExpr::Create(
387387
const ASTContext &Context, CXXRecordDecl *NamingClass,
388388
NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
389389
const DeclarationNameInfo &NameInfo, bool RequiresADL,
390390
const TemplateArgumentListInfo *Args, UnresolvedSetIterator Begin,
391-
UnresolvedSetIterator End) {
391+
UnresolvedSetIterator End, bool KnownDependent) {
392392
assert(Args || TemplateKWLoc.isValid());
393393
unsigned NumResults = End - Begin;
394394
unsigned NumTemplateArgs = Args ? Args->size() : 0;
395395
unsigned Size =
396396
totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
397397
TemplateArgumentLoc>(NumResults, 1, NumTemplateArgs);
398398
void *Mem = Context.Allocate(Size, alignof(UnresolvedLookupExpr));
399-
return new (Mem) UnresolvedLookupExpr(Context, NamingClass, QualifierLoc,
400-
TemplateKWLoc, NameInfo, RequiresADL,
401-
/*Overloaded*/ true, Args, Begin, End);
399+
return new (Mem) UnresolvedLookupExpr(
400+
Context, NamingClass, QualifierLoc, TemplateKWLoc, NameInfo, RequiresADL,
401+
/*Overloaded=*/true, Args, Begin, End, KnownDependent);
402402
}
403403

404404
UnresolvedLookupExpr *UnresolvedLookupExpr::CreateEmpty(

clang/lib/AST/Interp/Interp.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,11 +1488,14 @@ static inline bool IncDecPtrHelper(InterpState &S, CodePtr OpPC,
14881488
const Pointer &Ptr) {
14891489
using OneT = Integral<8, false>;
14901490

1491+
const Pointer &P = Ptr.deref<Pointer>();
1492+
if (!CheckNull(S, OpPC, P, CSK_ArrayIndex))
1493+
return false;
1494+
14911495
// Get the current value on the stack.
1492-
S.Stk.push<Pointer>(Ptr.deref<Pointer>());
1496+
S.Stk.push<Pointer>(P);
14931497

14941498
// Now the current Ptr again and a constant 1.
1495-
Pointer P = Ptr.deref<Pointer>();
14961499
OneT One = OneT::from(1);
14971500
if (!OffsetHelper<OneT, Op>(S, OpPC, One, P))
14981501
return false;

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,8 +1299,9 @@ static bool checkTupleLikeDecomposition(Sema &S,
12991299
// in the associated namespaces.
13001300
Expr *Get = UnresolvedLookupExpr::Create(
13011301
S.Context, nullptr, NestedNameSpecifierLoc(), SourceLocation(),
1302-
DeclarationNameInfo(GetDN, Loc), /*RequiresADL*/true, &Args,
1303-
UnresolvedSetIterator(), UnresolvedSetIterator());
1302+
DeclarationNameInfo(GetDN, Loc), /*RequiresADL*/ true, &Args,
1303+
UnresolvedSetIterator(), UnresolvedSetIterator(),
1304+
/*KnownDependent=*/false);
13041305

13051306
Expr *Arg = E.get();
13061307
E = S.BuildCallExpr(nullptr, Get, Loc, Arg, Loc);

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,7 +2250,6 @@ struct ConvertConstructorToDeductionGuideTransform {
22502250

22512251
Sema &SemaRef;
22522252
ClassTemplateDecl *Template;
2253-
ClassTemplateDecl *NestedPattern = nullptr;
22542253

22552254
DeclContext *DC = Template->getDeclContext();
22562255
CXXRecordDecl *Primary = Template->getTemplatedDecl();
@@ -2328,8 +2327,6 @@ struct ConvertConstructorToDeductionGuideTransform {
23282327
if (FTD) {
23292328
Args.addOuterTemplateArguments(SubstArgs);
23302329
Args.addOuterRetainedLevel();
2331-
if (NestedPattern)
2332-
Args.addOuterRetainedLevels(NestedPattern->getTemplateDepth());
23332330
}
23342331

23352332
FunctionProtoTypeLoc FPTL = CD->getTypeSourceInfo()->getTypeLoc()
@@ -2441,17 +2438,10 @@ struct ConvertConstructorToDeductionGuideTransform {
24412438
SmallVector<QualType, 4> ParamTypes;
24422439
const FunctionProtoType *T = TL.getTypePtr();
24432440

2444-
MultiLevelTemplateArgumentList OuterInstantiationArgs;
2445-
if (NestedPattern)
2446-
OuterInstantiationArgs = SemaRef.getTemplateInstantiationArgs(Template);
2447-
24482441
// -- The types of the function parameters are those of the constructor.
24492442
for (auto *OldParam : TL.getParams()) {
24502443
ParmVarDecl *NewParam =
24512444
transformFunctionTypeParam(OldParam, Args, MaterializedTypedefs);
2452-
if (NestedPattern && NewParam)
2453-
NewParam = transformFunctionTypeParam(NewParam, OuterInstantiationArgs,
2454-
MaterializedTypedefs);
24552445
if (!NewParam)
24562446
return QualType();
24572447
ParamTypes.push_back(NewParam->getType());
@@ -2657,23 +2647,13 @@ void Sema::DeclareImplicitDeductionGuides(TemplateDecl *Template,
26572647
if (BuildingDeductionGuides.isInvalid())
26582648
return;
26592649

2660-
// If the template is nested, then we need to use the original
2661-
// pattern to iterate over the constructors.
2662-
ClassTemplateDecl *Pattern = Transform.Template;
2663-
while (Pattern->getInstantiatedFromMemberTemplate()) {
2664-
if (Pattern->isMemberSpecialization())
2665-
break;
2666-
Pattern = Pattern->getInstantiatedFromMemberTemplate();
2667-
Transform.NestedPattern = Pattern;
2668-
}
2669-
26702650
// Convert declared constructors into deduction guide templates.
26712651
// FIXME: Skip constructors for which deduction must necessarily fail (those
26722652
// for which some class template parameter without a default argument never
26732653
// appears in a deduced context).
26742654
llvm::SmallPtrSet<NamedDecl *, 8> ProcessedCtors;
26752655
bool AddedAny = false;
2676-
for (NamedDecl *D : LookupConstructors(Pattern->getTemplatedDecl())) {
2656+
for (NamedDecl *D : LookupConstructors(Transform.Primary)) {
26772657
D = D->getUnderlyingDecl();
26782658
if (D->isInvalidDecl() || D->isImplicit())
26792659
continue;
@@ -5002,7 +4982,7 @@ ExprResult Sema::BuildTemplateIdExpr(const CXXScopeSpec &SS,
50024982
return ExprError();
50034983
}
50044984
}
5005-
4985+
bool KnownDependent = false;
50064986
// In C++1y, check variable template ids.
50074987
if (R.getAsSingle<VarTemplateDecl>()) {
50084988
ExprResult Res = CheckVarTemplateId(SS, R.getLookupNameInfo(),
@@ -5011,6 +4991,7 @@ ExprResult Sema::BuildTemplateIdExpr(const CXXScopeSpec &SS,
50114991
if (Res.isInvalid() || Res.isUsable())
50124992
return Res;
50134993
// Result is dependent. Carry on to build an UnresolvedLookupEpxr.
4994+
KnownDependent = true;
50144995
}
50154996

50164997
if (R.getAsSingle<ConceptDecl>()) {
@@ -5022,13 +5003,10 @@ ExprResult Sema::BuildTemplateIdExpr(const CXXScopeSpec &SS,
50225003
// We don't want lookup warnings at this point.
50235004
R.suppressDiagnostics();
50245005

5025-
UnresolvedLookupExpr *ULE
5026-
= UnresolvedLookupExpr::Create(Context, R.getNamingClass(),
5027-
SS.getWithLocInContext(Context),
5028-
TemplateKWLoc,
5029-
R.getLookupNameInfo(),
5030-
RequiresADL, TemplateArgs,
5031-
R.begin(), R.end());
5006+
UnresolvedLookupExpr *ULE = UnresolvedLookupExpr::Create(
5007+
Context, R.getNamingClass(), SS.getWithLocInContext(Context),
5008+
TemplateKWLoc, R.getLookupNameInfo(), RequiresADL, TemplateArgs,
5009+
R.begin(), R.end(), KnownDependent);
50325010

50335011
return ULE;
50345012
}

clang/test/AST/Interp/arrays.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,26 @@ namespace IncDec {
333333
// expected-note {{in call to}} \
334334
// ref-error {{not an integral constant expression}} \
335335
// ref-note {{in call to}}
336+
337+
constexpr int nullptr1(bool Pre) {
338+
int *a = nullptr;
339+
if (Pre)
340+
++a; // ref-note {{arithmetic on null pointer}} \
341+
// expected-note {{arithmetic on null pointer}}
342+
else
343+
a++; // ref-note {{arithmetic on null pointer}} \
344+
// expected-note {{arithmetic on null pointer}}
345+
return 1;
346+
}
347+
static_assert(nullptr1(true) == 1, ""); // ref-error {{not an integral constant expression}} \
348+
// ref-note {{in call to}} \
349+
// expected-error {{not an integral constant expression}} \
350+
// expected-note {{in call to}}
351+
352+
static_assert(nullptr1(false) == 1, ""); // ref-error {{not an integral constant expression}} \
353+
// ref-note {{in call to}} \
354+
// expected-error {{not an integral constant expression}} \
355+
// expected-note {{in call to}}
336356
};
337357

338358
namespace ZeroInit {

clang/test/SemaTemplate/dependent-expr.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,18 @@ namespace BindingInStmtExpr {
165165
using U = decltype(num_bindings<T>()); // expected-note {{previous}}
166166
using U = N<3>; // expected-error-re {{type alias redefinition with different types ('N<3>' vs {{.*}}N<2>}}
167167
}
168+
169+
namespace PR65153 {
170+
struct A{};
171+
172+
template <const A& T>
173+
const A JoinStringViews = T;
174+
175+
template <int V>
176+
class Builder {
177+
public:
178+
static constexpr A Equal{};
179+
// no crash here
180+
static constexpr auto Val = JoinStringViews<Equal>;
181+
};
182+
} // namespace PR65153

clang/test/SemaTemplate/nested-implicit-deduction-guides.cpp

Lines changed: 0 additions & 12 deletions
This file was deleted.

compiler-rt/test/hwasan/TestCases/deep-recursion.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
// Stack histories are currently not recorded on x86.
1818
// XFAIL: target=x86_64{{.*}}
1919

20-
// Flaky on AArch64 Linux, see https://github.com/llvm/llvm-project/issues/69221.
21-
// UNSUPPORTED: target=aarch64{{.*}}
22-
2320
#include <stdlib.h>
2421
// At least -O1 is needed for this function to not have a stack frame on
2522
// AArch64.
@@ -29,7 +26,23 @@ void USE(void *x) { // pretend_to_do_something(void *x)
2926

3027
volatile int four = 4;
3128

32-
__attribute__((noinline)) void OOB() { int x[4]; x[four] = 0; USE(&x[0]); }
29+
__attribute__((noinline)) void OOB() {
30+
int x[4];
31+
int y[4];
32+
33+
// Tags for stack-allocated variables can occasionally be zero, resulting in
34+
// a false negative for this test. This is not easy to fix, hence we work
35+
// around it: if the tag is zero, we use the neighboring variable instead,
36+
// which must have a different (hence non-zero) tag.
37+
// This tag check assumes aarch64.
38+
if (((uintptr_t)&x) >> 56 == 0) {
39+
y[four] = 0;
40+
} else {
41+
x[four] = 0;
42+
}
43+
USE(&x[0]);
44+
USE(&y[0]);
45+
}
3346
__attribute__((noinline)) void FUNC1() { int x; USE(&x); OOB(); }
3447
__attribute__((noinline)) void FUNC2() { int x; USE(&x); FUNC1(); }
3548
__attribute__((noinline)) void FUNC3() { int x; USE(&x); FUNC2(); }

flang/include/flang/Runtime/descriptor.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,13 +393,18 @@ class Descriptor {
393393
bool stridesAreContiguous{true};
394394
for (int j{0}; j < leadingDimensions; ++j) {
395395
const Dimension &dim{GetDimension(j)};
396-
stridesAreContiguous &= bytes == dim.ByteStride();
396+
stridesAreContiguous &=
397+
(bytes == dim.ByteStride()) || (dim.Extent() == 1);
397398
bytes *= dim.Extent();
398399
}
399400
// One and zero element arrays are contiguous even if the descriptor
400401
// byte strides are not perfect multiples.
401-
return stridesAreContiguous || bytes == 0 ||
402-
bytes == static_cast<SubscriptValue>(ElementBytes());
402+
// Arrays with more than 2 elements may also be contiguous even if a
403+
// byte stride in one dimension is not a perfect multiple, as long as
404+
// this is the last dimension, or if the dimension has one extent and
405+
// the following dimension have either one extents or contiguous byte
406+
// strides.
407+
return stridesAreContiguous || bytes == 0;
403408
}
404409

405410
// Establishes a pointer to a section or element.

0 commit comments

Comments
 (0)