Skip to content

Commit c1c0371

Browse files
committed
merge main into amd-staging
- Revert 8009bbe - Revert "Reapply "[Clang][Sema] Diagnose class member access expressions naming non-existent members of the current instantiation prior to instantiation in the absence of dependent base classes (llvm#84050)" (llvm#90152)" - Breaks composable kernels and rocthrust builds - Revert 41f9c78 - Revert "[OpenACC] Fix test failure from fa67986" - Fixes some issues in 8009bbe, so depends on it - Cherry-pick 803e03f from trunk - Fixes unit test failures introduced in trunk earlier Change-Id: I718574c8a26745a52845d0b5a914ed00db611956
2 parents 1a62373 + f898161 commit c1c0371

File tree

229 files changed

+177570
-82197
lines changed

Some content is hidden

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

229 files changed

+177570
-82197
lines changed

bolt/lib/Rewrite/LinuxKernelRewriter.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ class LinuxKernelRewriter final : public MetadataRewriter {
248248
/// Update ORC data in the binary.
249249
Error rewriteORCTables();
250250

251+
/// Validate written ORC tables after binary emission.
252+
Error validateORCTables();
253+
251254
/// Static call table handling.
252255
Error readStaticCalls();
253256
Error rewriteStaticCalls();
@@ -358,6 +361,9 @@ class LinuxKernelRewriter final : public MetadataRewriter {
358361
if (Error E = updateStaticKeysJumpTablePostEmit())
359362
return E;
360363

364+
if (Error E = validateORCTables())
365+
return E;
366+
361367
return Error::success();
362368
}
363369
};
@@ -837,6 +843,32 @@ Error LinuxKernelRewriter::rewriteORCTables() {
837843
return Error::success();
838844
}
839845

846+
Error LinuxKernelRewriter::validateORCTables() {
847+
if (!ORCUnwindIPSection)
848+
return Error::success();
849+
850+
const uint64_t IPSectionAddress = ORCUnwindIPSection->getAddress();
851+
DataExtractor IPDE = DataExtractor(ORCUnwindIPSection->getOutputContents(),
852+
BC.AsmInfo->isLittleEndian(),
853+
BC.AsmInfo->getCodePointerSize());
854+
DataExtractor::Cursor IPCursor(0);
855+
uint64_t PrevIP = 0;
856+
for (uint32_t Index = 0; Index < NumORCEntries; ++Index) {
857+
const uint64_t IP =
858+
IPSectionAddress + IPCursor.tell() + (int32_t)IPDE.getU32(IPCursor);
859+
if (!IPCursor)
860+
return createStringError(errc::executable_format_error,
861+
"out of bounds while reading ORC IP table: %s",
862+
toString(IPCursor.takeError()).c_str());
863+
864+
assert(IP >= PrevIP && "Unsorted ORC table detected");
865+
(void)PrevIP;
866+
PrevIP = IP;
867+
}
868+
869+
return Error::success();
870+
}
871+
840872
/// The static call site table is created by objtool and contains entries in the
841873
/// following format:
842874
///

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,9 @@ Bug Fixes in This Version
465465
- Clang now correctly generates overloads for bit-precise integer types for
466466
builtin operators in C++. Fixes #GH82998.
467467

468+
- Fix crash when destructor definition is preceded with an equals sign.
469+
Fixes (#GH89544).
470+
468471
- When performing mixed arithmetic between ``_Complex`` floating-point types and integers,
469472
Clang now correctly promotes the integer to its corresponding real floating-point
470473
type only rather than to the complex type (e.g. ``_Complex float / int`` is now evaluated
@@ -619,6 +622,7 @@ Bug Fixes to C++ Support
619622
- Fix a bug on template partial specialization whose template parameter is `decltype(auto)`.
620623
- Fix a bug on template partial specialization with issue on deduction of nontype template parameter
621624
whose type is `decltype(auto)`. Fixes (#GH68885).
625+
- Clang now correctly treats the noexcept-specifier of a friend function to be a complete-class context.
622626

623627
Bug Fixes to AST Handling
624628
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/docs/UsersManual.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1696,7 +1696,6 @@ for more details.
16961696
* ``-fno-associative-math``
16971697
* ``-fno-reciprocal-math``
16981698
* ``-fsigned-zeros``
1699-
* ``-ftrapping-math``
17001699
* ``-ffp-contract=on``
17011700

17021701
There is ambiguity about how ``-ffp-contract``,

clang/include/clang/AST/ExprCXX.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,6 +1482,8 @@ class CXXTemporary {
14821482
/// const S &s_ref = S(); // Requires a CXXBindTemporaryExpr.
14831483
/// }
14841484
/// \endcode
1485+
///
1486+
/// Destructor might be null if destructor declaration is not valid.
14851487
class CXXBindTemporaryExpr : public Expr {
14861488
CXXTemporary *Temp = nullptr;
14871489
Stmt *SubExpr = nullptr;

clang/include/clang/AST/OpenACCClause.h

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

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;
159+
/// Represents a clause that has one or more expressions associated with it.
160+
class OpenACCClauseWithExprs : public OpenACCClauseWithParams {
161+
MutableArrayRef<Expr *> Exprs;
163162

164163
protected:
165-
OpenACCClauseWithIntExprs(OpenACCClauseKind K, SourceLocation BeginLoc,
166-
SourceLocation LParenLoc, SourceLocation EndLoc)
164+
OpenACCClauseWithExprs(OpenACCClauseKind K, SourceLocation BeginLoc,
165+
SourceLocation LParenLoc, SourceLocation EndLoc)
167166
: OpenACCClauseWithParams(K, BeginLoc, LParenLoc, EndLoc) {}
168167

169168
/// Used only for initialization, the leaf class can initialize this to
170169
/// trailing storage.
171-
void setIntExprs(MutableArrayRef<Expr *> NewIntExprs) {
172-
assert(IntExprs.empty() && "Cannot change IntExprs list");
173-
IntExprs = NewIntExprs;
170+
void setExprs(MutableArrayRef<Expr *> NewExprs) {
171+
assert(Exprs.empty() && "Cannot change Exprs list");
172+
Exprs = NewExprs;
174173
}
175174

176-
/// Gets the entire list of integer expressions, but leave it to the
175+
/// Gets the entire list of expressions, but leave it to the
177176
/// individual clauses to expose this how they'd like.
178-
llvm::ArrayRef<Expr *> getIntExprs() const { return IntExprs; }
177+
llvm::ArrayRef<Expr *> getExprs() const { return Exprs; }
179178

180179
public:
181180
child_range children() {
182-
return child_range(reinterpret_cast<Stmt **>(IntExprs.begin()),
183-
reinterpret_cast<Stmt **>(IntExprs.end()));
181+
return child_range(reinterpret_cast<Stmt **>(Exprs.begin()),
182+
reinterpret_cast<Stmt **>(Exprs.end()));
184183
}
185184

186185
const_child_range children() const {
187186
child_range Children =
188-
const_cast<OpenACCClauseWithIntExprs *>(this)->children();
187+
const_cast<OpenACCClauseWithExprs *>(this)->children();
189188
return const_child_range(Children.begin(), Children.end());
190189
}
191190
};
192191

193192
class OpenACCNumGangsClause final
194-
: public OpenACCClauseWithIntExprs,
193+
: public OpenACCClauseWithExprs,
195194
public llvm::TrailingObjects<OpenACCNumGangsClause, Expr *> {
196195

197196
OpenACCNumGangsClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
198197
ArrayRef<Expr *> IntExprs, SourceLocation EndLoc)
199-
: OpenACCClauseWithIntExprs(OpenACCClauseKind::NumGangs, BeginLoc,
200-
LParenLoc, EndLoc) {
198+
: OpenACCClauseWithExprs(OpenACCClauseKind::NumGangs, BeginLoc, LParenLoc,
199+
EndLoc) {
201200
std::uninitialized_copy(IntExprs.begin(), IntExprs.end(),
202201
getTrailingObjects<Expr *>());
203-
setIntExprs(MutableArrayRef(getTrailingObjects<Expr *>(), IntExprs.size()));
202+
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), IntExprs.size()));
204203
}
205204

206205
public:
@@ -209,35 +208,35 @@ class OpenACCNumGangsClause final
209208
ArrayRef<Expr *> IntExprs, SourceLocation EndLoc);
210209

211210
llvm::ArrayRef<Expr *> getIntExprs() {
212-
return OpenACCClauseWithIntExprs::getIntExprs();
211+
return OpenACCClauseWithExprs::getExprs();
213212
}
214213

215214
llvm::ArrayRef<Expr *> getIntExprs() const {
216-
return OpenACCClauseWithIntExprs::getIntExprs();
215+
return OpenACCClauseWithExprs::getExprs();
217216
}
218217
};
219218

220219
/// Represents one of a handful of clauses that have a single integer
221220
/// expression.
222-
class OpenACCClauseWithSingleIntExpr : public OpenACCClauseWithIntExprs {
221+
class OpenACCClauseWithSingleIntExpr : public OpenACCClauseWithExprs {
223222
Expr *IntExpr;
224223

225224
protected:
226225
OpenACCClauseWithSingleIntExpr(OpenACCClauseKind K, SourceLocation BeginLoc,
227226
SourceLocation LParenLoc, Expr *IntExpr,
228227
SourceLocation EndLoc)
229-
: OpenACCClauseWithIntExprs(K, BeginLoc, LParenLoc, EndLoc),
228+
: OpenACCClauseWithExprs(K, BeginLoc, LParenLoc, EndLoc),
230229
IntExpr(IntExpr) {
231-
setIntExprs(MutableArrayRef<Expr *>{&this->IntExpr, 1});
230+
setExprs(MutableArrayRef<Expr *>{&this->IntExpr, 1});
232231
}
233232

234233
public:
235-
bool hasIntExpr() const { return !getIntExprs().empty(); }
234+
bool hasIntExpr() const { return !getExprs().empty(); }
236235
const Expr *getIntExpr() const {
237-
return hasIntExpr() ? getIntExprs()[0] : nullptr;
236+
return hasIntExpr() ? getExprs()[0] : nullptr;
238237
}
239238

240-
Expr *getIntExpr() { return hasIntExpr() ? getIntExprs()[0] : nullptr; };
239+
Expr *getIntExpr() { return hasIntExpr() ? getExprs()[0] : nullptr; };
241240
};
242241

243242
class OpenACCNumWorkersClause : public OpenACCClauseWithSingleIntExpr {
@@ -261,6 +260,40 @@ class OpenACCVectorLengthClause : public OpenACCClauseWithSingleIntExpr {
261260
Expr *IntExpr, SourceLocation EndLoc);
262261
};
263262

263+
/// Represents a clause with one or more 'var' objects, represented as an expr,
264+
/// as its arguments. Var-list is expected to be stored in trailing storage.
265+
/// For now, we're just storing the original expression in its entirety, unlike
266+
/// OMP which has to do a bunch of work to create a private.
267+
class OpenACCClauseWithVarList : public OpenACCClauseWithExprs {
268+
protected:
269+
OpenACCClauseWithVarList(OpenACCClauseKind K, SourceLocation BeginLoc,
270+
SourceLocation LParenLoc, SourceLocation EndLoc)
271+
: OpenACCClauseWithExprs(K, BeginLoc, LParenLoc, EndLoc) {}
272+
273+
public:
274+
ArrayRef<Expr *> getVarList() { return getExprs(); }
275+
ArrayRef<Expr *> getVarList() const { return getExprs(); }
276+
};
277+
278+
class OpenACCPrivateClause final
279+
: public OpenACCClauseWithVarList,
280+
public llvm::TrailingObjects<OpenACCPrivateClause, Expr *> {
281+
282+
OpenACCPrivateClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
283+
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
284+
: OpenACCClauseWithVarList(OpenACCClauseKind::Private, BeginLoc,
285+
LParenLoc, EndLoc) {
286+
std::uninitialized_copy(VarList.begin(), VarList.end(),
287+
getTrailingObjects<Expr *>());
288+
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
289+
}
290+
291+
public:
292+
static OpenACCPrivateClause *
293+
Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
294+
ArrayRef<Expr *> VarList, SourceLocation EndLoc);
295+
};
296+
264297
template <class Impl> class OpenACCClauseVisitor {
265298
Impl &getDerived() { return static_cast<Impl &>(*this); }
266299

clang/include/clang/Basic/DiagnosticInstallAPIKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def err_no_matching_target : Error<"no matching target found for target variant
2424
def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">;
2525
def err_unsupported_environment : Error<"environment '%0' is not supported: '%1'">;
2626
def err_unsupported_os : Error<"os '%0' is not supported: '%1'">;
27-
def err_cannot_read_alias_list : Error<"could not read alias list '%0': %1">;
27+
def err_cannot_read_input_list : Error<"could not read %select{alias list|filelist}0 '%1': %2">;
2828
} // end of command line category.
2929

3030
let CategoryName = "Verification" in {

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12305,4 +12305,7 @@ def err_acc_num_gangs_num_args
1230512305
"OpenACC 'num_gangs' "
1230612306
"%select{|clause: '%1' directive expects maximum of %2, %3 were "
1230712307
"provided}0">;
12308+
def err_acc_not_a_var_ref
12309+
: Error<"OpenACC variable is not a valid variable name, sub-array, array "
12310+
"element, or composite variable member">;
1230812311
} // end of sema component.

clang/include/clang/Basic/OpenACCClauses.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ VISIT_CLAUSE(If)
2020
VISIT_CLAUSE(Self)
2121
VISIT_CLAUSE(NumGangs)
2222
VISIT_CLAUSE(NumWorkers)
23+
VISIT_CLAUSE(Private)
2324
VISIT_CLAUSE(VectorLength)
2425

2526
#undef VISIT_CLAUSE

clang/include/clang/InstallAPI/FileList.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ class FileListReader {
2929
///
3030
/// \param InputBuffer JSON input data.
3131
/// \param Destination Container to load headers into.
32+
/// \param FM Optional File Manager to validate input files exist.
3233
static llvm::Error
3334
loadHeaders(std::unique_ptr<llvm::MemoryBuffer> InputBuffer,
34-
HeaderSeq &Destination);
35+
HeaderSeq &Destination, clang::FileManager *FM = nullptr);
3536

3637
FileListReader() = delete;
3738
};

clang/include/clang/Parse/Parser.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3654,11 +3654,12 @@ class Parser : public CodeCompletionHandler {
36543654
ExprResult ParseOpenACCIDExpression();
36553655
/// Parses the variable list for the `cache` construct.
36563656
void ParseOpenACCCacheVarList();
3657+
3658+
using OpenACCVarParseResult = std::pair<ExprResult, OpenACCParseCanContinue>;
36573659
/// Parses a single variable in a variable list for OpenACC.
3658-
bool ParseOpenACCVar();
3659-
/// Parses the variable list for the variety of clauses that take a var-list,
3660-
/// including the optional Special Token listed for some,based on clause type.
3661-
bool ParseOpenACCClauseVarList(OpenACCClauseKind Kind);
3660+
OpenACCVarParseResult ParseOpenACCVar();
3661+
/// Parses the variable list for the variety of places that take a var-list.
3662+
llvm::SmallVector<Expr *> ParseOpenACCVarList();
36623663
/// Parses any parameters for an OpenACC Clause, including required/optional
36633664
/// parens.
36643665
OpenACCClauseParseResult

clang/include/clang/Sema/Sema.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4101,12 +4101,12 @@ class Sema final : public SemaBase {
41014101
SmallVectorImpl<QualType> &Exceptions,
41024102
FunctionProtoType::ExceptionSpecInfo &ESI);
41034103

4104-
/// Add an exception-specification to the given member function
4105-
/// (or member function template). The exception-specification was parsed
4106-
/// after the method itself was declared.
4104+
/// Add an exception-specification to the given member or friend function
4105+
/// (or function template). The exception-specification was parsed
4106+
/// after the function itself was declared.
41074107
void actOnDelayedExceptionSpecification(
4108-
Decl *Method, ExceptionSpecificationType EST,
4109-
SourceRange SpecificationRange, ArrayRef<ParsedType> DynamicExceptions,
4108+
Decl *D, ExceptionSpecificationType EST, SourceRange SpecificationRange,
4109+
ArrayRef<ParsedType> DynamicExceptions,
41104110
ArrayRef<SourceRange> DynamicExceptionRanges, Expr *NoexceptExpr);
41114111

41124112
class InheritedConstructorInfo;

clang/include/clang/Sema/SemaOpenACC.h

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@ class SemaOpenACC : public SemaBase {
4848
SmallVector<Expr *> IntExprs;
4949
};
5050

51+
struct VarListDetails {
52+
SmallVector<Expr *> VarList;
53+
};
54+
5155
std::variant<std::monostate, DefaultDetails, ConditionDetails,
52-
IntExprDetails>
56+
IntExprDetails, VarListDetails>
5357
Details = std::monostate{};
5458

5559
public:
@@ -112,6 +116,16 @@ class SemaOpenACC : public SemaBase {
112116
return const_cast<OpenACCParsedClause *>(this)->getIntExprs();
113117
}
114118

119+
ArrayRef<Expr *> getVarList() {
120+
assert(ClauseKind == OpenACCClauseKind::Private &&
121+
"Parsed clause kind does not have a var-list");
122+
return std::get<VarListDetails>(Details).VarList;
123+
}
124+
125+
ArrayRef<Expr *> getVarList() const {
126+
return const_cast<OpenACCParsedClause *>(this)->getVarList();
127+
}
128+
115129
void setLParenLoc(SourceLocation EndLoc) { LParenLoc = EndLoc; }
116130
void setEndLoc(SourceLocation EndLoc) { ClauseRange.setEnd(EndLoc); }
117131

@@ -147,7 +161,19 @@ class SemaOpenACC : public SemaBase {
147161
ClauseKind == OpenACCClauseKind::NumWorkers ||
148162
ClauseKind == OpenACCClauseKind::VectorLength) &&
149163
"Parsed clause kind does not have a int exprs");
150-
Details = IntExprDetails{IntExprs};
164+
Details = IntExprDetails{std::move(IntExprs)};
165+
}
166+
167+
void setVarListDetails(ArrayRef<Expr *> VarList) {
168+
assert(ClauseKind == OpenACCClauseKind::Private &&
169+
"Parsed clause kind does not have a var-list");
170+
Details = VarListDetails{{VarList.begin(), VarList.end()}};
171+
}
172+
173+
void setVarListDetails(llvm::SmallVector<Expr *> &&VarList) {
174+
assert(ClauseKind == OpenACCClauseKind::Private &&
175+
"Parsed clause kind does not have a var-list");
176+
Details = VarListDetails{std::move(VarList)};
151177
}
152178
};
153179

@@ -194,6 +220,10 @@ class SemaOpenACC : public SemaBase {
194220
ExprResult ActOnIntExpr(OpenACCDirectiveKind DK, OpenACCClauseKind CK,
195221
SourceLocation Loc, Expr *IntExpr);
196222

223+
/// Called when encountering a 'var' for OpenACC, ensures it is actually a
224+
/// declaration reference to a variable of the correct type.
225+
ExprResult ActOnVar(Expr *VarExpr);
226+
197227
/// Checks and creates an Array Section used in an OpenACC construct/clause.
198228
ExprResult ActOnArraySectionExpr(Expr *Base, SourceLocation LBLoc,
199229
Expr *LowerBound,

clang/include/clang/Serialization/ASTRecordReader.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ class ASTRecordReader
269269
/// Read an OpenMP children, advancing Idx.
270270
void readOMPChildren(OMPChildren *Data);
271271

272+
/// Read a list of Exprs used for a var-list.
273+
llvm::SmallVector<Expr *> readOpenACCVarList();
274+
272275
/// Read an OpenACC clause, advancing Idx.
273276
OpenACCClause *readOpenACCClause();
274277

0 commit comments

Comments
 (0)