Skip to content

Commit 3e2f70e

Browse files
committed
Merge branch 'fix/116928' of https://github.com/a-tarasyuk/llvm-project into fix/116928
2 parents 905be9c + b84db52 commit 3e2f70e

File tree

747 files changed

+35861
-21808
lines changed

Some content is hidden

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

747 files changed

+35861
-21808
lines changed

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,6 @@ concurrency:
3333
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
3434
cancel-in-progress: true
3535

36-
37-
env:
38-
# LLVM POST-BRANCH bump version
39-
# LLVM POST-BRANCH add compiler test for ToT - 1, e.g. "Clang 17"
40-
# LLVM RELEASE bump remove compiler ToT - 3, e.g. "Clang 15"
41-
LLVM_HEAD_VERSION: "19" # Used compiler, update POST-BRANCH.
42-
LLVM_PREVIOUS_VERSION: "18"
43-
LLVM_OLDEST_VERSION: "17"
44-
GCC_STABLE_VERSION: "13"
45-
LLVM_SYMBOLIZER_PATH: "/usr/bin/llvm-symbolizer-19"
46-
CLANG_CRASH_DIAGNOSTICS_DIR: "crash_diagnostics"
47-
4836
jobs:
4937
stage1:
5038
if: github.repository_owner == 'llvm'

bolt/unittests/Core/MCPlusBuilder.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,14 @@ INSTANTIATE_TEST_SUITE_P(AArch64, MCPlusBuilderTester,
9090
::testing::Values(Triple::aarch64));
9191

9292
TEST_P(MCPlusBuilderTester, AliasX0) {
93-
uint64_t AliasesX0[] = {AArch64::W0, AArch64::W0_HI,
94-
AArch64::X0, AArch64::W0_W1,
93+
uint64_t AliasesX0[] = {AArch64::W0, AArch64::X0, AArch64::W0_W1,
9594
AArch64::X0_X1, AArch64::X0_X1_X2_X3_X4_X5_X6_X7};
9695
size_t AliasesX0Count = sizeof(AliasesX0) / sizeof(*AliasesX0);
9796
testRegAliases(Triple::aarch64, AArch64::X0, AliasesX0, AliasesX0Count);
9897
}
9998

10099
TEST_P(MCPlusBuilderTester, AliasSmallerX0) {
101-
uint64_t AliasesX0[] = {AArch64::W0, AArch64::W0_HI, AArch64::X0};
100+
uint64_t AliasesX0[] = {AArch64::W0, AArch64::X0};
102101
size_t AliasesX0Count = sizeof(AliasesX0) / sizeof(*AliasesX0);
103102
testRegAliases(Triple::aarch64, AArch64::X0, AliasesX0, AliasesX0Count, true);
104103
}

clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ void InfiniteLoopCheck::check(const MatchFinder::MatchResult &Result) {
303303
}
304304
}
305305

306-
if (ExprMutationAnalyzer::isUnevaluated(LoopStmt, *LoopStmt, *Result.Context))
306+
if (ExprMutationAnalyzer::isUnevaluated(LoopStmt, *Result.Context))
307307
return;
308308

309309
if (isAtLeastOneCondVarChanged(Func, LoopStmt, Cond, Result.Context))

clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidConstOrRefDataMembersCheck.cpp

Lines changed: 67 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -13,79 +13,88 @@
1313
using namespace clang::ast_matchers;
1414

