Skip to content

Commit cd778c0

Browse files
committed
merge main into amd-staging
2 parents 7224e2d + e165225 commit cd778c0

File tree

135 files changed

+4926
-3081
lines changed

Some content is hidden

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

135 files changed

+4926
-3081
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,10 @@ C23 Feature Support
255255
- Implemented `WG14 N3037 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3037.pdf>`_
256256
which allows tag types to be redefined within the same translation unit so
257257
long as both definitions are structurally equivalent (same tag types, same
258-
tag names, same tag members, etc).
258+
tag names, same tag members, etc). As a result of this paper, ``-Wvisibility``
259+
is no longer diagnosed in C23 if the parameter is a complete tag type (it
260+
does still fire when the parameter is an incomplete tag type as that cannot
261+
be completed).
259262
- Fixed a failed assertion with an invalid parameter to the ``#embed``
260263
directive. Fixes #GH126940.
261264

@@ -284,6 +287,8 @@ Non-comprehensive list of changes in this release
284287
stack space when running on Apple AArch64 based platforms. This means that
285288
stack traces of Clang from debuggers, crashes, and profilers may look
286289
different than before.
290+
- Fixed a crash when a VLA with an invalid size expression was used within a
291+
``sizeof`` or ``typeof`` expression. (#GH138444)
287292

288293
New Compiler Flags
289294
------------------
@@ -605,6 +610,9 @@ Bug Fixes to Attribute Support
605610
``__attribute__((unused))`` are still ignored after the definition, though
606611
this behavior may be relaxed in the future). (#GH135481)
607612

613+
- Clang will warn if a complete type specializes a deprecated partial specialization.
614+
(#GH44496)
615+
608616
Bug Fixes to C++ Support
609617
^^^^^^^^^^^^^^^^^^^^^^^^
610618

@@ -662,6 +670,7 @@ Bug Fixes to C++ Support
662670
(#GH136432), (#GH137014), (#GH138018)
663671
- Fixed an assertion when trying to constant-fold various builtins when the argument
664672
referred to a reference to an incomplete type. (#GH129397)
673+
- Fixed a crash when a cast involved a parenthesized aggregate initialization in dependent context. (#GH72880)
665674

666675
Bug Fixes to AST Handling
667676
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/ExprCXX.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5124,8 +5124,8 @@ class CXXParenListInitExpr final
51245124

51255125
void updateDependence() { setDependence(computeDependence(this)); }
51265126

5127-
ArrayRef<Expr *> getInitExprs() {
5128-
return ArrayRef(getTrailingObjects<Expr *>(), NumExprs);
5127+
MutableArrayRef<Expr *> getInitExprs() {
5128+
return MutableArrayRef(getTrailingObjects<Expr *>(), NumExprs);
51295129
}
51305130

51315131
const ArrayRef<Expr *> getInitExprs() const {

clang/include/clang/AST/Type.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3602,6 +3602,9 @@ class MemberPointerType : public Type, public llvm::FoldingSetNode {
36023602
}
36033603

36043604
NestedNameSpecifier *getQualifier() const { return Qualifier; }
3605+
/// Note: this can trigger extra deserialization when external AST sources are
3606+
/// used. Prefer `getCXXRecordDecl()` unless you really need the most recent
3607+
/// decl.
36053608
CXXRecordDecl *getMostRecentCXXRecordDecl() const;
36063609

36073610
bool isSugared() const;
@@ -3610,7 +3613,10 @@ class MemberPointerType : public Type, public llvm::FoldingSetNode {
36103613
}
36113614

36123615
void Profile(llvm::FoldingSetNodeID &ID) {
3613-
Profile(ID, getPointeeType(), getQualifier(), getMostRecentCXXRecordDecl());
3616+
// FIXME: `getMostRecentCXXRecordDecl()` should be possible to use here,
3617+
// however when external AST sources are used it causes nondeterminism
3618+
// issues (see https://github.com/llvm/llvm-project/pull/137910).
3619+
Profile(ID, getPointeeType(), getQualifier(), getCXXRecordDecl());
36143620
}
36153621

36163622
static void Profile(llvm::FoldingSetNodeID &ID, QualType Pointee,
@@ -3620,6 +3626,9 @@ class MemberPointerType : public Type, public llvm::FoldingSetNode {
36203626
static bool classof(const Type *T) {
36213627
return T->getTypeClass() == MemberPointer;
36223628
}
3629+
3630+
private:
3631+
CXXRecordDecl *getCXXRecordDecl() const;
36233632
};
36243633

36253634
/// Capture whether this is a normal array (e.g. int X[4])

clang/include/clang/Sema/Sema.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2388,9 +2388,14 @@ class Sema final : public SemaBase {
23882388
void DiagnoseAvailabilityOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
23892389
const ObjCInterfaceDecl *UnknownObjCClass,
23902390
bool ObjCPropertyAccess,
2391-
bool AvoidPartialAvailabilityChecks = false,
2392-
ObjCInterfaceDecl *ClassReceiver = nullptr);
2391+
bool AvoidPartialAvailabilityChecks,
2392+
ObjCInterfaceDecl *ClassReceiver);
23932393

2394+
void DiagnoseAvailabilityOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs);
2395+
2396+
std::pair<AvailabilityResult, const NamedDecl *>
2397+
ShouldDiagnoseAvailabilityOfDecl(const NamedDecl *D, std::string *Message,
2398+
ObjCInterfaceDecl *ClassReceiver);
23942399
///@}
23952400

23962401
//
@@ -7167,6 +7172,11 @@ class Sema final : public SemaBase {
71677172
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E);
71687173
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R,
71697174
MultiExprArg Val);
7175+
ExprResult ActOnCXXParenListInitExpr(ArrayRef<Expr *> Args, QualType T,
7176+
unsigned NumUserSpecifiedExprs,
7177+
SourceLocation InitLoc,
7178+
SourceLocation LParenLoc,
7179+
SourceLocation RParenLoc);
71707180

71717181
/// ActOnStringLiteral - The specified tokens were lexed as pasted string
71727182
/// fragments (e.g. "foo" "bar" L"baz"). The result string has to handle

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,12 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
834834
return false;
835835
}
836836

837+
// Bail out if the function declaration itself is invalid. We will
838+
// have produced a relevant diagnostic while parsing it, so just
839+
// note the problematic sub-expression.
840+
if (F->getDecl()->isInvalidDecl())
841+
return Invalid(S, OpPC);
842+
837843
if (S.checkingPotentialConstantExpression() && S.Current->getDepth() != 0)
838844
return false;
839845

clang/lib/AST/Type.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5305,10 +5305,14 @@ void MemberPointerType::Profile(llvm::FoldingSetNodeID &ID, QualType Pointee,
53055305
ID.AddPointer(Cls->getCanonicalDecl());
53065306
}
53075307

5308+
CXXRecordDecl *MemberPointerType::getCXXRecordDecl() const {
5309+
return dyn_cast<MemberPointerType>(getCanonicalTypeInternal())
5310+
->getQualifier()
5311+
->getAsRecordDecl();
5312+
}
5313+
53085314
CXXRecordDecl *MemberPointerType::getMostRecentCXXRecordDecl() const {
5309-
auto *RD = dyn_cast<MemberPointerType>(getCanonicalTypeInternal())
5310-
->getQualifier()
5311-
->getAsRecordDecl();
5315+
auto *RD = getCXXRecordDecl();
53125316
if (!RD)
53135317
return nullptr;
53145318
return RD->getMostRecentNonInjectedDecl();

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9522,6 +9522,11 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
95229522
CmdArgs.push_back(
95239523
Args.MakeArgString("--device-linker=" + TC->getTripleString() +
95249524
"=-plugin-opt=-avail-extern-to-local"));
9525+
if (Kind == Action::OFK_OpenMP) {
9526+
CmdArgs.push_back(
9527+
Args.MakeArgString("--device-linker=" + TC->getTripleString() +
9528+
"=-plugin-opt=-amdgpu-internalize-symbols"));
9529+
}
95259530
}
95269531
}
95279532
}

clang/lib/Sema/SemaAvailability.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,9 @@ static const AvailabilityAttr *getAttrForPlatform(ASTContext &Context,
9090
/// the availability attribute that is selected.
9191
/// \param ClassReceiver If we're checking the method of a class message
9292
/// send, the class. Otherwise nullptr.
93-
static std::pair<AvailabilityResult, const NamedDecl *>
94-
ShouldDiagnoseAvailabilityOfDecl(Sema &S, const NamedDecl *D,
95-
std::string *Message,
96-
ObjCInterfaceDecl *ClassReceiver) {
93+
std::pair<AvailabilityResult, const NamedDecl *>
94+
Sema::ShouldDiagnoseAvailabilityOfDecl(const NamedDecl *D, std::string *Message,
95+
ObjCInterfaceDecl *ClassReceiver) {
9796
AvailabilityResult Result = D->getAvailability(Message);
9897

9998
// For typedefs, if the typedef declaration appears available look
@@ -147,12 +146,12 @@ ShouldDiagnoseAvailabilityOfDecl(Sema &S, const NamedDecl *D,
147146

148147
// For +new, infer availability from -init.
149148
if (const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
150-
if (S.ObjC().NSAPIObj && ClassReceiver) {
149+
if (ObjC().NSAPIObj && ClassReceiver) {
151150
ObjCMethodDecl *Init = ClassReceiver->lookupInstanceMethod(
152-
S.ObjC().NSAPIObj->getInitSelector());
151+
ObjC().NSAPIObj->getInitSelector());
153152
if (Init && Result == AR_Available && MD->isClassMethod() &&
154-
MD->getSelector() == S.ObjC().NSAPIObj->getNewSelector() &&
155-
MD->definedInNSObject(S.getASTContext())) {
153+
MD->getSelector() == ObjC().NSAPIObj->getNewSelector() &&
154+
MD->definedInNSObject(getASTContext())) {
156155
Result = Init->getAvailability(Message);
157156
D = Init;
158157
}
@@ -162,7 +161,6 @@ ShouldDiagnoseAvailabilityOfDecl(Sema &S, const NamedDecl *D,
162161
return {Result, D};
163162
}
164163

165-
166164
/// whether we should emit a diagnostic for \c K and \c DeclVersion in
167165
/// the context of \c Ctx. For example, we should emit an unavailable diagnostic
168166
/// in a deprecated context, but not the other way around.
@@ -876,7 +874,7 @@ void DiagnoseUnguardedAvailability::DiagnoseDeclAvailability(
876874
AvailabilityResult Result;
877875
const NamedDecl *OffendingDecl;
878876
std::tie(Result, OffendingDecl) =
879-
ShouldDiagnoseAvailabilityOfDecl(SemaRef, D, nullptr, ReceiverClass);
877+
SemaRef.ShouldDiagnoseAvailabilityOfDecl(D, nullptr, ReceiverClass);
880878
if (Result != AR_Available) {
881879
// All other diagnostic kinds have already been handled in
882880
// DiagnoseAvailabilityOfDecl.
@@ -1112,12 +1110,13 @@ void Sema::DiagnoseAvailabilityOfDecl(NamedDecl *D,
11121110
bool ObjCPropertyAccess,
11131111
bool AvoidPartialAvailabilityChecks,
11141112
ObjCInterfaceDecl *ClassReceiver) {
1113+
11151114
std::string Message;
11161115
AvailabilityResult Result;
11171116
const NamedDecl* OffendingDecl;
11181117
// See if this declaration is unavailable, deprecated, or partial.
11191118
std::tie(Result, OffendingDecl) =
1120-
ShouldDiagnoseAvailabilityOfDecl(*this, D, &Message, ClassReceiver);
1119+
ShouldDiagnoseAvailabilityOfDecl(D, &Message, ClassReceiver);
11211120
if (Result == AR_Available)
11221121
return;
11231122

@@ -1146,3 +1145,11 @@ void Sema::DiagnoseAvailabilityOfDecl(NamedDecl *D,
11461145
EmitAvailabilityWarning(*this, Result, D, OffendingDecl, Message, Locs,
11471146
UnknownObjCClass, ObjCPDecl, ObjCPropertyAccess);
11481147
}
1148+
1149+
void Sema::DiagnoseAvailabilityOfDecl(NamedDecl *D,
1150+
ArrayRef<SourceLocation> Locs) {
1151+
DiagnoseAvailabilityOfDecl(D, Locs, /*UnknownObjCClass=*/nullptr,
1152+
/*ObjCPropertyAccess=*/false,
1153+
/*AvoidPartialAvailabilityChecks=*/false,
1154+
/*ClassReceiver=*/nullptr);
1155+
}

clang/lib/Sema/SemaDecl.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18348,7 +18348,10 @@ Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
1834818348

1834918349
// If we're declaring or defining a tag in function prototype scope in C,
1835018350
// note that this type can only be used within the function and add it to
18351-
// the list of decls to inject into the function definition scope.
18351+
// the list of decls to inject into the function definition scope. However,
18352+
// in C23 and later, while the type is only visible within the function, the
18353+
// function can be called with a compatible type defined in the same TU, so
18354+
// we silence the diagnostic in C23 and up. This matches the behavior of GCC.
1835218355
if ((Name || Kind == TagTypeKind::Enum) &&
1835318356
getNonFieldDeclScope(S)->isFunctionPrototypeScope()) {
1835418357
if (getLangOpts().CPlusPlus) {
@@ -18362,7 +18365,10 @@ Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
1836218365
if (TUK == TagUseKind::Declaration)
1836318366
Invalid = true;
1836418367
} else if (!PrevDecl) {
18365-
Diag(Loc, diag::warn_decl_in_param_list) << Context.getTagDeclType(New);
18368+
// In C23 mode, if the declaration is complete, we do not want to
18369+
// diagnose.
18370+
if (!getLangOpts().C23 || TUK != TagUseKind::Definition)
18371+
Diag(Loc, diag::warn_decl_in_param_list) << Context.getTagDeclType(New);
1836618372
}
1836718373
}
1836818374

clang/lib/Sema/SemaExpr.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4700,6 +4700,10 @@ ExprResult Sema::CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo,
47004700
TInfo->getType()->isVariablyModifiedType())
47014701
TInfo = TransformToPotentiallyEvaluated(TInfo);
47024702

4703+
// It's possible that the transformation above failed.
4704+
if (!TInfo)
4705+
return ExprError();
4706+
47034707
// C99 6.5.3.4p4: the type (an unsigned integer type) is size_t.
47044708
return new (Context) UnaryExprOrTypeTraitExpr(
47054709
ExprKind, TInfo, Context.getSizeType(), OpLoc, R.getEnd());
@@ -8001,6 +8005,15 @@ ExprResult Sema::ActOnParenListExpr(SourceLocation L,
80018005
return ParenListExpr::Create(Context, L, Val, R);
80028006
}
80038007

8008+
ExprResult Sema::ActOnCXXParenListInitExpr(ArrayRef<Expr *> Args, QualType T,
8009+
unsigned NumUserSpecifiedExprs,
8010+
SourceLocation InitLoc,
8011+
SourceLocation LParenLoc,
8012+
SourceLocation RParenLoc) {
8013+
return CXXParenListInitExpr::Create(Context, Args, T, NumUserSpecifiedExprs,
8014+
InitLoc, LParenLoc, RParenLoc);
8015+
}
8016+
80048017
bool Sema::DiagnoseConditionalForNull(const Expr *LHSExpr, const Expr *RHSExpr,
80058018
SourceLocation QuestionLoc) {
80068019
const Expr *NullExpr = LHSExpr;

0 commit comments

Comments
 (0)