Skip to content

Commit e499598

Browse files
qinkunbaovitalybuka
authored andcommitted
rebase
Created using spr 1.3.6
2 parents 117144c + b2f90f5 commit e499598

File tree

224 files changed

+7732
-1940
lines changed

Some content is hidden

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

224 files changed

+7732
-1940
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/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
@@ -558,6 +558,9 @@ Improvements to Clang's diagnostics
558558
between different Unicode character types (``char8_t``, ``char16_t``, ``char32_t``).
559559
This warning only triggers in C++ as these types are aliases in C. (#GH138526)
560560

561+
- Fixed a crash when checking a ``__thread``-specified variable declaration
562+
with a dependent type in C++. (#GH140509)
563+
561564
Improvements to Clang's time-trace
562565
----------------------------------
563566

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

745750
Bug Fixes to AST Handling
746751
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/DeclFriend.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ class FriendDecl final
9090
: Decl(Decl::Friend, DC, L), Friend(Friend), FriendLoc(FriendL),
9191
EllipsisLoc(EllipsisLoc), UnsupportedFriend(false),
9292
NumTPLists(FriendTypeTPLists.size()) {
93-
for (unsigned i = 0; i < NumTPLists; ++i)
94-
getTrailingObjects<TemplateParameterList *>()[i] = FriendTypeTPLists[i];
93+
llvm::copy(FriendTypeTPLists, getTrailingObjects());
9594
}
9695

9796
FriendDecl(EmptyShell Empty, unsigned NumFriendTypeTPLists)
@@ -132,8 +131,7 @@ class FriendDecl final
132131
}
133132

134133
TemplateParameterList *getFriendTypeTemplateParameterList(unsigned N) const {
135-
assert(N < NumTPLists);
136-
return getTrailingObjects<TemplateParameterList *>()[N];
134+
return getTrailingObjects(NumTPLists)[N];
137135
}
138136

139137
/// If this friend declaration doesn't name a type, return the inner
@@ -153,10 +151,9 @@ class FriendDecl final
153151
/// Retrieves the source range for the friend declaration.
154152
SourceRange getSourceRange() const override LLVM_READONLY {
155153
if (TypeSourceInfo *TInfo = getFriendType()) {
156-
SourceLocation StartL =
157-
(NumTPLists == 0) ? getFriendLoc()
158-
: getTrailingObjects<TemplateParameterList *>()[0]
159-
->getTemplateLoc();
154+
SourceLocation StartL = (NumTPLists == 0)
155+
? getFriendLoc()
156+
: getTrailingObjects()[0]->getTemplateLoc();
160157
SourceLocation EndL = isPackExpansion() ? getEllipsisLoc()
161158
: TInfo->getTypeLoc().getEndLoc();
162159
return SourceRange(StartL, EndL);

clang/include/clang/AST/DeclGroup.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,10 @@ class DeclGroup final : private llvm::TrailingObjects<DeclGroup, Decl *> {
3737

3838
unsigned size() const { return NumDecls; }
3939

40-
Decl*& operator[](unsigned i) {
41-
assert (i < NumDecls && "Out-of-bounds access.");
42-
return getTrailingObjects<Decl *>()[i];
43-
}
40+
Decl *&operator[](unsigned i) { return getTrailingObjects(NumDecls)[i]; }
4441

4542
Decl* const& operator[](unsigned i) const {
46-
assert (i < NumDecls && "Out-of-bounds access.");
47-
return getTrailingObjects<Decl *>()[i];
43+
return getTrailingObjects(NumDecls)[i];
4844
}
4945
};
5046

clang/include/clang/AST/DeclObjC.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ class ObjCTypeParamList final
678678
/// Iterate through the type parameters in the list.
679679
using iterator = ObjCTypeParamDecl **;
680680

681-
iterator begin() { return getTrailingObjects<ObjCTypeParamDecl *>(); }
681+
iterator begin() { return getTrailingObjects(); }
682682

683683
iterator end() { return begin() + size(); }
684684

@@ -688,9 +688,7 @@ class ObjCTypeParamList final
688688
// Iterate through the type parameters in the list.
689689
using const_iterator = ObjCTypeParamDecl * const *;
690690

691-
const_iterator begin() const {
692-
return getTrailingObjects<ObjCTypeParamDecl *>();
693-
}
691+
const_iterator begin() const { return getTrailingObjects(); }
694692

695693
const_iterator end() const {
696694
return begin() + size();

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:

0 commit comments

Comments
 (0)