Skip to content

Commit bf64a8f

Browse files
committed
[AutoBump] Merge with e7e72a9 (Jan 30)
2 parents 3a2e997 + e7e72a9 commit bf64a8f

File tree

607 files changed

+16080
-33061
lines changed

Some content is hidden

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

607 files changed

+16080
-33061
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/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/test/clang-tidy/checkers/bugprone/unsafe-functions-custom-regex.cpp

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
// RUN: %check_clang_tidy -check-suffix=NON-STRICT-REGEX %s bugprone-unsafe-functions %t --\
2-
// RUN: -config="{CheckOptions: {bugprone-unsafe-functions.CustomFunctions: '::name_match,replacement,is a qualname match;^::prefix_match,,is matched on qualname prefix'}}"
2+
// RUN: -config="{CheckOptions: {bugprone-unsafe-functions.CustomFunctions: '::name_match,replacement,is a qualname match;^::prefix_match,,is matched on qualname prefix;^::S::member_match_,,is matched on a C++ class member'}}"
33
// RUN: %check_clang_tidy -check-suffix=STRICT-REGEX %s bugprone-unsafe-functions %t --\
4-
// RUN: -config="{CheckOptions: {bugprone-unsafe-functions.CustomFunctions: '^name_match$,replacement,is matched on function name only;^::prefix_match$,,is a full qualname match'}}"
4+
// RUN: -config="{CheckOptions: {bugprone-unsafe-functions.CustomFunctions: '^name_match$,replacement,is matched on function name only;^::prefix_match$,,is a full qualname match;^::S::member_match_1$,,is matched on a C++ class member'}}"
55

66
void name_match();
77
void prefix_match();
88

9+
struct S {
10+
static void member_match_1() {}
11+
void member_match_2() {}
12+
};
13+
14+
void member_match_1() {}
15+
void member_match_unmatched() {}
16+
917
namespace regex_test {
1018
void name_match();
1119
void prefix_match();
@@ -42,3 +50,25 @@ void f1() {
4250
// CHECK-MESSAGES-NON-STRICT-REGEX: :[[@LINE-1]]:3: warning: function 'prefix_match_regex' is matched on qualname prefix; it should not be used
4351
// no-warning STRICT-REGEX
4452
}
53+
54+
void f2() {
55+
S s;
56+
57+
S::member_match_1();
58+
// CHECK-MESSAGES-NON-STRICT-REGEX: :[[@LINE-1]]:3: warning: function 'member_match_1' is matched on a C++ class member; it should not be used
59+
// CHECK-MESSAGES-STRICT-REGEX: :[[@LINE-2]]:3: warning: function 'member_match_1' is matched on a C++ class member; it should not be used
60+
61+
s.member_match_1();
62+
// CHECK-MESSAGES-NON-STRICT-REGEX: :[[@LINE-1]]:5: warning: function 'member_match_1' is matched on a C++ class member; it should not be used
63+
// CHECK-MESSAGES-STRICT-REGEX: :[[@LINE-2]]:5: warning: function 'member_match_1' is matched on a C++ class member; it should not be used
64+
65+
s.member_match_2();
66+
// CHECK-MESSAGES-NON-STRICT-REGEX: :[[@LINE-1]]:5: warning: function 'member_match_2' is matched on a C++ class member; it should not be used
67+
// no-warning STRICT-REGEX
68+
69+
member_match_1();
70+
// no-warning
71+
72+
member_match_unmatched();
73+
// no-warning
74+
}

clang/CMakeLists.txt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -432,18 +432,16 @@ if(NOT LLVM_STATIC_LINK_CXX_STDLIB)
432432
set(HAVE_CLANG_REPL_SUPPORT ON)
433433
endif()
434434

435-
option(CLANG_ENABLE_ARCMT "Build ARCMT." ON)
435+
option(CLANG_ENABLE_OBJC_REWRITER "Build the Objective-C rewriter tool" OFF)
436+
436437
option(CLANG_ENABLE_STATIC_ANALYZER
437438
"Include static analyzer in clang binary." ON)
438439

439440
option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF)
440441

441-
if(NOT CLANG_ENABLE_STATIC_ANALYZER AND CLANG_ENABLE_ARCMT)
442-
message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or Z3")
443-
endif()
444-
445-
if(CLANG_ENABLE_ARCMT)
446-
set(CLANG_ENABLE_OBJC_REWRITER ON)
442+
if (DEFINED CLANG_ENABLE_ARCMT)
443+
set(CLANG_ENABLE_OBJC_REWRITER ${CLANG_ENABLE_ARCMT})
444+
message(DEPRECATION "'CLANG_ENABLE_ARCMT' is deprecated as ARCMigrate has been removed from Clang. Please use 'CLANG_ENABLE_OBJC_REWRITER' instead to enable or disable the Objective-C rewriter.")
447445
endif()
448446

449447
# This option is a stop-gap, we should commit to removing this as

clang/cmake/caches/Android.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
set(LLVM_TARGETS_TO_BUILD X86 CACHE STRING "")
44

5-
set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
65
set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
76
set(CLANG_TIDY_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
87
set(CLANG_VENDOR Android CACHE STRING "")

clang/cmake/caches/Fuchsia-stage2.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
4444
set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
4545
set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
4646
set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
47-
set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
4847
set(CLANG_ENABLE_STATIC_ANALYZER ON CACHE BOOL "")
4948
set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
5049

0 commit comments

Comments
 (0)