Skip to content

Commit d4018db

Browse files
committed
Rebase, address comments
Created using spr 1.3.5
2 parents df8afc9 + 38cb693 commit d4018db

File tree

1,268 files changed

+29064
-38451
lines changed

Some content is hidden

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

1,268 files changed

+29064
-38451
lines changed

.github/workflows/release-binaries.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,6 @@ jobs:
226226
id: setup-stage
227227
uses: ./workflows-main/.github/workflows/release-binaries-setup-stage
228228

229-
- name: Setup sccache
230-
uses: hendrikmuhs/ccache-action@ca3acd2731eef11f1572ccb126356c2f9298d35e # v1.2.9
231-
with:
232-
# Default to 2G to workaround: https://github.com/hendrikmuhs/ccache-action/issues/174
233-
max-size: 2G
234-
key: ${{ needs.prepare.outputs.ccache }}-${{ runner.os }}-${{ runner.arch }}-release
235-
variant: ${{ needs.prepare.outputs.ccache }}
236-
237229
- name: Configure
238230
id: build
239231
shell: bash
@@ -246,9 +238,8 @@ jobs:
246238
${{ needs.prepare.outputs.target-cmake-flags }} \
247239
-C clang/cmake/caches/Release.cmake \
248240
-DBOOTSTRAP_LLVM_PARALLEL_LINK_JOBS=1 \
249-
-DBOOTSTRAP_CPACK_PACKAGE_FILE_NAME="${{ needs.prepare.outputs.release-binary-basename }}" \
250-
-DCMAKE_C_COMPILER_LAUNCHER=$CCACHE_BIN \
251-
-DCMAKE_CXX_COMPILER_LAUNCHER=$CCACHE_BIN
241+
-DBOOTSTRAP_CPACK_PACKAGE_FILE_NAME="${{ needs.prepare.outputs.release-binary-basename }}"
242+
252243
- name: Build
253244
shell: bash
254245
run: |

bolt/test/AArch64/pad-before-funcs.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# RUN: llvm-bolt %t.exe -o %t.bolt.4.4 --pad-funcs-before=_start:4 --pad-funcs=_start:4
1616
# RUN: llvm-bolt %t.exe -o %t.bolt.4.8 --pad-funcs-before=_start:4 --pad-funcs=_start:8
1717

18-
# RUN: not llvm-bolt %t.exe -o %t.bolt.8 --pad-funcs-before=_start:1 2>&1 | FileCheck --check-prefix=CHECK-BAD-ALIGN %s
18+
# RUN: not llvm-bolt %t.exe -o %t.bolt.1 --pad-funcs-before=_start:1 2>&1 | FileCheck --check-prefix=CHECK-BAD-ALIGN %s
1919

2020
# CHECK-BAD-ALIGN: user-requested 1 padding bytes before function _start(*2) is not a multiple of the minimum function alignment (4).
2121

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

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,32 @@ void UnsafeFunctionsCheck::registerMatchers(MatchFinder *Finder) {
256256
.bind(CustomFunctionNamesId)))
257257
.bind(DeclRefId),
258258
this);
259+
// C++ member calls do not contain a DeclRefExpr to the function decl.
260+
// Instead, they contain a MemberExpr that refers to the decl.
261+
Finder->addMatcher(memberExpr(member(functionDecl(CustomFunctionsMatcher)
262+
.bind(CustomFunctionNamesId)))
263+
.bind(DeclRefId),
264+
this);
259265
}
260266
}
261267

