Skip to content

Commit 5333a81

Browse files
authored
Merge branch 'main' into gpu-typos
2 parents c292a45 + b32c6d1 commit 5333a81

File tree

134 files changed

+4894
-3409
lines changed

Some content is hidden

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

134 files changed

+4894
-3409
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ Non-comprehensive list of changes in this release
287287
stack space when running on Apple AArch64 based platforms. This means that
288288
stack traces of Clang from debuggers, crashes, and profilers may look
289289
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)
290292

291293
New Compiler Flags
292294
------------------
@@ -592,6 +594,9 @@ Bug Fixes to Attribute Support
592594
``__attribute__((unused))`` are still ignored after the definition, though
593595
this behavior may be relaxed in the future). (#GH135481)
594596

597+
- Clang will warn if a complete type specializes a deprecated partial specialization.
598+
(#GH44496)
599+
595600
Bug Fixes to C++ Support
596601
^^^^^^^^^^^^^^^^^^^^^^^^
597602

@@ -649,6 +654,7 @@ Bug Fixes to C++ Support
649654
(#GH136432), (#GH137014), (#GH138018)
650655
- Fixed an assertion when trying to constant-fold various builtins when the argument
651656
referred to a reference to an incomplete type. (#GH129397)
657+
- Fixed a crash when a cast involved a parenthesized aggregate initialization in dependent context. (#GH72880)
652658

653659
Bug Fixes to AST Handling
654660
^^^^^^^^^^^^^^^^^^^^^^^^^

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/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 & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9284,12 +9284,6 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
92849284
CmdArgs.push_back(Args.MakeArgString(
92859285
"--device-linker=" + TC->getTripleString() + "=" + Arg));
92869286

9287-
// Enable internalization for AMDGPU.
9288-
if (TC->getTriple().isAMDGPU())
9289-
CmdArgs.push_back(
9290-
Args.MakeArgString("--device-linker=" + TC->getTripleString() +
9291-
"=-plugin-opt=-amdgpu-internalize-symbols"));
9292-
92939287
// Forward the LTO mode relying on the Driver's parsing.
92949288
if (C.getDriver().getOffloadLTOMode() == LTOK_Full)
92959289
CmdArgs.push_back(Args.MakeArgString(
@@ -9304,6 +9298,11 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
93049298
CmdArgs.push_back(
93059299
Args.MakeArgString("--device-linker=" + TC->getTripleString() +
93069300
"=-plugin-opt=-avail-extern-to-local"));
9301+
if (Kind == Action::OFK_OpenMP) {
9302+
CmdArgs.push_back(
9303+
Args.MakeArgString("--device-linker=" + TC->getTripleString() +
9304+
"=-plugin-opt=-amdgpu-internalize-symbols"));
9305+
}
93079306
}
93089307
}
93099308
}

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/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());
@@ -7985,6 +7989,15 @@ ExprResult Sema::ActOnParenListExpr(SourceLocation L,
79857989
return ParenListExpr::Create(Context, L, Val, R);
79867990
}
79877991

7992+
ExprResult Sema::ActOnCXXParenListInitExpr(ArrayRef<Expr *> Args, QualType T,
7993+
unsigned NumUserSpecifiedExprs,
7994+
SourceLocation InitLoc,
7995+
SourceLocation LParenLoc,
7996+
SourceLocation RParenLoc) {
7997+
return CXXParenListInitExpr::Create(Context, Args, T, NumUserSpecifiedExprs,
7998+
InitLoc, LParenLoc, RParenLoc);
7999+
}
8000+
79888001
bool Sema::DiagnoseConditionalForNull(const Expr *LHSExpr, const Expr *RHSExpr,
79898002
SourceLocation QuestionLoc) {
79908003
const Expr *NullExpr = LHSExpr;

clang/lib/Sema/SemaOpenACCClause.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,10 @@ class SemaOpenACCClauseVisitor {
403403

404404
// There are no clauses of the current kind between these device_types, so
405405
// continue.
406-
if (CurClauseKindItr == CurDevTypeItr)
406+
if (CurClauseKindItr == CurDevTypeItr) {
407+
PrevDeviceTypeItr = CurDevTypeItr;
407408
continue;
409+
}
408410

409411
// At this point, we know that this device_type region has a collapse. So
410412
// diagnose if the two device_types have any overlap in their

clang/lib/Sema/SemaTemplateInstantiate.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4094,16 +4094,32 @@ bool Sema::InstantiateClassTemplateSpecialization(
40944094
if (ClassTemplateSpec->isInvalidDecl())
40954095
return true;
40964096

4097+
bool HadAvaibilityWarning =
4098+
ShouldDiagnoseAvailabilityOfDecl(ClassTemplateSpec, nullptr, nullptr)
4099+
.first != AR_Available;
4100+
40974101
ActionResult<CXXRecordDecl *> Pattern =
40984102
getPatternForClassTemplateSpecialization(*this, PointOfInstantiation,
40994103
ClassTemplateSpec, TSK,
41004104
PrimaryStrictPackMatch);
4105+
41014106
if (!Pattern.isUsable())
41024107
return Pattern.isInvalid();
41034108

4104-
return InstantiateClass(
4109+
bool Err = InstantiateClass(
41054110
PointOfInstantiation, ClassTemplateSpec, Pattern.get(),
41064111
getTemplateInstantiationArgs(ClassTemplateSpec), TSK, Complain);
4112+
4113+
// If we haven't already warn on avaibility, consider the avaibility
4114+
// attributes of the partial specialization.
4115+
// Note that - because we need to have deduced the partial specialization -
4116+
// We can only emit these warnings when the specialization is instantiated.
4117+
if (!Err && !HadAvaibilityWarning) {
4118+
assert(ClassTemplateSpec->getTemplateSpecializationKind() !=
4119+
TSK_Undeclared);
4120+
DiagnoseAvailabilityOfDecl(ClassTemplateSpec, PointOfInstantiation);
4121+
}
4122+
return Err;
41074123
}
41084124

41094125
void

0 commit comments

Comments
 (0)