Skip to content

Commit e4eee7f

Browse files
committed
Merged main:41cf94e6b8b4 into amd-gfx:816ba771739c
Local branch amd-gfx 816ba77 Merged main:09f1aaca0bdc into amd-gfx:1e7085b95985 Remote branch main 41cf94e [AMDGPU] - Add s_quadmask intrinsics
2 parents 816ba77 + 41cf94e commit e4eee7f

File tree

475 files changed

+16321
-14489
lines changed

Some content is hidden

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

475 files changed

+16321
-14489
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -665,11 +665,6 @@ Bug Fixes to C++ Support
665665
declaration definition. Fixes:
666666
(`#61763 <https://github.com/llvm/llvm-project/issues/61763>`_)
667667

668-
- Fix a bug where implicit deduction guides are not correctly generated for nested template
669-
classes. Fixes:
670-
(`#46200 <https://github.com/llvm/llvm-project/issues/46200>`_)
671-
(`#57812 <https://github.com/llvm/llvm-project/issues/57812>`_)
672-
673668
- Diagnose use of a variable-length array in a coroutine. The design of
674669
coroutines is such that it is not possible to support VLA use. Fixes:
675670
(`#65858 <https://github.com/llvm/llvm-project/issues/65858>`_)

clang/include/clang/Basic/DiagnosticLexKinds.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,11 @@ def err_header_import_semi_in_macro : Error<
922922
def err_header_import_not_header_unit : Error<
923923
"header file %0 (aka '%1') cannot be imported because "
924924
"it is not known to be a header unit">;
925+
def warn_pp_include_angled_in_module_purview : Warning<
926+
"'#include <filename>' attaches the declarations to the named module '%0'"
927+
", which is not usually intended; consider moving that directive before "
928+
"the module declaration">,
929+
InGroup<DiagGroup<"include-angled-in-module-purview">>;
925930

926931
def warn_header_guard : Warning<
927932
"%0 is used as a header guard here, followed by #define of a different macro">,

clang/lib/Lex/PPDirectives.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2537,6 +2537,10 @@ Preprocessor::ImportAction Preprocessor::HandleHeaderIncludeOrImport(
25372537
return {ImportAction::None};
25382538
}
25392539

2540+
if (isAngled && isInNamedModule())
2541+
Diag(FilenameTok, diag::warn_pp_include_angled_in_module_purview)
2542+
<< getNamedModuleName();
2543+
25402544
// Look up the file, create a File ID for it.
25412545
SourceLocation IncludePos = FilenameTok.getLocation();
25422546
// If the filename string was the result of macro expansions, set the include

