Skip to content

Commit c0cd20b

Browse files
committed
merge main into amd-staging
includes 3 improved lit tests from Pranav.
2 parents acda018 + c75b251 commit c0cd20b

File tree

730 files changed

+20394
-32248
lines changed

Some content is hidden

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

730 files changed

+20394
-32248
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``).

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
@@ -457,18 +457,16 @@ if(NOT LLVM_STATIC_LINK_CXX_STDLIB)
457457
set(HAVE_CLANG_REPL_SUPPORT ON)
458458
endif()
459459

460-
option(CLANG_ENABLE_ARCMT "Build ARCMT." ON)
460+
option(CLANG_ENABLE_OBJC_REWRITER "Build the Objective-C rewriter tool" OFF)
461+
461462
option(CLANG_ENABLE_STATIC_ANALYZER
462463
"Include static analyzer in clang binary." ON)
463464

464465
option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF)
465466

466-
if(NOT CLANG_ENABLE_STATIC_ANALYZER AND CLANG_ENABLE_ARCMT)
467-
message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or Z3")
468-
endif()
469-
470-
if(CLANG_ENABLE_ARCMT)
471-
set(CLANG_ENABLE_OBJC_REWRITER ON)
467+
if (DEFINED CLANG_ENABLE_ARCMT)
468+
set(CLANG_ENABLE_OBJC_REWRITER ${CLANG_ENABLE_ARCMT})
469+
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.")
472470
endif()
473471

474472
# 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

clang/cmake/caches/Fuchsia.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
8484
set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
8585
set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
8686
set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
87-
set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
8887
set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
8988
set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
9089

clang/docs/ReleaseNotes.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ latest release, please see the `Clang Web Site <https://clang.llvm.org>`_ or the
3434
Potentially Breaking Changes
3535
============================
3636

37+
- The Objective-C ARC migrator (ARCMigrate) has been removed.
38+
3739
C/C++ Language Potentially Breaking Changes
3840
-------------------------------------------
3941

@@ -73,6 +75,11 @@ C++17 Feature Support
7375
Resolutions to C++ Defect Reports
7476
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7577

78+
- The flag `-frelaxed-template-template-args`
79+
and its negation have been removed, having been deprecated since the previous
80+
two releases. The improvements to template template parameter matching implemented
81+
in the previous release, as described in P3310 and P3579, made this flag unnecessary.
82+
7683
C Language Changes
7784
------------------
7885

clang/include/clang-c/Index.h

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -5905,66 +5905,6 @@ CINDEX_LINKAGE const char *clang_EvalResult_getAsStr(CXEvalResult E);
59055905
* Disposes the created Eval memory.
59065906
*/
59075907
CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E);
5908-
/**
5909-
* @}
5910-
*/
5911-
5912-
/** \defgroup CINDEX_REMAPPING Remapping functions
5913-
*
5914-
* @{
5915-
*/
5916-
5917-
/**
5918-
* A remapping of original source files and their translated files.
5919-
*/
5920-
typedef void *CXRemapping;
5921-
5922-
/**
5923-
* Retrieve a remapping.
5924-
*
5925-
* \param path the path that contains metadata about remappings.
5926-
*
5927-
* \returns the requested remapping. This remapping must be freed
5928-
* via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5929-
*/
5930-
CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
5931-
5932-
/**
5933-
* Retrieve a remapping.
5934-
*
5935-
* \param filePaths pointer to an array of file paths containing remapping info.
5936-
*
5937-
* \param numFiles number of file paths.
5938-
*
5939-
* \returns the requested remapping. This remapping must be freed
5940-
* via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5941-
*/
5942-
CINDEX_LINKAGE
5943-
CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
5944-
unsigned numFiles);
5945-
5946-
/**
5947-
* Determine the number of remappings.
5948-
*/
5949-
CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
5950-
5951-
/**
5952-
* Get the original and the associated filename from the remapping.
5953-
*
5954-
* \param original If non-NULL, will be set to the original filename.
5955-
*
5956-
* \param transformed If non-NULL, will be set to the filename that the original
5957-
* is associated with.
5958-
*/
5959-
CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
5960-
CXString *original,
5961-
CXString *transformed);
5962-
5963-
/**
5964-
* Dispose the remapping.
5965-
*/
5966-
CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
5967-
59685908
/**
59695909
* @}
59705910
*/

0 commit comments

Comments
 (0)