Skip to content

Commit 15f6d14

Browse files
committed
merge main into amd-staging
this brings us up to commit before offload move reverts Clang] Fix a crash introduced in PR#88666 (llvm#89567) needs to land with f4bbcac [Clang] Allow the value of unroll count to be z Change-Id: Iea8007ab25f5b48137c34f2710afaebf3e07874b
2 parents f26eb4c + b6628c2 commit 15f6d14

File tree

132 files changed

+6337
-1805
lines changed

Some content is hidden

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

132 files changed

+6337
-1805
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ C23 Feature Support
184184
- Clang now supports `N3018 The constexpr specifier for object definitions`
185185
<https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3018.htm>`_.
186186

187+
- Properly promote bit-fields of bit-precise integer types to the field's type
188+
rather than to ``int``. #GH87641
189+
187190
Non-comprehensive list of changes in this release
188191
-------------------------------------------------
189192

@@ -519,6 +522,8 @@ Bug Fixes to C++ Support
519522
- Fix an issue caused by not handling invalid cases when substituting into the parameter mapping of a constraint. Fixes (#GH86757).
520523
- Fixed a bug that prevented member function templates of class templates declared with a deduced return type
521524
from being explicitly specialized for a given implicit instantiation of the class template.
525+
- Fixed a crash when ``this`` is used in a dependent class scope function template specialization
526+
that instantiates to a static member function.
522527

523528
- Fix crash when inheriting from a cv-qualified type. Fixes #GH35603
524529
- Fix a crash when the using enum declaration uses an anonymous enumeration. Fixes (#GH86790).
@@ -531,6 +536,8 @@ Bug Fixes to C++ Support
531536
- Fix a crash caused by defined struct in a type alias template when the structure
532537
has fields with dependent type. Fixes (#GH75221).
533538
- Fix the Itanium mangling of lambdas defined in a member of a local class (#GH88906)
539+
- Fixed a crash when trying to evaluate a user-defined ``static_assert`` message whose ``size()``
540+
function returns a large or negative value. Fixes (#GH89407).
534541

535542
Bug Fixes to AST Handling
536543
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/ASTNodeTraverser.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,12 @@ class ASTNodeTraverser
851851
Visit(R);
852852
}
853853

854+
void VisitTypeTraitExpr(const TypeTraitExpr *E) {
855+
// Argument types are not children of the TypeTraitExpr.
856+
for (auto *A : E->getArgs())
857+
Visit(A->getType());
858+
}
859+
854860
void VisitLambdaExpr(const LambdaExpr *Node) {
855861
if (Traversal == TK_IgnoreUnlessSpelledInSource) {
856862
for (unsigned I = 0, N = Node->capture_size(); I != N; ++I) {

clang/include/clang/AST/ExprCXX.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3198,7 +3198,6 @@ class UnresolvedLookupExpr final
31983198
NestedNameSpecifierLoc QualifierLoc,
31993199
SourceLocation TemplateKWLoc,
32003200
const DeclarationNameInfo &NameInfo, bool RequiresADL,
3201-
bool Overloaded,
32023201
const TemplateArgumentListInfo *TemplateArgs,
32033202
UnresolvedSetIterator Begin, UnresolvedSetIterator End,
32043203
bool KnownDependent);
@@ -3218,8 +3217,9 @@ class UnresolvedLookupExpr final
32183217
static UnresolvedLookupExpr *
32193218
Create(const ASTContext &Context, CXXRecordDecl *NamingClass,
32203219
NestedNameSpecifierLoc QualifierLoc,
3221-
const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded,
3222-
UnresolvedSetIterator Begin, UnresolvedSetIterator End);
3220+
const DeclarationNameInfo &NameInfo, bool RequiresADL,
3221+
UnresolvedSetIterator Begin, UnresolvedSetIterator End,
3222+
bool KnownDependent);
32233223

32243224
// After canonicalization, there may be dependent template arguments in
32253225
// CanonicalConverted But none of Args is dependent. When any of
@@ -3240,9 +3240,6 @@ class UnresolvedLookupExpr final
32403240
/// argument-dependent lookup.
32413241
bool requiresADL() const { return UnresolvedLookupExprBits.RequiresADL; }
32423242

3243-
/// True if this lookup is overloaded.
3244-
bool isOverloaded() const { return UnresolvedLookupExprBits.Overloaded; }
3245-
32463243
/// Gets the 'naming class' (in the sense of C++0x
32473244
/// [class.access.base]p5) of the lookup. This is the scope
32483245
/// that was looked in to find these results.

clang/include/clang/AST/OpenACCClause.h

Lines changed: 71 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -156,33 +156,88 @@ class OpenACCSelfClause : public OpenACCClauseWithCondition {
156156
Expr *ConditionExpr, SourceLocation EndLoc);
157157
};
158158

159-
/// Represents oen of a handful of classes that have a single integer
159+
/// Represents a clause that has one or more IntExprs. It does not own the
160+
/// IntExprs, but provides 'children' and other accessors.
161+
class OpenACCClauseWithIntExprs : public OpenACCClauseWithParams {
162+
MutableArrayRef<Expr *> IntExprs;
163+
164+
protected:
165+
OpenACCClauseWithIntExprs(OpenACCClauseKind K, SourceLocation BeginLoc,
166+
SourceLocation LParenLoc, SourceLocation EndLoc)
167+
: OpenACCClauseWithParams(K, BeginLoc, LParenLoc, EndLoc) {}
168+
169+
/// Used only for initialization, the leaf class can initialize this to
170+
/// trailing storage.
171+
void setIntExprs(MutableArrayRef<Expr *> NewIntExprs) {
172+
assert(IntExprs.empty() && "Cannot change IntExprs list");
173+
IntExprs = NewIntExprs;
174+
}
175+
176+
/// Gets the entire list of integer expressions, but leave it to the
177+
/// individual clauses to expose this how they'd like.
178+
llvm::ArrayRef<Expr *> getIntExprs() const { return IntExprs; }
179+
180+
public:
181+
child_range children() {
182+
return child_range(reinterpret_cast<Stmt **>(IntExprs.begin()),
183+
reinterpret_cast<Stmt **>(IntExprs.end()));
184+
}
185+
186+
const_child_range children() const {
187+
child_range Children =
188+
const_cast<OpenACCClauseWithIntExprs *>(this)->children();
189+
return const_child_range(Children.begin(), Children.end());
190+
}
191+
};
192+
193+
class OpenACCNumGangsClause final
194+
: public OpenACCClauseWithIntExprs,
195+
public llvm::TrailingObjects<OpenACCNumGangsClause, Expr *> {
196+
197+
OpenACCNumGangsClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
198+
ArrayRef<Expr *> IntExprs, SourceLocation EndLoc)
199+
: OpenACCClauseWithIntExprs(OpenACCClauseKind::NumGangs, BeginLoc,
200+
LParenLoc, EndLoc) {
201+
std::uninitialized_copy(IntExprs.begin(), IntExprs.end(),
202+
getTrailingObjects<Expr *>());
203+
setIntExprs(MutableArrayRef(getTrailingObjects<Expr *>(), IntExprs.size()));
204+
}
205+
206+
public:
207+
static OpenACCNumGangsClause *
208+
Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
209+
ArrayRef<Expr *> IntExprs, SourceLocation EndLoc);
210+
211+
llvm::ArrayRef<Expr *> getIntExprs() {
212+
return OpenACCClauseWithIntExprs::getIntExprs();
213+
}
214+
215+
llvm::ArrayRef<Expr *> getIntExprs() const {
216+
return OpenACCClauseWithIntExprs::getIntExprs();
217+
}
218+
};
219+
220+
/// Represents one of a handful of clauses that have a single integer
160221
/// expression.
161-
class OpenACCClauseWithSingleIntExpr : public OpenACCClauseWithParams {
222+
class OpenACCClauseWithSingleIntExpr : public OpenACCClauseWithIntExprs {
162223
Expr *IntExpr;
163224

164225
protected:
165226
OpenACCClauseWithSingleIntExpr(OpenACCClauseKind K, SourceLocation BeginLoc,
166227
SourceLocation LParenLoc, Expr *IntExpr,
167228
SourceLocation EndLoc)
168-
: OpenACCClauseWithParams(K, BeginLoc, LParenLoc, EndLoc),
169-
IntExpr(IntExpr) {}
229+
: OpenACCClauseWithIntExprs(K, BeginLoc, LParenLoc, EndLoc),
230+
IntExpr(IntExpr) {
231+
setIntExprs(MutableArrayRef<Expr *>{&this->IntExpr, 1});
232+
}
170233

171234
public:
172-
bool hasIntExpr() const { return IntExpr; }
173-
const Expr *getIntExpr() const { return IntExpr; }
174-
175-
Expr *getIntExpr() { return IntExpr; };
176-
177-
child_range children() {
178-
return child_range(reinterpret_cast<Stmt **>(&IntExpr),
179-
reinterpret_cast<Stmt **>(&IntExpr + 1));
235+
bool hasIntExpr() const { return !getIntExprs().empty(); }
236+
const Expr *getIntExpr() const {
237+
return hasIntExpr() ? getIntExprs()[0] : nullptr;
180238
}
181239

182-
const_child_range children() const {
183-
return const_child_range(reinterpret_cast<Stmt *const *>(&IntExpr),
184-
reinterpret_cast<Stmt *const *>(&IntExpr + 1));
185-
}
240+
Expr *getIntExpr() { return hasIntExpr() ? getIntExprs()[0] : nullptr; };
186241
};
187242

188243
class OpenACCNumWorkersClause : public OpenACCClauseWithSingleIntExpr {

clang/include/clang/AST/Stmt.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,11 +1067,6 @@ class alignas(void *) Stmt {
10671067
/// argument-dependent lookup if this is the operand of a function call.
10681068
LLVM_PREFERRED_TYPE(bool)
10691069
unsigned RequiresADL : 1;
1070-
1071-
/// True if these lookup results are overloaded. This is pretty trivially
1072-
/// rederivable if we urgently need to kill this field.
1073-
LLVM_PREFERRED_TYPE(bool)
1074-
unsigned Overloaded : 1;
10751070
};
10761071
static_assert(sizeof(UnresolvedLookupExprBitfields) <= 4,
10771072
"UnresolvedLookupExprBitfields must be <= than 4 bytes to"

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ def err_expr_not_cce : Error<
8787
"call to 'size()'|call to 'data()'}0 is not a constant expression">;
8888
def ext_cce_narrowing : ExtWarn<
8989
"%select{case value|enumerator value|non-type template argument|"
90-
"array size|explicit specifier argument|noexcept specifier argument}0 "
91-
"%select{cannot be narrowed from type %2 to %3|"
92-
"evaluates to %2, which cannot be narrowed to type %3}1">,
90+
"array size|explicit specifier argument|noexcept specifier argument|"
91+
"call to 'size()'|call to 'data()'}0 %select{cannot be narrowed from "
92+
"type %2 to %3|evaluates to %2, which cannot be narrowed to type %3}1">,
9393
InGroup<CXX11Narrowing>, DefaultError, SFINAEFailure;
9494
def err_ice_not_integral : Error<
9595
"%select{integer|integral}1 constant expression must have "
@@ -12291,4 +12291,9 @@ def note_acc_int_expr_conversion
1229112291
: Note<"conversion to %select{integral|enumeration}0 type %1">;
1229212292
def err_acc_int_expr_multiple_conversions
1229312293
: Error<"multiple conversions from expression type %0 to an integral type">;
12294+
def err_acc_num_gangs_num_args
12295+
: Error<"%select{no|too many}0 integer expression arguments provided to "
12296+
"OpenACC 'num_gangs' "
12297+
"%select{|clause: '%1' directive expects maximum of %2, %3 were "
12298+
"provided}0">;
1229412299
} // end of sema component.

clang/include/clang/Basic/OpenACCClauses.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
VISIT_CLAUSE(Default)
1919
VISIT_CLAUSE(If)
2020
VISIT_CLAUSE(Self)
21+
VISIT_CLAUSE(NumGangs)
2122
VISIT_CLAUSE(NumWorkers)
2223
VISIT_CLAUSE(VectorLength)
2324

clang/include/clang/Parse/Parser.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3644,10 +3644,22 @@ class Parser : public CodeCompletionHandler {
36443644
/// Parses the clause of the 'bind' argument, which can be a string literal or
36453645
/// an ID expression.
36463646
ExprResult ParseOpenACCBindClauseArgument();
3647+
3648+
/// A type to represent the state of parsing after an attempt to parse an
3649+
/// OpenACC int-expr. This is useful to determine whether an int-expr list can
3650+
/// continue parsing after a failed int-expr.
3651+
using OpenACCIntExprParseResult =
3652+
std::pair<ExprResult, OpenACCParseCanContinue>;
36473653
/// Parses the clause kind of 'int-expr', which can be any integral
36483654
/// expression.
3649-
ExprResult ParseOpenACCIntExpr(OpenACCDirectiveKind DK, OpenACCClauseKind CK,
3650-
SourceLocation Loc);
3655+
OpenACCIntExprParseResult ParseOpenACCIntExpr(OpenACCDirectiveKind DK,
3656+
OpenACCClauseKind CK,
3657+
SourceLocation Loc);
3658+
/// Parses the argument list for 'num_gangs', which allows up to 3
3659+
/// 'int-expr's.
3660+
bool ParseOpenACCIntExprList(OpenACCDirectiveKind DK, OpenACCClauseKind CK,
3661+
SourceLocation Loc,
3662+
llvm::SmallVectorImpl<Expr *> &IntExprs);
36513663
/// Parses the 'device-type-list', which is a list of identifiers.
36523664
bool ParseOpenACCDeviceTypeList();
36533665
/// Parses the 'async-argument', which is an integral value with two

clang/include/clang/Sema/Sema.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6531,7 +6531,10 @@ class Sema final : public SemaBase {
65316531
SourceLocation RParenLoc);
65326532

65336533
//// ActOnCXXThis - Parse 'this' pointer.
6534-
ExprResult ActOnCXXThis(SourceLocation loc);
6534+
ExprResult ActOnCXXThis(SourceLocation Loc);
6535+
6536+
/// Check whether the type of 'this' is valid in the current context.
6537+
bool CheckCXXThisType(SourceLocation Loc, QualType Type);
65356538

65366539
/// Build a CXXThisExpr and mark it referenced in the current context.
65376540
Expr *BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit);
@@ -6953,10 +6956,14 @@ class Sema final : public SemaBase {
69536956
///@{
69546957

69556958
public:
6959+
/// Check whether an expression might be an implicit class member access.
6960+
bool isPotentialImplicitMemberAccess(const CXXScopeSpec &SS, LookupResult &R,
6961+
bool IsAddressOfOperand);
6962+
69566963
ExprResult BuildPossibleImplicitMemberExpr(
69576964
const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R,
6958-
const TemplateArgumentListInfo *TemplateArgs, const Scope *S,
6959-
UnresolvedLookupExpr *AsULE = nullptr);
6965+
const TemplateArgumentListInfo *TemplateArgs, const Scope *S);
6966+
69606967
ExprResult
69616968
BuildImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
69626969
LookupResult &R,

clang/include/clang/Sema/SemaOpenACC.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,16 @@ class SemaOpenACC : public SemaBase {
9393
}
9494

9595
unsigned getNumIntExprs() const {
96-
assert((ClauseKind == OpenACCClauseKind::NumWorkers ||
96+
assert((ClauseKind == OpenACCClauseKind::NumGangs ||
97+
ClauseKind == OpenACCClauseKind::NumWorkers ||
9798
ClauseKind == OpenACCClauseKind::VectorLength) &&
9899
"Parsed clause kind does not have a int exprs");
99100
return std::get<IntExprDetails>(Details).IntExprs.size();
100101
}
101102

102103
ArrayRef<Expr *> getIntExprs() {
103-
assert((ClauseKind == OpenACCClauseKind::NumWorkers ||
104+
assert((ClauseKind == OpenACCClauseKind::NumGangs ||
105+
ClauseKind == OpenACCClauseKind::NumWorkers ||
104106
ClauseKind == OpenACCClauseKind::VectorLength) &&
105107
"Parsed clause kind does not have a int exprs");
106108
return std::get<IntExprDetails>(Details).IntExprs;
@@ -134,11 +136,19 @@ class SemaOpenACC : public SemaBase {
134136
}
135137

136138
void setIntExprDetails(ArrayRef<Expr *> IntExprs) {
137-
assert((ClauseKind == OpenACCClauseKind::NumWorkers ||
139+
assert((ClauseKind == OpenACCClauseKind::NumGangs ||
140+
ClauseKind == OpenACCClauseKind::NumWorkers ||
138141
ClauseKind == OpenACCClauseKind::VectorLength) &&
139142
"Parsed clause kind does not have a int exprs");
140143
Details = IntExprDetails{{IntExprs.begin(), IntExprs.end()}};
141144
}
145+
void setIntExprDetails(llvm::SmallVector<Expr *> &&IntExprs) {
146+
assert((ClauseKind == OpenACCClauseKind::NumGangs ||
147+
ClauseKind == OpenACCClauseKind::NumWorkers ||
148+
ClauseKind == OpenACCClauseKind::VectorLength) &&
149+
"Parsed clause kind does not have a int exprs");
150+
Details = IntExprDetails{IntExprs};
151+
}
142152
};
143153

144154
SemaOpenACC(Sema &S);

clang/lib/AST/ASTContext.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7242,6 +7242,14 @@ QualType ASTContext::isPromotableBitField(Expr *E) const {
72427242
// We perform that promotion here to match GCC and C++.
72437243
// FIXME: C does not permit promotion of an enum bit-field whose rank is
72447244
// greater than that of 'int'. We perform that promotion to match GCC.
7245+
//
7246+
// C23 6.3.1.1p2:
7247+
// The value from a bit-field of a bit-precise integer type is converted to
7248+
// the corresponding bit-precise integer type. (The rest is the same as in
7249+
// C11.)
7250+
if (QualType QT = Field->getType(); QT->isBitIntType())
7251+
return QT;
7252+
72457253
if (BitWidth < IntSize)
72467254
return IntTy;
72477255

clang/lib/AST/ASTImporter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8574,8 +8574,8 @@ ASTNodeImporter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
85748574

85758575
return UnresolvedLookupExpr::Create(
85768576
Importer.getToContext(), *ToNamingClassOrErr, *ToQualifierLocOrErr,
8577-
ToNameInfo, E->requiresADL(), E->isOverloaded(), ToDecls.begin(),
8578-
ToDecls.end());
8577+
ToNameInfo, E->requiresADL(), ToDecls.begin(), ToDecls.end(),
8578+
/*KnownDependent=*/E->isTypeDependent());
85798579
}
85808580

85818581
ExpectedStmt

0 commit comments

Comments
 (0)