1515
namespace clang::tidy::cppcoreguidelines {
16-
namespace {
1716

18-
AST_MATCHER(FieldDecl, isMemberOfLambda) {
19-
return Node.getParent()->isLambda();
17+
static bool isCopyConstructible(CXXRecordDecl const &Node) {
18+
if (Node.needsOverloadResolutionForCopyConstructor() &&
19+
Node.needsImplicitCopyConstructor()) {
20+
// unresolved
21+
for (CXXBaseSpecifier const &BS : Node.bases()) {
22+
CXXRecordDecl const *BRD = BS.getType()->getAsCXXRecordDecl();
23+
if (BRD != nullptr && !isCopyConstructible(*BRD))
24+
return false;
25+
}
26+
}
27+
if (Node.hasSimpleCopyConstructor())
28+
return true;
29+
for (CXXConstructorDecl const *Ctor : Node.ctors())
30+
if (Ctor->isCopyConstructor())
31+
return !Ctor->isDeleted();
32+
return false;
2033
}
2134

22-
struct MemberFunctionInfo {
23-
bool Declared{};
24-
bool Deleted{};
25-
};
26-
27-
struct MemberFunctionPairInfo {
28-
MemberFunctionInfo Copy{};
29-
MemberFunctionInfo Move{};
30-
};
31-
32-
MemberFunctionPairInfo getConstructorsInfo(CXXRecordDecl const &Node) {
33-
MemberFunctionPairInfo Constructors{};
34-
35-
for (CXXConstructorDecl const *Ctor : Node.ctors()) {
36-
if (Ctor->isCopyConstructor()) {
37-
Constructors.Copy.Declared = true;
38-
if (Ctor->isDeleted())
39-
Constructors.Copy.Deleted = true;
40-
}
41-
if (Ctor->isMoveConstructor()) {
42-
Constructors.Move.Declared = true;
43-
if (Ctor->isDeleted())
44-
Constructors.Move.Deleted = true;
35+
static bool isMoveConstructible(CXXRecordDecl const &Node) {
36+
if (Node.needsOverloadResolutionForMoveConstructor() &&
37+
Node.needsImplicitMoveConstructor()) {
38+
// unresolved
39+
for (CXXBaseSpecifier const &BS : Node.bases()) {
40+
CXXRecordDecl const *BRD = BS.getType()->getAsCXXRecordDecl();
41+
if (BRD != nullptr && !isMoveConstructible(*BRD))
42+
return false;
4543
}
4644
}
47-
48-
return Constructors;
45+
if (Node.hasSimpleMoveConstructor())
46+
return true;
47+
for (CXXConstructorDecl const *Ctor : Node.ctors())
48+
if (Ctor->isMoveConstructor())
49+
return !Ctor->isDeleted();
50+
return false;
4951
}
5052

51-
MemberFunctionPairInfo getAssignmentsInfo(CXXRecordDecl const &Node) {
52-
MemberFunctionPairInfo Assignments{};
53-
54-
for (CXXMethodDecl const *Method : Node.methods()) {
55-
if (Method->isCopyAssignmentOperator()) {
56-
Assignments.Copy.Declared = true;
57-
if (Method->isDeleted())
58-
Assignments.Copy.Deleted = true;
53+
static bool isCopyAssignable(CXXRecordDecl const &Node) {
54+
if (Node.needsOverloadResolutionForCopyAssignment() &&
55+
Node.needsImplicitCopyAssignment()) {
56+
// unresolved
57+
for (CXXBaseSpecifier const &BS : Node.bases()) {
58+
CXXRecordDecl const *BRD = BS.getType()->getAsCXXRecordDecl();
59+
if (BRD != nullptr && !isCopyAssignable(*BRD))
60+
return false;
5961
}
62+
}
63+
if (Node.hasSimpleCopyAssignment())
64+
return true;
65+
for (CXXMethodDecl const *Method : Node.methods())
66+
if (Method->isCopyAssignmentOperator())
67+
return !Method->isDeleted();
68+
return false;
69+
}
6070

61-
if (Method->isMoveAssignmentOperator()) {
62-
Assignments.Move.Declared = true;
63-
if (Method->isDeleted())
64-
Assignments.Move.Deleted = true;
71+
static bool isMoveAssignable(CXXRecordDecl const &Node) {
72+
if (Node.needsOverloadResolutionForMoveAssignment() &&
73+
Node.needsImplicitMoveAssignment()) {
74+
// unresolved
75+
for (CXXBaseSpecifier const &BS : Node.bases()) {
76+
CXXRecordDecl const *BRD = BS.getType()->getAsCXXRecordDecl();
77+
if (BRD != nullptr && !isMoveAssignable(*BRD))
78+
return false;
6579
}
6680
}
67-
68-
return Assignments;
81+
if (Node.hasSimpleMoveAssignment())
82+
return true;
83+
for (CXXMethodDecl const *Method : Node.methods())
84+
if (Method->isMoveAssignmentOperator())
85+
return !Method->isDeleted();
86+
return false;
6987
}
7088

71-
AST_MATCHER(CXXRecordDecl, isCopyableOrMovable) {
72-
MemberFunctionPairInfo Constructors = getConstructorsInfo(Node);
73-
MemberFunctionPairInfo Assignments = getAssignmentsInfo(Node);
89+
namespace {
7490

75-
if (Node.hasSimpleCopyConstructor() ||
76-
(Constructors.Copy.Declared && !Constructors.Copy.Deleted))
77-
return true;
78-
if (Node.hasSimpleMoveConstructor() ||
79-
(Constructors.Move.Declared && !Constructors.Move.Deleted))
80-
return true;
81-
if (Node.hasSimpleCopyAssignment() ||
82-
(Assignments.Copy.Declared && !Assignments.Copy.Deleted))
83-
return true;
84-
if (Node.hasSimpleMoveAssignment() ||
85-
(Assignments.Move.Declared && !Assignments.Move.Deleted))
86-
return true;
91+
AST_MATCHER(FieldDecl, isMemberOfLambda) {
92+
return Node.getParent()->isLambda();
93+
}
8794

88-
return false;
95+
AST_MATCHER(CXXRecordDecl, isCopyableOrMovable) {
96+
return isCopyConstructible(Node) || isMoveConstructible(Node) ||
97+
isCopyAssignable(Node) || isMoveAssignable(Node);
8998
}
9099

91100
} // namespace

clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88

99
#include "UseInternalLinkageCheck.h"
1010
#include "../utils/FileExtensionsUtils.h"
11-
#include "../utils/LexerUtils.h"
1211
#include "clang/AST/Decl.h"
1312
#include "clang/ASTMatchers/ASTMatchFinder.h"
1413
#include "clang/ASTMatchers/ASTMatchers.h"
1514
#include "clang/ASTMatchers/ASTMatchersMacros.h"
1615
#include "clang/Basic/SourceLocation.h"
1716
#include "clang/Basic/Specifiers.h"
18-
#include "clang/Basic/TokenKinds.h"
1917
#include "clang/Lex/Token.h"
2018
#include "llvm/ADT/STLExtras.h"
2119

@@ -47,6 +45,8 @@ namespace {
4745

4846
AST_MATCHER(Decl, isFirstDecl) { return Node.isFirstDecl(); }
4947

48+
AST_MATCHER(FunctionDecl, hasBody) { return Node.hasBody(); }
49+
5050
static bool isInMainFile(SourceLocation L, SourceManager &SM,
5151
const FileExtensionsSet &HeaderFileExtensions) {
5252
for (;;) {
@@ -103,7 +103,7 @@ void UseInternalLinkageCheck::registerMatchers(MatchFinder *Finder) {
103103
// 4. friend
104104
hasAncestor(friendDecl()))));
105105
Finder->addMatcher(
106-
functionDecl(Common, unless(cxxMethodDecl()), unless(isMain()))
106+
functionDecl(Common, hasBody(), unless(cxxMethodDecl()), unless(isMain()))
107107
.bind("fn"),
108108
this);
109109
Finder->addMatcher(varDecl(Common, hasGlobalStorage()).bind("var"), this);

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ Changes in existing checks
207207
fix false positive that floating point variable is only used in increment
208208
expression.
209209

210+
- Improved :doc:`cppcoreguidelines-avoid-const-or-ref-data-members
211+
<clang-tidy/checks/cppcoreguidelines/avoid-const-or-ref-data-members>` check to
212+
avoid false positives when detecting a templated class with inheritance.
213+
210214
- Improved :doc:`cppcoreguidelines-init-variables
211215
<clang-tidy/checks/cppcoreguidelines/init-variables>` check by fixing the
212216
insertion location for function pointers.
@@ -228,6 +232,11 @@ Changes in existing checks
228232
<clang-tidy/checks/misc/unconventional-assign-operator>` check to avoid
229233
false positive for C++23 deducing this.
230234

235+
- Improved :doc:`misc-use-internal-linkage
236+
<clang-tidy/checks/misc/use-internal-linkage>` check to insert ``static``
237+
keyword before type qualifiers such as ``const`` and ``volatile`` and fix
238+
false positives for function declaration without body.
239+
231240
- Improved :doc:`modernize-avoid-c-arrays
232241
<clang-tidy/checks/modernize/avoid-c-arrays>` check to suggest using
233242
``std::span`` as a replacement for parameters of incomplete C array type in
@@ -237,10 +246,6 @@ Changes in existing checks
237246
<clang-tidy/checks/modernize/loop-convert>` check to fix false positive when
238247
using loop variable in initializer of lambda capture.
239248

240-
- Improved :doc:`misc-use-internal-linkage
241-
<clang-tidy/checks/misc/use-internal-linkage>` check to insert ``static`` keyword
242-
before type qualifiers such as ``const`` and ``volatile``.
243-
244249
- Improved :doc:`modernize-min-max-use-initializer-list
245250
<clang-tidy/checks/modernize/min-max-use-initializer-list>` check by fixing
246251
a false positive when only an implicit conversion happened inside an

clang-tools-extra/docs/clang-tidy/checks/misc/use-internal-linkage.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Example:
1616

1717
int v1; // can be marked as static
1818

19-
void fn1(); // can be marked as static
19+
void fn1() {} // can be marked as static
2020

2121
namespace {
2222
// already in anonymous namespace
@@ -26,6 +26,9 @@ Example:
2626
// already declared as extern
2727
extern int v2;
2828

29+
void fn3(); // without function body in all declaration, maybe external linkage
30+
void fn3();
31+
2932
Options
3033
-------
3134

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-const-or-ref-data-members.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,28 @@ struct InheritBothFromNonCopyableAndNonMovable : NonCopyable, NonMovable
285285
int& x; // OK, non copyable nor movable
286286
};
287287

288+
template<class T> struct TemplateInheritFromNonCopyable : NonCopyable
289+
{
290+
int& x;
291+
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: member 'x' of type 'int &' is a reference
292+
};
293+
294+
template<class T> struct TemplateInheritFromNonMovable : NonMovable
295+
{
296+
int& x;
297+
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: member 'x' of type 'int &' is a reference
298+
};
299+
300+
template<class T> struct TemplateInheritFromNonCopyableNonMovable : NonCopyableNonMovable
301+
{
302+
int& x; // OK, non copyable nor movable
303+
};
304+
305+
template<class T> struct TemplateInheritBothFromNonCopyableAndNonMovable : NonCopyable, NonMovable
306+
{
307+
int& x; // OK, non copyable nor movable
308+
};
309+
288310
// Test composition
289311
struct ContainsNonCopyable
290312
{

0 commit comments

Comments
 (0)