Skip to content

Commit c6cc339

Browse files
committed
Merge remote-tracking branch 'origin/main' into vplan-compute-iv-end-values
2 parents 6440a91 + c95af08 commit c6cc339

File tree

654 files changed

+6613
-17219
lines changed

Some content is hidden

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

654 files changed

+6613
-17219
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ code bases.
6161
C/C++ Language Potentially Breaking Changes
6262
-------------------------------------------
6363

64+
- Clang now rejects ``_Complex _BitInt`` types.
65+
6466
C++ Specific Potentially Breaking Changes
6567
-----------------------------------------
6668

@@ -664,6 +666,15 @@ Improvements to Clang's diagnostics
664666
bool operator==(const C&) = default;
665667
};
666668

669+
- Clang now emits `-Wdangling-capture` diangostic when a STL container captures a dangling reference.
670+
671+
.. code-block:: c++
672+
673+
void test() {
674+
std::vector<std::string_view> views;
675+
views.push_back(std::string("123")); // warning
676+
}
677+
667678
Improvements to Clang's time-trace
668679
----------------------------------
669680

clang/include/clang-c/CXString.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ typedef struct {
4646

4747
/**
4848
* Retrieve the character data associated with the given string.
49+
*
50+
* The returned data is a reference and not owned by the user. This data
51+
* is only valid while the `CXString` is valid. This function is similar
52+
* to `std::string::c_str()`.
4953
*/
5054
CINDEX_LINKAGE const char *clang_getCString(CXString string);
5155

clang/include/clang-c/Index.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2166,9 +2166,27 @@ enum CXCursorKind {
21662166
*/
21672167
CXCursor_OpenACCLoopConstruct = 321,
21682168

2169+
/** OpenACC Combined Constructs.
2170+
*/
21692171
CXCursor_OpenACCCombinedConstruct = 322,
21702172

2171-
CXCursor_LastStmt = CXCursor_OpenACCCombinedConstruct,
2173+
/** OpenACC data Construct.
2174+
*/
2175+
CXCursor_OpenACCDataConstruct = 323,
2176+
2177+
/** OpenACC enter data Construct.
2178+
*/
2179+
CXCursor_OpenACCEnterDataConstruct = 324,
2180+
2181+
/** OpenACC exit data Construct.
2182+
*/
2183+
CXCursor_OpenACCExitDataConstruct = 325,
2184+
2185+
/** OpenACC host_data Construct.
2186+
*/
2187+
CXCursor_OpenACCHostDataConstruct = 326,
2188+
2189+
CXCursor_LastStmt = CXCursor_OpenACCHostDataConstruct,
21722190

21732191
/**
21742192
* Cursor that represents the translation unit itself.

clang/include/clang/AST/RecursiveASTVisitor.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2151,8 +2151,11 @@ DEF_TRAVERSE_DECL(DecompositionDecl, {
21512151
})
21522152

21532153
DEF_TRAVERSE_DECL(BindingDecl, {
2154-
if (getDerived().shouldVisitImplicitCode())
2154+
if (getDerived().shouldVisitImplicitCode()) {
21552155
TRY_TO(TraverseStmt(D->getBinding()));
2156+
if (const auto HoldingVar = D->getHoldingVar())
2157+
TRY_TO(TraverseDecl(HoldingVar));
2158+
}
21562159
})
21572160

21582161
DEF_TRAVERSE_DECL(MSPropertyDecl, { TRY_TO(TraverseDeclaratorHelper(D)); })
@@ -4058,6 +4061,12 @@ DEF_TRAVERSE_STMT(OpenACCLoopConstruct,
40584061
{ TRY_TO(TraverseOpenACCAssociatedStmtConstruct(S)); })
40594062
DEF_TRAVERSE_STMT(OpenACCCombinedConstruct,
40604063
{ TRY_TO(TraverseOpenACCAssociatedStmtConstruct(S)); })
4064+
DEF_TRAVERSE_STMT(OpenACCDataConstruct,
4065+
{ TRY_TO(TraverseOpenACCAssociatedStmtConstruct(S)); })
4066+
DEF_TRAVERSE_STMT(OpenACCEnterDataConstruct, {})
4067+
DEF_TRAVERSE_STMT(OpenACCExitDataConstruct, {})
4068+
DEF_TRAVERSE_STMT(OpenACCHostDataConstruct,
4069+
{ TRY_TO(TraverseOpenACCAssociatedStmtConstruct(S)); })
40614070

40624071
// Traverse HLSL: Out argument expression
40634072
DEF_TRAVERSE_STMT(HLSLOutArgExpr, {})

clang/include/clang/AST/StmtOpenACC.h

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,5 +292,175 @@ class OpenACCCombinedConstruct final
292292
return const_cast<OpenACCCombinedConstruct *>(this)->getLoop();
293293
}
294294
};
295+
296+
// This class represents a 'data' construct, which has an associated statement
297+
// and clauses, but is otherwise pretty simple.
298+
class OpenACCDataConstruct final
299+
: public OpenACCAssociatedStmtConstruct,
300+
public llvm::TrailingObjects<OpenACCCombinedConstruct,
301+
const OpenACCClause *> {
302+
OpenACCDataConstruct(unsigned NumClauses)
303+
: OpenACCAssociatedStmtConstruct(
304+
OpenACCDataConstructClass, OpenACCDirectiveKind::Data,
305+
SourceLocation{}, SourceLocation{}, SourceLocation{},
306+
/*AssociatedStmt=*/nullptr) {
307+
std::uninitialized_value_construct(
308+
getTrailingObjects<const OpenACCClause *>(),
309+
getTrailingObjects<const OpenACCClause *>() + NumClauses);
310+
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
311+
NumClauses));
312+
}
313+
314+
OpenACCDataConstruct(SourceLocation Start, SourceLocation DirectiveLoc,
315+
SourceLocation End,
316+
ArrayRef<const OpenACCClause *> Clauses,
317+
Stmt *StructuredBlock)
318+
: OpenACCAssociatedStmtConstruct(OpenACCDataConstructClass,
319+
OpenACCDirectiveKind::Data, Start,
320+
DirectiveLoc, End, StructuredBlock) {
321+
std::uninitialized_copy(Clauses.begin(), Clauses.end(),
322+
getTrailingObjects<const OpenACCClause *>());
323+
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
324+
Clauses.size()));
325+
}
326+
void setStructuredBlock(Stmt *S) { setAssociatedStmt(S); }
327+
328+
public:
329+
static bool classof(const Stmt *T) {
330+
return T->getStmtClass() == OpenACCDataConstructClass;
331+
}
332+
333+
static OpenACCDataConstruct *CreateEmpty(const ASTContext &C,
334+
unsigned NumClauses);
335+
static OpenACCDataConstruct *Create(const ASTContext &C, SourceLocation Start,
336+
SourceLocation DirectiveLoc,
337+
SourceLocation End,
338+
ArrayRef<const OpenACCClause *> Clauses,
339+
Stmt *StructuredBlock);
340+
Stmt *getStructuredBlock() { return getAssociatedStmt(); }
341+
const Stmt *getStructuredBlock() const {
342+
return const_cast<OpenACCDataConstruct *>(this)->getStructuredBlock();
343+
}
344+
};
345+
// This class represents a 'enter data' construct, which JUST has clauses.
346+
class OpenACCEnterDataConstruct final
347+
: public OpenACCConstructStmt,
348+
public llvm::TrailingObjects<OpenACCCombinedConstruct,
349+
const OpenACCClause *> {
350+
OpenACCEnterDataConstruct(unsigned NumClauses)
351+
: OpenACCConstructStmt(OpenACCEnterDataConstructClass,
352+
OpenACCDirectiveKind::EnterData, SourceLocation{},
353+
SourceLocation{}, SourceLocation{}) {
354+
std::uninitialized_value_construct(
355+
getTrailingObjects<const OpenACCClause *>(),
356+
getTrailingObjects<const OpenACCClause *>() + NumClauses);
357+
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
358+
NumClauses));
359+
}
360+
OpenACCEnterDataConstruct(SourceLocation Start, SourceLocation DirectiveLoc,
361+
SourceLocation End,
362+
ArrayRef<const OpenACCClause *> Clauses)
363+
: OpenACCConstructStmt(OpenACCEnterDataConstructClass,
364+
OpenACCDirectiveKind::EnterData, Start,
365+
DirectiveLoc, End) {
366+
std::uninitialized_copy(Clauses.begin(), Clauses.end(),
367+
getTrailingObjects<const OpenACCClause *>());
368+
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
369+
Clauses.size()));
370+
}
371+
372+
public:
373+
static bool classof(const Stmt *T) {
374+
return T->getStmtClass() == OpenACCEnterDataConstructClass;
375+
}
376+
static OpenACCEnterDataConstruct *CreateEmpty(const ASTContext &C,
377+
unsigned NumClauses);
378+
static OpenACCEnterDataConstruct *
379+
Create(const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
380+
SourceLocation End, ArrayRef<const OpenACCClause *> Clauses);
381+
};
382+
// This class represents a 'exit data' construct, which JUST has clauses.
383+
class OpenACCExitDataConstruct final
384+
: public OpenACCConstructStmt,
385+
public llvm::TrailingObjects<OpenACCCombinedConstruct,
386+
const OpenACCClause *> {
387+
OpenACCExitDataConstruct(unsigned NumClauses)
388+
: OpenACCConstructStmt(OpenACCExitDataConstructClass,
389+
OpenACCDirectiveKind::ExitData, SourceLocation{},
390+
SourceLocation{}, SourceLocation{}) {
391+
std::uninitialized_value_construct(
392+
getTrailingObjects<const OpenACCClause *>(),
393+
getTrailingObjects<const OpenACCClause *>() + NumClauses);
394+
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
395+
NumClauses));
396+
}
397+
OpenACCExitDataConstruct(SourceLocation Start, SourceLocation DirectiveLoc,
398+
SourceLocation End,
399+
ArrayRef<const OpenACCClause *> Clauses)
400+
: OpenACCConstructStmt(OpenACCExitDataConstructClass,
401+
OpenACCDirectiveKind::ExitData, Start,
402+
DirectiveLoc, End) {
403+
std::uninitialized_copy(Clauses.begin(), Clauses.end(),
404+
getTrailingObjects<const OpenACCClause *>());
405+
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
406+
Clauses.size()));
407+
}
408+
409+
public:
410+
static bool classof(const Stmt *T) {
411+
return T->getStmtClass() == OpenACCExitDataConstructClass;
412+
}
413+
static OpenACCExitDataConstruct *CreateEmpty(const ASTContext &C,
414+
unsigned NumClauses);
415+
static OpenACCExitDataConstruct *
416+
Create(const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
417+
SourceLocation End, ArrayRef<const OpenACCClause *> Clauses);
418+
};
419+
// This class represents a 'host_data' construct, which has an associated
420+
// statement and clauses, but is otherwise pretty simple.
421+
class OpenACCHostDataConstruct final
422+
: public OpenACCAssociatedStmtConstruct,
423+
public llvm::TrailingObjects<OpenACCCombinedConstruct,
424+
const OpenACCClause *> {
425+
OpenACCHostDataConstruct(unsigned NumClauses)
426+
: OpenACCAssociatedStmtConstruct(
427+
OpenACCHostDataConstructClass, OpenACCDirectiveKind::HostData,
428+
SourceLocation{}, SourceLocation{}, SourceLocation{},
429+
/*AssociatedStmt=*/nullptr) {
430+
std::uninitialized_value_construct(
431+
getTrailingObjects<const OpenACCClause *>(),
432+
getTrailingObjects<const OpenACCClause *>() + NumClauses);
433+
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
434+
NumClauses));
435+
}
436+
OpenACCHostDataConstruct(SourceLocation Start, SourceLocation DirectiveLoc,
437+
SourceLocation End,
438+
ArrayRef<const OpenACCClause *> Clauses,
439+
Stmt *StructuredBlock)
440+
: OpenACCAssociatedStmtConstruct(OpenACCHostDataConstructClass,
441+
OpenACCDirectiveKind::HostData, Start,
442+
DirectiveLoc, End, StructuredBlock) {
443+
std::uninitialized_copy(Clauses.begin(), Clauses.end(),
444+
getTrailingObjects<const OpenACCClause *>());
445+
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
446+
Clauses.size()));
447+
}
448+
void setStructuredBlock(Stmt *S) { setAssociatedStmt(S); }
449+
450+
public:
451+
static bool classof(const Stmt *T) {
452+
return T->getStmtClass() == OpenACCHostDataConstructClass;
453+
}
454+
static OpenACCHostDataConstruct *CreateEmpty(const ASTContext &C,
455+
unsigned NumClauses);
456+
static OpenACCHostDataConstruct *
457+
Create(const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
458+
SourceLocation End, ArrayRef<const OpenACCClause *> Clauses,
459+
Stmt *StructuredBlock);
460+
Stmt *getStructuredBlock() { return getAssociatedStmt(); }
461+
const Stmt *getStructuredBlock() const {
462+
return const_cast<OpenACCHostDataConstruct *>(this)->getStructuredBlock();
463+
}
464+
};
295465
} // namespace clang
296466
#endif // LLVM_CLANG_AST_STMTOPENACC_H

