Skip to content

Commit 6e97273

Browse files
authored
Merge branch 'main' into fix/117385
2 parents cf8a1d6 + db6f627 commit 6e97273

File tree

952 files changed

+51762
-19802
lines changed

Some content is hidden

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

952 files changed

+51762
-19802
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/utils/bughunter.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ if [[ $FAIL -eq "0" ]]; then
131131
fi
132132
else
133133
echo "Did it pass? Type the return code [0 = pass, 1 = fail]"
134-
read -n1 PASS
134+
read -n1 FAIL
135135
fi
136136
if [[ $FAIL -eq "0" ]] ; then
137137
echo " Warning: optimized binary passes."
@@ -205,7 +205,7 @@ while [[ "$CONTINUE" -ne "0" ]] ; do
205205
echo " OPTIMIZED_BINARY failure=$FAIL"
206206
else
207207
echo "Did it pass? Type the return code [0 = pass, 1 = fail]"
208-
read -n1 PASS
208+
read -n1 FAIL
209209
fi
210210
else
211211
FAIL=1

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/clangd/refactor/tweaks/DefineOutline.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -467,18 +467,9 @@ class DefineOutline : public Tweak {
467467
}
468468
}
469469

470-
// For function templates, the same limitations as for class templates
471-
// apply.
472-
if (const TemplateParameterList *Params =
473-
MD->getDescribedTemplateParams()) {
474-
// FIXME: Is this really needed? It inhibits application on
475-
// e.g. std::enable_if.
476-
for (NamedDecl *P : *Params) {
477-
if (!P->getIdentifier())
478-
return false;
479-
}
470+
// Function templates must be defined in the same file.
471+
if (MD->getDescribedTemplate())
480472
SameFile = true;
481-
}
482473

483474
// The refactoring is meaningless for unnamed classes and namespaces,
484475
// unless we're outlining in the same file

clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,6 @@ TEST_F(DefineOutlineTest, TriggersOnFunctionDecl) {
118118
template <> void fo^o<int>() {}
119119
)cpp");
120120

121-
// Not available on member function templates with unnamed template
122-
// parameters.
123-
EXPECT_UNAVAILABLE(R"cpp(
124-
struct Foo { template <typename> void ba^r() {} };
125-
)cpp");
126-
127121
// Not available on methods of unnamed classes.
128122
EXPECT_UNAVAILABLE(R"cpp(
129123
struct Foo {
@@ -410,14 +404,14 @@ inline typename O1<T, U...>::template O2<V, A>::E O1<T, U...>::template O2<V, A>
410404
{
411405
R"cpp(
412406
struct Foo {
413-
template <typename T, bool B = true>
407+
template <typename T, typename, bool B = true>
414408
T ^bar() { return {}; }
415409
};)cpp",
416410
R"cpp(
417411
struct Foo {
418-
template <typename T, bool B = true>
412+
template <typename T, typename, bool B = true>
419413
T bar() ;
420-
};template <typename T, bool B>
414+
};template <typename T, typename, bool B>
421415
inline T Foo::bar() { return {}; }
422416
)cpp",
423417
""},
@@ -426,13 +420,13 @@ inline T Foo::bar() { return {}; }
426420
{
427421
R"cpp(
428422
template <typename T> struct Foo {
429-
template <typename U> T ^bar(const T& t, const U& u) { return {}; }
423+
template <typename U, bool> T ^bar(const T& t, const U& u) { return {}; }
430424
};)cpp",
431425
R"cpp(
432426
template <typename T> struct Foo {
433-
template <typename U> T bar(const T& t, const U& u) ;
427+
template <typename U, bool> T bar(const T& t, const U& u) ;
434428
};template <typename T>
435-
template <typename U>
429+
template <typename U, bool>
436430
inline T Foo<T>::bar(const T& t, const U& u) { return {}; }
437431
)cpp",
438432
""},

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ Hover
7373
Code completion
7474
^^^^^^^^^^^^^^^
7575

76+
- Added completion for C++20 keywords.
77+
7678
Code actions
7779
^^^^^^^^^^^^
7880

@@ -207,6 +209,10 @@ Changes in existing checks
207209
fix false positive that floating point variable is only used in increment
208210
expression.
209211

212+
- Improved :doc:`cppcoreguidelines-avoid-const-or-ref-data-members
213+
<clang-tidy/checks/cppcoreguidelines/avoid-const-or-ref-data-members>` check to
214+
avoid false positives when detecting a templated class with inheritance.
215+
210216
- Improved :doc:`cppcoreguidelines-init-variables
211217
<clang-tidy/checks/cppcoreguidelines/init-variables>` check by fixing the
212218
insertion location for function pointers.
@@ -228,6 +234,11 @@ Changes in existing checks
228234
<clang-tidy/checks/misc/unconventional-assign-operator>` check to avoid
229235
false positive for C++23 deducing this.
230236

237+
- Improved :doc:`misc-use-internal-linkage
238+
<clang-tidy/checks/misc/use-internal-linkage>` check to insert ``static``
239+
keyword before type qualifiers such as ``const`` and ``volatile`` and fix
240+
false positives for function declaration without body.
241+
231242
- Improved :doc:`modernize-avoid-c-arrays
232243
<clang-tidy/checks/modernize/avoid-c-arrays>` check to suggest using
233244
``std::span`` as a replacement for parameters of incomplete C array type in
@@ -237,10 +248,6 @@ Changes in existing checks
237248
<clang-tidy/checks/modernize/loop-convert>` check to fix false positive when
238249
using loop variable in initializer of lambda capture.
239250

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-
244251
- Improved :doc:`modernize-min-max-use-initializer-list
245252
<clang-tidy/checks/modernize/min-max-use-initializer-list>` check by fixing
246253
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)