262268
void UnsafeFunctionsCheck::check(const MatchFinder::MatchResult &Result) {
263-
const auto *DeclRef = Result.Nodes.getNodeAs<DeclRefExpr>(DeclRefId);
264-
const auto *FuncDecl = cast<FunctionDecl>(DeclRef->getDecl());
265-
assert(DeclRef && FuncDecl && "No valid matched node in check()");
269+
const Expr *SourceExpr;
270+
const FunctionDecl *FuncDecl;
271+
272+
if (const auto *DeclRef = Result.Nodes.getNodeAs<DeclRefExpr>(DeclRefId)) {
273+
SourceExpr = DeclRef;
274+
FuncDecl = cast<FunctionDecl>(DeclRef->getDecl());
275+
} else if (const auto *Member =
276+
Result.Nodes.getNodeAs<MemberExpr>(DeclRefId)) {
277+
SourceExpr = Member;
278+
FuncDecl = cast<FunctionDecl>(Member->getMemberDecl());
279+
} else {
280+
llvm_unreachable("No valid matched node in check()");
281+
return;
282+
}
283+
284+
assert(SourceExpr && FuncDecl && "No valid matched node in check()");
266285

267286
// Only one of these are matched at a time.
268287
const auto *AnnexK = Result.Nodes.getNodeAs<FunctionDecl>(
@@ -286,14 +305,15 @@ void UnsafeFunctionsCheck::check(const MatchFinder::MatchResult &Result) {
286305
Entry.Reason.empty() ? "is marked as unsafe" : Entry.Reason.c_str();
287306

288307
if (Entry.Replacement.empty()) {
289-
diag(DeclRef->getExprLoc(), "function %0 %1; it should not be used")
308+
diag(SourceExpr->getExprLoc(),
309+
"function %0 %1; it should not be used")
290310
<< FuncDecl << Reason << Entry.Replacement
291-
<< DeclRef->getSourceRange();
311+
<< SourceExpr->getSourceRange();
292312
} else {
293-
diag(DeclRef->getExprLoc(),
313+
diag(SourceExpr->getExprLoc(),
294314
"function %0 %1; '%2' should be used instead")
295315
<< FuncDecl << Reason << Entry.Replacement
296-
<< DeclRef->getSourceRange();
316+
<< SourceExpr->getSourceRange();
297317
}
298318

299319
return;
@@ -323,9 +343,9 @@ void UnsafeFunctionsCheck::check(const MatchFinder::MatchResult &Result) {
323343
if (!ReplacementFunctionName)
324344
return;
325345

326-
diag(DeclRef->getExprLoc(), "function %0 %1; '%2' should be used instead")
346+
diag(SourceExpr->getExprLoc(), "function %0 %1; '%2' should be used instead")
327347
<< FuncDecl << getRationaleFor(FunctionName)
328-
<< ReplacementFunctionName.value() << DeclRef->getSourceRange();
348+
<< ReplacementFunctionName.value() << SourceExpr->getSourceRange();
329349
}
330350

331351
void UnsafeFunctionsCheck::registerPPCallbacks(

clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class UnsafeFunctionsCheck : public ClangTidyCheck {
4343
private:
4444
const std::vector<CheckedFunction> CustomFunctions;
4545

46-
// If true, the default set of functions are reported.
46+
/// If true, the default set of functions are reported.
4747
const bool ReportDefaultFunctions;
4848
/// If true, additional functions from widely used API-s (such as POSIX) are
4949
/// added to the list of reported functions.

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ New check aliases
9797
Changes in existing checks
9898
^^^^^^^^^^^^^^^^^^^^^^^^^^
9999

100+
- Improved :doc:`bugprone-unsafe-functions
101+
<clang-tidy/checks/bugprone/unsafe-functions>` check to allow specifying
102+
additional C++ member functions to match.
103+
100104
Removed checks
101105
^^^^^^^^^^^^^^
102106

clang-tools-extra/docs/clang-tidy/checks/bugprone/assert-side-effect.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ Options
2626

2727
A semicolon-separated list of the names of functions or methods to be
2828
considered as not having side-effects. Regular expressions are accepted,
29-
e.g. `[Rr]ef(erence)?$` matches every type with suffix `Ref`, `ref`,
30-
`Reference` and `reference`. The default is empty. If a name in the list
31-
contains the sequence `::` it is matched against the qualified typename
32-
(i.e. `namespace::Type`, otherwise it is matched against only
33-
the type name (i.e. `Type`).
29+
e.g. ``[Rr]ef(erence)?$`` matches every type with suffix ``Ref``, ``ref``,
30+
``Reference`` and ``reference``. The default is empty. If a name in the list
31+
contains the sequence `::` it is matched against the qualified type name
32+
(i.e. ``namespace::Type``), otherwise it is matched against only
33+
the type name (i.e. ``Type``).

clang-tools-extra/docs/clang-tidy/checks/bugprone/unsafe-functions.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,17 @@ qualified name (i.e. ``std::original``), otherwise the regex is matched against
114114
If the regular expression starts with `::` (or `^::`), it is matched against the
115115
fully qualified name (``::std::original``).
116116

117+
.. note::
118+
119+
Fully qualified names can contain template parameters on certain C++ classes, but not on C++ functions.
120+
Type aliases are resolved before matching.
121+
122+
As an example, the member function ``open`` in the class ``std::ifstream``
123+
has a fully qualified name of ``::std::basic_ifstream<char>::open``.
124+
125+
The example could also be matched with the regex ``::std::basic_ifstream<[^>]*>::open``, which matches all potential
126+
template parameters, but does not match nested template classes.
127+
117128
Options
118129
-------
119130

clang-tools-extra/docs/clang-tidy/checks/performance/for-range-copy.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ Options
2323

2424
.. option:: WarnOnAllAutoCopies
2525

26-
When `true`, warns on any use of `auto` as the type of the range-based for
26+
When `true`, warns on any use of ``auto`` as the type of the range-based for
2727
loop variable. Default is `false`.
2828

2929
.. option:: AllowedTypes
3030

3131
A semicolon-separated list of names of types allowed to be copied in each
32-
iteration. Regular expressions are accepted, e.g. `[Rr]ef(erence)?$` matches
33-
every type with suffix `Ref`, `ref`, `Reference` and `reference`. The default
34-
is empty. If a name in the list contains the sequence `::` it is matched
35-
against the qualified typename (i.e. `namespace::Type`, otherwise it is
36-
matched against only the type name (i.e. `Type`).
32+
iteration. Regular expressions are accepted, e.g. ``[Rr]ef(erence)?$``
33+
matches every type with suffix ``Ref``, ``ref``, ``Reference`` and
34+
``reference``. The default is empty. If a name in the list contains the
35+
sequence `::`, it is matched against the qualified type name
36+
(i.e. ``namespace::Type``), otherwise it is matched against only the
37+
type name (i.e. ``Type``).

clang-tools-extra/docs/clang-tidy/checks/performance/unnecessary-copy-initialization.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ Options
4242
.. option:: AllowedTypes
4343

4444
A semicolon-separated list of names of types allowed to be initialized by
45-
copying. Regular expressions are accepted, e.g. `[Rr]ef(erence)?$` matches
46-
every type with suffix `Ref`, `ref`, `Reference` and `reference`. The default
47-
is empty. If a name in the list contains the sequence `::` it is matched
48-
against the qualified typename (i.e. `namespace::Type`, otherwise it is
49-
matched against only the type name (i.e. `Type`).
45+
copying. Regular expressions are accepted, e.g. ``[Rr]ef(erence)?$`` matches
46+
every type with suffix ``Ref``, ``ref``, ``Reference`` and ``reference``.
47+
The default is empty. If a name in the list contains the sequence `::`, it
48+
is matched against the qualified type name (i.e. ``namespace::Type``),
49+
otherwise it is matched against only the type name (i.e. ``Type``).
5050

5151
.. option:: ExcludedContainerTypes
5252

clang-tools-extra/docs/clang-tidy/checks/performance/unnecessary-value-param.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ Options
6565
.. option:: AllowedTypes
6666

6767
A semicolon-separated list of names of types allowed to be passed by value.
68-
Regular expressions are accepted, e.g. `[Rr]ef(erence)?$` matches every type
69-
with suffix `Ref`, `ref`, `Reference` and `reference`. The default is
70-
empty. If a name in the list contains the sequence `::` it is matched against
71-
the qualified typename (i.e. `namespace::Type`, otherwise it is matched
72-
against only the type name (i.e. `Type`).
68+
Regular expressions are accepted, e.g. ``[Rr]ef(erence)?$`` matches every
69+
type with suffix ``Ref``, ``ref``, ``Reference`` and ``reference``. The
70+
default is empty. If a name in the list contains the sequence `::`, it is
71+
matched against the qualified type name (i.e. ``namespace::Type``),
72+
otherwise it is matched against only the type name (i.e. ``Type``).

0 commit comments

Comments
 (0)