clang/include/clang/AST/TextNodeDumper.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,10 @@ class TextNodeDumper
411411
void VisitOpenACCConstructStmt(const OpenACCConstructStmt *S);
412412
void VisitOpenACCLoopConstruct(const OpenACCLoopConstruct *S);
413413
void VisitOpenACCCombinedConstruct(const OpenACCCombinedConstruct *S);
414+
void VisitOpenACCDataConstruct(const OpenACCDataConstruct *S);
415+
void VisitOpenACCEnterDataConstruct(const OpenACCEnterDataConstruct *S);
416+
void VisitOpenACCExitDataConstruct(const OpenACCExitDataConstruct *S);
417+
void VisitOpenACCHostDataConstruct(const OpenACCHostDataConstruct *S);
414418
void VisitOpenACCAsteriskSizeExpr(const OpenACCAsteriskSizeExpr *S);
415419
void VisitEmbedExpr(const EmbedExpr *S);
416420
void VisitAtomicExpr(const AtomicExpr *AE);

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10237,10 +10237,10 @@ def warn_dangling_pointer_assignment : Warning<
1023710237
InGroup<DanglingAssignment>;
1023810238
def warn_dangling_reference_captured : Warning<
1023910239
"object whose reference is captured by '%0' will be destroyed at the end of "
10240-
"the full-expression">, InGroup<DanglingCapture>, DefaultIgnore;
10240+
"the full-expression">, InGroup<DanglingCapture>;
1024110241
def warn_dangling_reference_captured_by_unknown : Warning<
1024210242
"object whose reference is captured will be destroyed at the end of "
10243-
"the full-expression">, InGroup<DanglingCapture>, DefaultIgnore;
10243+
"the full-expression">, InGroup<DanglingCapture>;
1024410244