clang/lib/Sema/SemaCoroutine.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,9 +1965,15 @@ bool Sema::buildCoroutineParameterMoves(SourceLocation Loc) {
19651965
if (PD->getType()->isDependentType())
19661966
continue;
19671967

1968+
// Preserve the referenced state for unused parameter diagnostics.
1969+
bool DeclReferenced = PD->isReferenced();
1970+
19681971
ExprResult PDRefExpr =
19691972
BuildDeclRefExpr(PD, PD->getType().getNonReferenceType(),
19701973
ExprValueKind::VK_LValue, Loc); // FIXME: scope?
1974+
1975+
PD->setReferenced(DeclReferenced);
1976+
19711977
if (PDRefExpr.isInvalid())
19721978
return false;
19731979

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2253,7 +2253,6 @@ struct ConvertConstructorToDeductionGuideTransform {
22532253

22542254
Sema &SemaRef;
22552255
ClassTemplateDecl *Template;
2256-
ClassTemplateDecl *NestedPattern = nullptr;
22572256

22582257
DeclContext *DC = Template->getDeclContext();
22592258
CXXRecordDecl *Primary = Template->getTemplatedDecl();
@@ -2333,9 +2332,6 @@ struct ConvertConstructorToDeductionGuideTransform {
23332332
Args.addOuterRetainedLevel();
23342333
}
23352334

2336-
if (NestedPattern)
2337-
Args.addOuterRetainedLevels(NestedPattern->getTemplateDepth());
2338-
23392335
FunctionProtoTypeLoc FPTL = CD->getTypeSourceInfo()->getTypeLoc()
23402336
.getAsAdjusted<FunctionProtoTypeLoc>();
23412337
assert(FPTL && "no prototype for constructor declaration");
@@ -2445,17 +2441,10 @@ struct ConvertConstructorToDeductionGuideTransform {
24452441
SmallVector<QualType, 4> ParamTypes;
24462442
const FunctionProtoType *T = TL.getTypePtr();
24472443

2448-
MultiLevelTemplateArgumentList OuterInstantiationArgs;
2449-
if (NestedPattern)
2450-
OuterInstantiationArgs = SemaRef.getTemplateInstantiationArgs(Template);
2451-
24522444
// -- The types of the function parameters are those of the constructor.
24532445
for (auto *OldParam : TL.getParams()) {
24542446
ParmVarDecl *NewParam =
24552447
transformFunctionTypeParam(OldParam, Args, MaterializedTypedefs);
2456-
if (NestedPattern && NewParam)
2457-
NewParam = transformFunctionTypeParam(NewParam, OuterInstantiationArgs,
2458-
MaterializedTypedefs);
24592448
if (!NewParam)
24602449
return QualType();
24612450
ParamTypes.push_back(NewParam->getType());
@@ -2661,24 +2650,13 @@ void Sema::DeclareImplicitDeductionGuides(TemplateDecl *Template,
26612650
if (BuildingDeductionGuides.isInvalid())
26622651
return;
26632652

2664-
// If the template is nested, then we need to use the original
2665-
// pattern to iterate over the constructors.
2666-
ClassTemplateDecl *Pattern = Transform.Template;
2667-
while (Pattern->getInstantiatedFromMemberTemplate()) {
2668-
if (Pattern->isMemberSpecialization())
2669-
break;
2670-
Pattern = Pattern->getInstantiatedFromMemberTemplate();
2671-
Transform.NestedPattern = Pattern;
2672-
}
2673-
26742653
// Convert declared constructors into deduction guide templates.
26752654
// FIXME: Skip constructors for which deduction must necessarily fail (those
26762655
// for which some class template parameter without a default argument never
26772656
// appears in a deduced context).
2678-
ContextRAII SavedContext(*this, Pattern->getTemplatedDecl());
26792657
llvm::SmallPtrSet<NamedDecl *, 8> ProcessedCtors;
26802658
bool AddedAny = false;
2681-
for (NamedDecl *D : LookupConstructors(Pattern->getTemplatedDecl())) {
2659+
for (NamedDecl *D : LookupConstructors(Transform.Primary)) {
26822660
D = D->getUnderlyingDecl();
26832661
if (D->isInvalidDecl() || D->isImplicit())
26842662
continue;
@@ -2724,8 +2702,6 @@ void Sema::DeclareImplicitDeductionGuides(TemplateDecl *Template,
27242702
Transform.buildSimpleDeductionGuide(Transform.DeducedType))
27252703
->getTemplatedDecl())
27262704
->setDeductionCandidateKind(DeductionCandidate::Copy);
2727-
2728-
SavedContext.pop();
27292705
}
27302706

27312707
/// Diagnose the presence of a default template argument on a

clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ class StreamChecker : public Checker<check::PreCall, eval::Call,
238238

239239
private:
240240
CallDescriptionMap<FnDescription> FnDescriptions = {
241-
{{{"fopen"}}, {nullptr, &StreamChecker::evalFopen, ArgNone}},
241+
{{{"fopen"}, 2}, {nullptr, &StreamChecker::evalFopen, ArgNone}},
242242
{{{"freopen"}, 3},
243243
{&StreamChecker::preFreopen, &StreamChecker::evalFreopen, 2}},
244-
{{{"tmpfile"}}, {nullptr, &StreamChecker::evalFopen, ArgNone}},
244+
{{{"tmpfile"}, 0}, {nullptr, &StreamChecker::evalFopen, ArgNone}},
245245
{{{"fclose"}, 1},
246246
{&StreamChecker::preDefault, &StreamChecker::evalFclose, 0}},
247247
{{{"fread"}, 4},
@@ -1037,7 +1037,7 @@ StreamChecker::ensureStreamNonNull(SVal StreamVal, const Expr *StreamE,
10371037
ConstraintManager &CM = C.getConstraintManager();
10381038

10391039
ProgramStateRef StateNotNull, StateNull;
1040-
std::tie(StateNotNull, StateNull) = CM.assumeDual(C.getState(), *Stream);
1040+
std::tie(StateNotNull, StateNull) = CM.assumeDual(State, *Stream);
10411041

10421042
if (!StateNotNull && StateNull) {
10431043
if (ExplodedNode *N = C.generateErrorNode(StateNull)) {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %clang_analyze_cc1 -fno-builtin -analyzer-checker=core,alpha.unix.Stream -verify %s
2+
// expected-no-diagnostics
3+
4+
typedef struct _FILE FILE;
5+
6+
// These functions are not standard C library functions.
7+
FILE *tmpfile(const char *restrict path); // Real 'tmpfile' should have exactly 0 formal parameters.
8+
FILE *fopen(const char *restrict path); // Real 'fopen' should have exactly 2 formal parameters.
9+
10+
void test_fopen_non_posix(void) {
11+
FILE *fp = fopen("file"); // no-leak: This isn't the standard POSIX `fopen`, we don't know the semantics of this call.
12+
}
13+
14+
void test_tmpfile_non_posix(void) {
15+
FILE *fp = tmpfile("file"); // // no-leak: This isn't the standard POSIX `tmpfile`, we don't know the semantics of this call.
16+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %clang_cc1 -triple loongarch64 -target-feature +f -target-feature +d -target-abi lp64d -emit-llvm %s -o - | \
2+
// RUN: FileCheck --check-prefix=CHECK-C %s
3+
// RUN: %clang_cc1 -triple loongarch64 -target-feature +f -target-feature +d -target-abi lp64d -emit-llvm %s -o - -x c++ | \
4+
// RUN: FileCheck --check-prefix=CHECK-CXX %s
5+
6+
#include <stdint.h>
7+
8+
// CHECK-C: define{{.*}} void @test1()
9+
// CHECK-CXX: define{{.*}} i64 @_Z5test12u1(i64{{[^,]*}})
10+
union u1 { };
11+
union u1 test1(union u1 a) {
12+
return a;
13+
}
14+
15+
struct s1 {
16+
union u1 u;
17+
int i;
18+
float f;
19+
};
20+
21+
// CHECK-C: define{{.*}} { i32, float } @test2(i32{{[^,]*}}, float{{[^,]*}})
22+
/// FIXME: This doesn't match g++.
23+
// CHECK-CXX: define{{.*}} { i32, float } @_Z5test22s1(i32{{[^,]*}}, float{{[^,]*}})
24+
struct s1 test2(struct s1 a) {
25+
return a;
26+
}

clang/test/CodeGen/arm64_32-vaarg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ long long test_longlong(OneLongLong input, va_list *mylist) {
2929
// CHECK-LABEL: define{{.*}} i64 @test_longlong(i64 %input
3030
// CHECK: [[STARTPTR:%.*]] = load ptr, ptr %mylist
3131
// CHECK: [[ALIGN_TMP:%.+]] = getelementptr inbounds i8, ptr [[STARTPTR]], i32 7
32-
// CHECK: [[ALIGNED_ADDR:%.+]] = tail call ptr @llvm.ptrmask.p0.i32(ptr nonnull [[ALIGN_TMP]], i32 -8)
32+
// CHECK: [[ALIGNED_ADDR:%.+]] = tail call align 8 ptr @llvm.ptrmask.p0.i32(ptr nonnull [[ALIGN_TMP]], i32 -8)
3333
// CHECK: [[NEXT:%.*]] = getelementptr inbounds i8, ptr [[ALIGNED_ADDR]], i32 8
3434
// CHECK: store ptr [[NEXT]], ptr %mylist
3535

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// RUN: rm -rf %t
2+
// RUN: mkdir %t
3+
// RUN: split-file %s %t
4+
//
5+
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -E -P -I%t -o %t/tmp 2>&1 | FileCheck %t/a.cppm
6+
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -E -P -I%t -o - 2>&1 \
7+
// RUN: -Wno-include-angled-in-module-purview | FileCheck %t/a.cppm --check-prefix=CHECK-NO-WARN
8+
9+
//--- a.h
10+
// left empty
11+
12+
//--- b.h
13+
#include <stddef.h>
14+
// The headers not get included shouldn't be affected.
15+
#ifdef WHATEVER
16+
#include <stdint.h>
17+
#endif
18+
19+
//--- a.cppm
20+
module;
21+
#include <stddef.h>
22+
#include <a.h>
23+
#include <b.h>
24+
#include "a.h"
25+
#include "b.h"
26+
export module a;
27+
28+
#include <stddef.h>
29+
#include <a.h>
30+
#include <b.h>
31+
#include "a.h"
32+
#include "b.h"
33+
34+
// CHECK: a.cppm:9:10: warning: '#include <filename>' attaches the declarations to the named module 'a'
35+
// CHECK: a.cppm:10:10: warning: '#include <filename>' attaches the declarations to the named module 'a'
36+
// CHECK: a.cppm:11:10: warning: '#include <filename>' attaches the declarations to the named module 'a'
37+
// CHECK: In file included from {{.*}}/a.cppm:11
38+
// CHECK-NEXT: b.h:1:10: warning: '#include <filename>' attaches the declarations to the named module 'a'
39+
// CHECK: In file included from {{.*}}/a.cppm:13
40+
// CHECK-NEXT: b.h:1:10: warning: '#include <filename>' attaches the declarations to the named module 'a'
41+
42+
module :private;
43+
#include <stddef.h>
44+
#include <a.h>
45+
#include <b.h>
46+
#include "a.h"
47+
#include "b.h"
48+
49+
// CHECK: a.cppm:24:10: warning: '#include <filename>' attaches the declarations to the named module 'a'
50+
// CHECK: a.cppm:25:10: warning: '#include <filename>' attaches the declarations to the named module 'a'
51+
// CHECK: a.cppm:26:10: warning: '#include <filename>' attaches the declarations to the named module 'a'
52+
// CHECK: In file included from {{.*}}/a.cppm:26
53+
// CHECK-NEXT: b.h:1:10: warning: '#include <filename>' attaches the declarations to the named module 'a'
54+
// CHECK: In file included from {{.*}}/a.cppm:28
55+
// CHECK-NEXT: b.h:1:10: warning: '#include <filename>' attaches the declarations to the named module 'a'
56+
57+
// We should have catched all warnings.
58+
// CHECK: 10 warnings generated.
59+
60+
// CHECK-NO-WARN-NOT: warning
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// RUN: %clang_cc1 -fsyntax-only -Wunused-parameter -verify -std=c++20 %s
2+
3+
#include "Inputs/std-coroutine.h"
4+
5+
struct awaitable {
6+
bool await_ready() noexcept;
7+
void await_resume() noexcept;
8+
void await_suspend(std::coroutine_handle<>) noexcept;
9+
};
10+
11+
struct task : awaitable {
12+
struct promise_type {
13+
task get_return_object() noexcept;
14+
awaitable initial_suspend() noexcept;
15+
awaitable final_suspend() noexcept;
16+
void unhandled_exception() noexcept;
17+
void return_void() noexcept;
18+
};
19+
};
20+
21+
task foo(int a) { // expected-warning{{unused parameter 'a'}}
22+
co_return;
23+
}
24+
25+
task bar(int a, int b) { // expected-warning{{unused parameter 'b'}}
26+
a = a + 1;
27+
co_return;
28+
}
29+
30+
void create_closure() {
31+
auto closure = [](int c) -> task { // expected-warning{{unused parameter 'c'}}
32+
co_return;
33+
};
34+
}

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,10 @@
44
template<typename T> struct A {
55
template<typename U> struct B {
66
B(...);
7-
B(const B &) = default;
87
};
98
template<typename U> B(U) -> B<U>;
109
};
1110
A<void>::B b = 123;
12-
A<void>::B copy = b;
1311

1412
using T = decltype(b);
1513
using T = A<void>::B<int>;
16-
17-
using Copy = decltype(copy);
18-
using Copy = A<void>::B<int>;

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

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

clang/unittests/Serialization/SourceLocationEncodingTest.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ void roundTrip(SourceLocation::UIntTy Loc,
2525
std::optional<uint64_t> ExpectedEncoded = std::nullopt) {
2626
uint64_t ActualEncoded =
2727
SourceLocationEncoding::encode(SourceLocation::getFromRawEncoding(Loc));
28-
if (ExpectedEncoded)
28+
if (ExpectedEncoded) {
2929
ASSERT_EQ(ActualEncoded, *ExpectedEncoded) << "Encoding " << Loc;
30+
}
3031
SourceLocation::UIntTy DecodedEncoded =
3132
SourceLocationEncoding::decode(ActualEncoded).getRawEncoding();
3233
ASSERT_EQ(DecodedEncoded, Loc) << "Decoding " << ActualEncoded;
@@ -41,9 +42,10 @@ void roundTrip(std::vector<SourceLocation::UIntTy> Locs,
4142
for (auto L : Locs)
4243
ActualEncoded.push_back(SourceLocationEncoding::encode(
4344
SourceLocation::getFromRawEncoding(L), Seq));
44-
if (!ExpectedEncoded.empty())
45+
if (!ExpectedEncoded.empty()) {
4546
ASSERT_EQ(ActualEncoded, ExpectedEncoded)
4647
<< "Encoding " << testing::PrintToString(Locs);
48+
}
4749
}
4850
std::vector<SourceLocation::UIntTy> DecodedEncoded;
4951
{
@@ -70,7 +72,7 @@ TEST(SourceLocationEncoding, Individual) {
7072
roundTrip(Big);
7173
roundTrip(Big + 1);
7274
roundTrip(MacroBit | Big);
73-
roundTrip(MacroBit | Big + 1);
75+
roundTrip(MacroBit | (Big + 1));
7476
}
7577

7678
TEST(SourceLocationEncoding, Sequence) {

compiler-rt/include/sanitizer/common_interface_defs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ void SANITIZER_CDECL __sanitizer_symbolize_global(void *data_ptr,
298298
#define __sanitizer_return_address() \
299299
__builtin_extract_return_addr(__builtin_return_address(0))
300300
#else
301-
extern "C" void *SANITIZER_CDECL _ReturnAddress(void);
301+
void *SANITIZER_CDECL _ReturnAddress(void);
302302
#pragma intrinsic(_ReturnAddress)
303303
#define __sanitizer_return_address() _ReturnAddress()
304304
#endif

0 commit comments

Comments
 (0)