Skip to content

Commit a71ebb5

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#2250)
2 parents 934b4d3 + 30faa16 commit a71ebb5

File tree

113 files changed

+4467
-894
lines changed

Some content is hidden

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

113 files changed

+4467
-894
lines changed

clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ static const clang::StringRef GlibcFunctions[] = {
153153
"::sigsuspend",
154154
"::sleep",
155155
"::srand48",
156-
"::strerror",
157156
"::strsignal",
158157
"::strtok",
159158
"::tcflow",

clang-tools-extra/clangd/ModulesBuilder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ bool IsModuleFileUpToDate(PathRef ModuleFilePath,
207207
Preprocessor PP(PPOpts, *Diags, LangOpts, SourceMgr, HeaderInfo,
208208
ModuleLoader);
209209

210-
IntrusiveRefCntPtr<ModuleCache> ModCache = createCrossProcessModuleCache();
210+
IntrusiveRefCntPtr<ModuleCache> ModCache =
211+
createCrossProcessModuleCache(HSOpts.BuildSessionTimestamp);
211212
PCHContainerOperations PCHOperations;
212213
ASTReader Reader(PP, *ModCache, /*ASTContext=*/nullptr,
213214
PCHOperations.getRawReader(), {});

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ Changes in existing checks
172172
<clang-tidy/checks/cert/err33-c>` check by fixing false positives when
173173
a function name is just prefixed with a targeted function name.
174174

175+
- Improved :doc:`concurrency-mt-unsafe
176+
<clang-tidy/checks/concurrency/mt-unsafe>` check by fixing a false positive
177+
where ``strerror`` was flagged as MT-unsafe.
178+
175179
- Improved :doc:`misc-const-correctness
176180
<clang-tidy/checks/misc/const-correctness>` check by adding the option
177181
`AllowedTypes`, that excludes specified types from const-correctness

clang-tools-extra/test/clang-tidy/checkers/concurrency/mt-unsafe-glibc.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
extern unsigned int sleep (unsigned int __seconds);
44
extern int *gmtime (const int *__timer);
55
extern char *dirname (char *__path);
6+
extern char *strerror(int errnum);
67

78
void foo() {
89
sleep(2);
@@ -12,4 +13,6 @@ void foo() {
1213
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrency-mt-unsafe]
1314

1415
dirname(nullptr);
16+
17+
strerror(0);
1518
}

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,9 @@ Improvements to Clang's diagnostics
574574
between different Unicode character types (``char8_t``, ``char16_t``, ``char32_t``).
575575
This warning only triggers in C++ as these types are aliases in C. (#GH138526)
576576

577+
- Fixed a crash when checking a ``__thread``-specified variable declaration
578+
with a dependent type in C++. (#GH140509)
579+
577580
Improvements to Clang's time-trace
578581
----------------------------------
579582

@@ -757,6 +760,8 @@ Bug Fixes to C++ Support
757760
- Fixed a function declaration mismatch that caused inconsistencies between concepts and variable template declarations. (#GH139476)
758761
- Clang no longer segfaults when there is a configuration mismatch between modules and their users (http://crbug.com/400353616).
759762
- Fix an incorrect deduction when calling an explicit object member function template through an overload set address.
763+
- Fixed bug in constant evaluation that would allow using the value of a
764+
reference in its own initializer in C++23 mode (#GH131330).
760765

761766
Bug Fixes to AST Handling
762767
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/DeclOpenACC.h

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,8 @@ class OpenACCDeclareDecl final
7373

7474
OpenACCDeclareDecl(unsigned NumClauses)
7575
: OpenACCConstructDecl(OpenACCDeclare) {
76-
std::uninitialized_value_construct(
77-
getTrailingObjects<const OpenACCClause *>(),
78-
getTrailingObjects<const OpenACCClause *>() + NumClauses);
79-
setClauseList(getTrailingObjects<const OpenACCClause *>(NumClauses));
76+
std::uninitialized_value_construct_n(getTrailingObjects(), NumClauses);
77+
setClauseList(getTrailingObjects(NumClauses));
8078
}
8179

8280
OpenACCDeclareDecl(DeclContext *DC, SourceLocation StartLoc,
@@ -85,10 +83,9 @@ class OpenACCDeclareDecl final
8583
: OpenACCConstructDecl(OpenACCDeclare, DC, OpenACCDirectiveKind::Declare,
8684
StartLoc, DirLoc, EndLoc) {
8785
// Initialize the trailing storage.
88-
llvm::uninitialized_copy(Clauses,
89-
getTrailingObjects<const OpenACCClause *>());
86+
llvm::uninitialized_copy(Clauses, getTrailingObjects());
9087

91-
setClauseList(getTrailingObjects<const OpenACCClause *>(Clauses.size()));
88+
setClauseList(getTrailingObjects(Clauses.size()));
9289
}
9390

9491
public:
@@ -117,10 +114,8 @@ class OpenACCRoutineDecl final
117114

118115
OpenACCRoutineDecl(unsigned NumClauses)
119116
: OpenACCConstructDecl(OpenACCRoutine) {
120-
std::uninitialized_value_construct(
121-
getTrailingObjects<const OpenACCClause *>(),
122-
getTrailingObjects<const OpenACCClause *>() + NumClauses);
123-
setClauseList(getTrailingObjects<const OpenACCClause *>(NumClauses));
117+
std::uninitialized_value_construct_n(getTrailingObjects(), NumClauses);
118+
setClauseList(getTrailingObjects(NumClauses));
124119
}
125120

126121
OpenACCRoutineDecl(DeclContext *DC, SourceLocation StartLoc,
@@ -134,9 +129,8 @@ class OpenACCRoutineDecl final
134129
assert(LParenLoc.isValid() &&
135130
"Cannot represent implicit name with this declaration");
136131
// Initialize the trailing storage.
137-
llvm::uninitialized_copy(Clauses,
138-
getTrailingObjects<const OpenACCClause *>());
139-
setClauseList(getTrailingObjects<const OpenACCClause *>(Clauses.size()));
132+
llvm::uninitialized_copy(Clauses, getTrailingObjects());
133+
setClauseList(getTrailingObjects(Clauses.size()));
140134
}
141135

142136
public:

clang/include/clang/AST/Expr.h

Lines changed: 36 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,7 +2023,7 @@ class PredefinedExpr final
20232023
void setFunctionName(StringLiteral *SL) {
20242024
assert(hasFunctionName() &&
20252025
"This PredefinedExpr has no storage for a function name!");
2026-
*getTrailingObjects<Stmt *>() = SL;
2026+
*getTrailingObjects() = SL;
20272027
}
20282028

20292029
public:
@@ -2050,13 +2050,13 @@ class PredefinedExpr final
20502050

20512051
StringLiteral *getFunctionName() {
20522052
return hasFunctionName()
2053-
? static_cast<StringLiteral *>(*getTrailingObjects<Stmt *>())
2053+
? static_cast<StringLiteral *>(*getTrailingObjects())
20542054
: nullptr;
20552055
}
20562056

20572057
const StringLiteral *getFunctionName() const {
20582058
return hasFunctionName()
2059-
? static_cast<StringLiteral *>(*getTrailingObjects<Stmt *>())
2059+
? static_cast<StringLiteral *>(*getTrailingObjects())
20602060
: nullptr;
20612061
}
20622062

@@ -2078,13 +2078,11 @@ class PredefinedExpr final
20782078

20792079
// Iterators
20802080
child_range children() {
2081-
return child_range(getTrailingObjects<Stmt *>(),
2082-
getTrailingObjects<Stmt *>() + hasFunctionName());
2081+
return child_range(getTrailingObjects(hasFunctionName()));
20832082
}
20842083

20852084
const_child_range children() const {
2086-
return const_child_range(getTrailingObjects<Stmt *>(),
2087-
getTrailingObjects<Stmt *>() + hasFunctionName());
2085+
return const_child_range(getTrailingObjects(hasFunctionName()));
20882086
}
20892087
};
20902088

@@ -2248,18 +2246,14 @@ class UnaryOperator final
22482246
private llvm::TrailingObjects<UnaryOperator, FPOptionsOverride> {
22492247
Stmt *Val;
22502248

2251-
size_t numTrailingObjects(OverloadToken<FPOptionsOverride>) const {
2252-
return UnaryOperatorBits.HasFPFeatures ? 1 : 0;
2253-
}
2254-
22552249
FPOptionsOverride &getTrailingFPFeatures() {
22562250
assert(UnaryOperatorBits.HasFPFeatures);
2257-
return *getTrailingObjects<FPOptionsOverride>();
2251+
return *getTrailingObjects();
22582252
}
22592253

22602254
const FPOptionsOverride &getTrailingFPFeatures() const {
22612255
assert(UnaryOperatorBits.HasFPFeatures);
2262-
return *getTrailingObjects<FPOptionsOverride>();
2256+
return *getTrailingObjects();
22632257
}
22642258

22652259
public:
@@ -2580,32 +2574,27 @@ class OffsetOfExpr final
25802574
}
25812575

25822576
const OffsetOfNode &getComponent(unsigned Idx) const {
2583-
assert(Idx < NumComps && "Subscript out of range");
2584-
return getTrailingObjects<OffsetOfNode>()[Idx];
2577+
return getTrailingObjects<OffsetOfNode>(NumComps)[Idx];
25852578
}
25862579

25872580
void setComponent(unsigned Idx, OffsetOfNode ON) {
2588-
assert(Idx < NumComps && "Subscript out of range");
2589-
getTrailingObjects<OffsetOfNode>()[Idx] = ON;
2581+
getTrailingObjects<OffsetOfNode>(NumComps)[Idx] = ON;
25902582
}
25912583

25922584
unsigned getNumComponents() const {
25932585
return NumComps;
25942586
}
25952587

25962588
Expr* getIndexExpr(unsigned Idx) {
2597-
assert(Idx < NumExprs && "Subscript out of range");
2598-
return getTrailingObjects<Expr *>()[Idx];
2589+
return getTrailingObjects<Expr *>(NumExprs)[Idx];
25992590
}
26002591

26012592
const Expr *getIndexExpr(unsigned Idx) const {
2602-
assert(Idx < NumExprs && "Subscript out of range");
2603-
return getTrailingObjects<Expr *>()[Idx];
2593+
return getTrailingObjects<Expr *>(NumExprs)[Idx];
26042594
}
26052595

26062596
void setIndexExpr(unsigned Idx, Expr* E) {
2607-
assert(Idx < NumComps && "Subscript out of range");
2608-
getTrailingObjects<Expr *>()[Idx] = E;
2597+
getTrailingObjects<Expr *>(NumComps)[Idx] = E;
26092598
}
26102599

26112600
unsigned getNumExpressions() const {
@@ -4619,12 +4608,12 @@ class ConvertVectorExpr final
46194608

46204609
FPOptionsOverride &getTrailingFPFeatures() {
46214610
assert(ConvertVectorExprBits.HasFPFeatures);
4622-
return *getTrailingObjects<FPOptionsOverride>();
4611+
return *getTrailingObjects();
46234612
}
46244613

46254614
const FPOptionsOverride &getTrailingFPFeatures() const {
46264615
assert(ConvertVectorExprBits.HasFPFeatures);
4627-
return *getTrailingObjects<FPOptionsOverride>();
4616+
return *getTrailingObjects();
46284617
}
46294618

46304619
public:
@@ -5705,13 +5694,11 @@ class DesignatedInitExpr final
57055694
unsigned getNumSubExprs() const { return NumSubExprs; }
57065695

57075696
Expr *getSubExpr(unsigned Idx) const {
5708-
assert(Idx < NumSubExprs && "Subscript out of range");
5709-
return cast<Expr>(getTrailingObjects<Stmt *>()[Idx]);
5697+
return cast<Expr>(getTrailingObjects(NumSubExprs)[Idx]);
57105698
}
57115699

57125700
void setSubExpr(unsigned Idx, Expr *E) {
5713-
assert(Idx < NumSubExprs && "Subscript out of range");
5714-
getTrailingObjects<Stmt *>()[Idx] = E;
5701+
getTrailingObjects(NumSubExprs)[Idx] = E;
57155702
}
57165703

57175704
/// Replaces the designator at index @p Idx with the series
@@ -5730,11 +5717,11 @@ class DesignatedInitExpr final
57305717

57315718
// Iterators
57325719
child_range children() {
5733-
Stmt **begin = getTrailingObjects<Stmt *>();
5720+
Stmt **begin = getTrailingObjects();
57345721
return child_range(begin, begin + NumSubExprs);
57355722
}
57365723
const_child_range children() const {
5737-
Stmt * const *begin = getTrailingObjects<Stmt *>();
5724+
Stmt *const *begin = getTrailingObjects();
57385725
return const_child_range(begin, begin + NumSubExprs);
57395726
}
57405727

@@ -5994,9 +5981,7 @@ class ParenListExpr final
59945981
return const_cast<ParenListExpr *>(this)->getExpr(Init);
59955982
}
59965983

5997-
Expr **getExprs() {
5998-
return reinterpret_cast<Expr **>(getTrailingObjects<Stmt *>());
5999-
}
5984+
Expr **getExprs() { return reinterpret_cast<Expr **>(getTrailingObjects()); }
60005985

60015986
ArrayRef<Expr *> exprs() { return llvm::ArrayRef(getExprs(), getNumExprs()); }
60025987

@@ -6011,12 +5996,10 @@ class ParenListExpr final
60115996

60125997
// Iterators
60135998
child_range children() {
6014-
return child_range(getTrailingObjects<Stmt *>(),
6015-
getTrailingObjects<Stmt *>() + getNumExprs());
5999+
return child_range(getTrailingObjects(getNumExprs()));
60166000
}
60176001
const_child_range children() const {
6018-
return const_child_range(getTrailingObjects<Stmt *>(),
6019-
getTrailingObjects<Stmt *>() + getNumExprs());
6002+
return const_child_range(getTrailingObjects(getNumExprs()));
60206003
}
60216004
};
60226005

@@ -6421,14 +6404,12 @@ class GenericSelectionExpr final
64216404
}
64226405

64236406
child_range children() {
6424-
return child_range(getTrailingObjects<Stmt *>(),
6425-
getTrailingObjects<Stmt *>() +
6426-
numTrailingObjects(OverloadToken<Stmt *>()));
6407+
return child_range(getTrailingObjects<Stmt *>(
6408+
numTrailingObjects(OverloadToken<Stmt *>())));
64276409
}
64286410
const_child_range children() const {
6429-
return const_child_range(getTrailingObjects<Stmt *>(),
6430-
getTrailingObjects<Stmt *>() +
6431-
numTrailingObjects(OverloadToken<Stmt *>()));
6411+
return const_child_range(getTrailingObjects<Stmt *>(
6412+
numTrailingObjects(OverloadToken<Stmt *>())));
64326413
}
64336414
};
64346415

@@ -6647,11 +6628,6 @@ class PseudoObjectExpr final
66476628
// in to Create, which is an index within the semantic forms.
66486629
// Note also that ASTStmtWriter assumes this encoding.
66496630

6650-
Expr **getSubExprsBuffer() { return getTrailingObjects<Expr *>(); }
6651-
const Expr * const *getSubExprsBuffer() const {
6652-
return getTrailingObjects<Expr *>();
6653-
}
6654-
66556631
PseudoObjectExpr(QualType type, ExprValueKind VK,
66566632
Expr *syntactic, ArrayRef<Expr*> semantic,
66576633
unsigned resultIndex);
@@ -6677,8 +6653,8 @@ class PseudoObjectExpr final
66776653
/// Return the syntactic form of this expression, i.e. the
66786654
/// expression it actually looks like. Likely to be expressed in
66796655
/// terms of OpaqueValueExprs bound in the semantic form.
6680-
Expr *getSyntacticForm() { return getSubExprsBuffer()[0]; }
6681-
const Expr *getSyntacticForm() const { return getSubExprsBuffer()[0]; }
6656+
Expr *getSyntacticForm() { return getTrailingObjects()[0]; }
6657+
const Expr *getSyntacticForm() const { return getTrailingObjects()[0]; }
66826658

66836659
/// Return the index of the result-bearing expression into the semantics
66846660
/// expressions, or PseudoObjectExpr::NoResult if there is none.
@@ -6691,7 +6667,7 @@ class PseudoObjectExpr final
66916667
Expr *getResultExpr() {
66926668
if (PseudoObjectExprBits.ResultIndex == 0)
66936669
return nullptr;
6694-
return getSubExprsBuffer()[PseudoObjectExprBits.ResultIndex];
6670+
return getTrailingObjects()[PseudoObjectExprBits.ResultIndex];
66956671
}
66966672
const Expr *getResultExpr() const {
66976673
return const_cast<PseudoObjectExpr*>(this)->getResultExpr();
@@ -6701,29 +6677,26 @@ class PseudoObjectExpr final
67016677

67026678
typedef Expr * const *semantics_iterator;
67036679
typedef const Expr * const *const_semantics_iterator;
6704-
semantics_iterator semantics_begin() {
6705-
return getSubExprsBuffer() + 1;
6706-
}
6680+
semantics_iterator semantics_begin() { return getTrailingObjects() + 1; }
67076681
const_semantics_iterator semantics_begin() const {
6708-
return getSubExprsBuffer() + 1;
6682+
return getTrailingObjects() + 1;
67096683
}
67106684
semantics_iterator semantics_end() {
6711-
return getSubExprsBuffer() + getNumSubExprs();
6685+
return getTrailingObjects() + getNumSubExprs();
67126686
}
67136687
const_semantics_iterator semantics_end() const {
6714-
return getSubExprsBuffer() + getNumSubExprs();
6688+
return getTrailingObjects() + getNumSubExprs();
67156689
}
67166690

67176691
ArrayRef<Expr*> semantics() {
6718-
return ArrayRef(semantics_begin(), semantics_end());
6692+
return getTrailingObjects(getNumSubExprs()).drop_front();
67196693
}
67206694
ArrayRef<const Expr*> semantics() const {
6721-
return ArrayRef(semantics_begin(), semantics_end());
6695+
return getTrailingObjects(getNumSubExprs()).drop_front();
67226696
}
67236697

67246698
Expr *getSemanticExpr(unsigned index) {
6725-
assert(index + 1 < getNumSubExprs());
6726-
return getSubExprsBuffer()[index + 1];
6699+
return getTrailingObjects(getNumSubExprs())[index + 1];
67276700
}
67286701
const Expr *getSemanticExpr(unsigned index) const {
67296702
return const_cast<PseudoObjectExpr*>(this)->getSemanticExpr(index);
@@ -6748,7 +6721,7 @@ class PseudoObjectExpr final
67486721
}
67496722
const_child_range children() const {
67506723
Stmt *const *cs = const_cast<Stmt *const *>(
6751-
reinterpret_cast<const Stmt *const *>(getSubExprsBuffer()));
6724+
reinterpret_cast<const Stmt *const *>(getTrailingObjects()));
67526725
return const_child_range(cs, cs + getNumSubExprs());
67536726
}
67546727

0 commit comments

Comments
 (0)