1024510245
// For non-floating point, expressions of the form x == x or x != x
1024610246
// should result in a warning, since these always evaluate to a constant.

clang/include/clang/Basic/StmtNodes.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,10 @@ def OpenACCAssociatedStmtConstruct
308308
def OpenACCComputeConstruct : StmtNode<OpenACCAssociatedStmtConstruct>;
309309
def OpenACCLoopConstruct : StmtNode<OpenACCAssociatedStmtConstruct>;
310310
def OpenACCCombinedConstruct : StmtNode<OpenACCAssociatedStmtConstruct>;
311+
def OpenACCDataConstruct : StmtNode<OpenACCAssociatedStmtConstruct>;
312+
def OpenACCEnterDataConstruct : StmtNode<OpenACCConstructStmt>;
313+
def OpenACCExitDataConstruct : StmtNode<OpenACCConstructStmt>;
314+
def OpenACCHostDataConstruct : StmtNode<OpenACCAssociatedStmtConstruct>;
311315

312316
// OpenACC Additional Expressions.
313317
def OpenACCAsteriskSizeExpr : StmtNode<Expr>;

clang/include/clang/Serialization/ASTBitCodes.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,6 +2019,10 @@ enum StmtCode {
20192019
STMT_OPENACC_LOOP_CONSTRUCT,
20202020
STMT_OPENACC_COMBINED_CONSTRUCT,
20212021
EXPR_OPENACC_ASTERISK_SIZE,
2022+
STMT_OPENACC_DATA_CONSTRUCT,
2023+
STMT_OPENACC_ENTER_DATA_CONSTRUCT,
2024+
STMT_OPENACC_EXIT_DATA_CONSTRUCT,
2025+
STMT_OPENACC_HOST_DATA_CONSTRUCT,
20222026

20232027
// HLSL Constructs
20242028
EXPR_HLSL_OUT_ARG,

0 commit comments

Comments
 (0)