Skip to content

Commit 646a112

Browse files
committed
Merge remote-tracking branch 'origin/main' into vplan-all-regions-as-transform
2 parents a88f03e + d4002b4 commit 646a112

File tree

88 files changed

+1372
-1261
lines changed

Some content is hidden

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

88 files changed

+1372
-1261
lines changed

clang-tools-extra/clangd/ConfigCompile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ struct FragmentCompiler {
535535
}
536536
if (Filters->empty())
537537
return std::nullopt;
538-
auto Filter = [Filters](llvm::StringRef Path) {
538+
auto Filter = [Filters = std::move(Filters)](llvm::StringRef Path) {
539539
for (auto &Regex : *Filters)
540540
if (Regex.match(Path))
541541
return true;

clang-tools-extra/clangd/Headers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,14 @@ IncludeInserter::calculateIncludePath(const HeaderFile &InsertedHeader,
305305
if (llvm::sys::path::is_absolute(Suggested))
306306
return std::nullopt;
307307
bool IsAngled = false;
308-
for (auto Filter : AngledHeaders) {
308+
for (auto &Filter : AngledHeaders) {
309309
if (Filter(Suggested)) {
310310
IsAngled = true;
311311
break;
312312
}
313313
}
314314
bool IsQuoted = false;
315-
for (auto Filter : QuotedHeaders) {
315+
for (auto &Filter : QuotedHeaders) {
316316
if (Filter(Suggested)) {
317317
IsQuoted = true;
318318
break;

clang-tools-extra/docs/clang-tidy/checks/android/comparison-in-temp-failure-retry.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ Options
4141
.. option:: RetryMacros
4242

4343
A comma-separated list of the names of retry macros to be checked.
44+
Default is `TEMP_FAILURE_RETRY`.

clang-tools-extra/docs/clang-tidy/checks/cert/msc51-cpp.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ Options
3737
.. option:: DisallowedSeedTypes
3838

3939
A comma-separated list of the type names which are disallowed.
40-
Default values are ``time_t``, ``std::time_t``.
40+
Default value is `time_t,std::time_t`.

clang-tools-extra/docs/clang-tidy/checks/concurrency/mt-unsafe.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ Examples:
3232

3333
sleep(1); // implementation may use SIGALRM
3434

35+
Options
36+
-------
37+
3538
.. option:: FunctionSet
3639

3740
Specifies which functions in libc should be considered thread-safe,

clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/no-malloc.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ Options
3535
.. option:: Allocations
3636

3737
Semicolon-separated list of fully qualified names of memory allocation functions.
38-
Defaults to ``::malloc;::calloc``.
38+
Defaults to `::malloc;::calloc`.
3939

4040
.. option:: Deallocations
4141

4242
Semicolon-separated list of fully qualified names of memory allocation functions.
43-
Defaults to ``::free``.
43+
Defaults to `::free`.
4444

4545
.. option:: Reallocations
4646

4747
Semicolon-separated list of fully qualified names of memory allocation functions.
48-
Defaults to ``::realloc``.
48+
Defaults to `::realloc`.

clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/owning-memory.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ Options
9595

9696
Semicolon-separated list of fully qualified names of legacy functions that create
9797
resources but cannot introduce ``gsl::owner<>``.
98-
Defaults to ``::malloc;::aligned_alloc;::realloc;::calloc;::fopen;::freopen;::tmpfile``.
98+
Defaults to `::malloc;::aligned_alloc;::realloc;::calloc;::fopen;::freopen;::tmpfile`.
9999

100100

101101
.. option:: LegacyResourceConsumers
102102

103103
Semicolon-separated list of fully qualified names of legacy functions expecting
104104
resource owners as pointer arguments but cannot introduce ``gsl::owner<>``.
105-
Defaults to ``::free;::realloc;::freopen;::fclose``.
105+
Defaults to `::free;::realloc;::freopen;::fclose`.
106106

107107

108108
Limitations

clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/pro-bounds-constant-array-index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Options
2121

2222
The check can generate fixes after this option has been set to the name of
2323
the include file that contains ``gsl::at()``, e.g. `"gsl/gsl.h"`.
24+
Default is an empty string.
2425

2526
.. option:: IncludeStyle
2627

clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/pro-type-member-init.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Options
3737

3838
If set to `true`, the check will provide fix-its with literal initializers
3939
\( ``int i = 0;`` \) instead of curly braces \( ``int i{};`` \).
40+
Default is `false`.
4041

4142
This rule is part of the `Type safety (Type.6)
4243
<https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Pro-type-memberinit>`_

clang-tools-extra/docs/clang-tidy/checks/misc/coroutine-hostile-raii.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ Options
4545

4646
A semicolon-separated list of qualified types which should not be allowed to
4747
persist across suspension points.
48-
Eg: ``my::lockable; a::b;::my::other::lockable;``
49-
The default value of this option is `"std::lock_guard;std::scoped_lock"`.
48+
Eg: `my::lockable;a::b;::my::other::lockable`
49+
The default value of this option is `std::lock_guard;std::scoped_lock`.
5050

5151
.. option:: AllowedAwaitablesList
5252

@@ -78,6 +78,6 @@ Options
7878
co_await wait();
7979
}
8080

81-
Eg: ``my::safe::awaitable;other::awaitable``
82-
The default value of this option is empty string `""`.
81+
Eg: `my::safe::awaitable;other::awaitable`
82+
Default is an empty string.
8383

clang-tools-extra/docs/clang-tidy/checks/misc/include-cleaner.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ Options
3131

3232
A semicolon-separated list of regexes to disable insertion/removal of header
3333
files that match this regex as a suffix. E.g., `foo/.*` disables
34-
insertion/removal for all headers under the directory `foo`. By default, no
35-
headers will be ignored.
34+
insertion/removal for all headers under the directory `foo`. Default is an
35+
empty string, no headers will be ignored.
3636

3737
.. option:: DeduplicateFindings
3838

clang-tools-extra/docs/clang-tidy/checks/misc/non-private-member-variables-in-classes.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ Options
1717

1818
.. option:: IgnoreClassesWithAllMemberVariablesBeingPublic
1919

20-
Allows to completely ignore classes if **all** the member variables in that
21-
class a declared with a ``public`` access specifier.
20+
When `true`, allows to completely ignore classes if **all** the member
21+
variables in that class declared with a ``public`` access specifier.
22+
Default is `false`.
2223

2324
.. option:: IgnorePublicMemberVariables
2425

25-
Allows to ignore (not diagnose) **all** the member variables declared with
26-
a ``public`` access specifier.
26+
When `true`, allows to ignore (not diagnose) **all** the member variables
27+
declared with a ``public`` access specifier. Default is `false`.

clang-tools-extra/docs/clang-tidy/checks/readability/container-data-pointer.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ Options
1818
.. option:: IgnoredContainers
1919

2020
Semicolon-separated list of containers regexp for which this check won't be
21-
enforced. Default is `empty`.
21+
enforced. Default is an empty string.

clang-tools-extra/docs/clang-tidy/checks/readability/container-size-empty.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ The check issues warning if a container has ``empty()`` and ``size()`` or
2525

2626
`size_type` can be any kind of integer type.
2727

28+
Options
29+
-------
30+
2831
.. option:: ExcludedComparisonTypes
2932

3033
A semicolon-separated list of class names for which the check will ignore

clang-tools-extra/docs/clang-tidy/checks/readability/inconsistent-declaration-parameter-name.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ In the case of multiple redeclarations or function template specializations,
5252
a warning is issued for every redeclaration or specialization inconsistent with
5353
the definition or the first declaration seen in a translation unit.
5454

55+
Options
56+
-------
57+
5558
.. option:: IgnoreMacros
5659

5760
If this option is set to `true` (default is `true`), the check will not warn

clang-tools-extra/docs/clang-tidy/checks/readability/redundant-inline-specifier.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ Options
2929
.. option:: StrictMode
3030

3131
If set to `true`, the check will also flag functions and variables that
32-
already have internal linkage as redundant.
32+
already have internal linkage as redundant. Default is `false`.

clang-tools-extra/docs/clang-tidy/checks/readability/redundant-smartptr-get.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Examples:
1414
*ptr->get() ==> **ptr
1515
if (ptr.get() == nullptr) ... => if (ptr == nullptr) ...
1616
17+
Options
18+
-------
1719

1820
.. option:: IgnoreMacros
1921

clang/include/clang/AST/DeclCXX.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2878,7 +2878,7 @@ class CXXDestructorDecl : public CXXMethodDecl {
28782878
static CXXDestructorDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
28792879

28802880
void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg);
2881-
void setOperatorArrayDelete(FunctionDecl *OD, Expr *ThisArg);
2881+
void setOperatorArrayDelete(FunctionDecl *OD);
28822882

28832883
const FunctionDecl *getOperatorDelete() const {
28842884
return getCanonicalDecl()->OperatorDelete;

clang/include/clang/ASTMatchers/ASTMatchers.h

Lines changed: 17 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
#include "clang/AST/TypeLoc.h"
7272
#include "clang/ASTMatchers/ASTMatchersInternal.h"
7373
#include "clang/ASTMatchers/ASTMatchersMacros.h"
74+
#include "clang/ASTMatchers/LowLevelHelpers.h"
7475
#include "clang/Basic/AttrKinds.h"
7576
#include "clang/Basic/ExceptionSpecificationType.h"
7677
#include "clang/Basic/FileManager.h"
@@ -5211,72 +5212,25 @@ AST_POLYMORPHIC_MATCHER_P2(forEachArgumentWithParamType,
52115212
internal::Matcher<Expr>, ArgMatcher,
52125213
internal::Matcher<QualType>, ParamMatcher) {
52135214
BoundNodesTreeBuilder Result;
5214-
// The first argument of an overloaded member operator is the implicit object
5215-
// argument of the method which should not be matched against a parameter, so
5216-
// we skip over it here.
5217-
BoundNodesTreeBuilder Matches;
5218-
unsigned ArgIndex =
5219-
cxxOperatorCallExpr(
5220-
callee(cxxMethodDecl(unless(isExplicitObjectMemberFunction()))))
5221-
.matches(Node, Finder, &Matches)
5222-
? 1
5223-
: 0;
5224-
const FunctionProtoType *FProto = nullptr;
5225-
5226-
if (const auto *Call = dyn_cast<CallExpr>(&Node)) {
5227-
if (const auto *Value =
5228-
dyn_cast_or_null<ValueDecl>(Call->getCalleeDecl())) {
5229-
QualType QT = Value->getType().getCanonicalType();
5230-
5231-
// This does not necessarily lead to a `FunctionProtoType`,
5232-
// e.g. K&R functions do not have a function prototype.
5233-
if (QT->isFunctionPointerType())
5234-
FProto = QT->getPointeeType()->getAs<FunctionProtoType>();
5235-
5236-
if (QT->isMemberFunctionPointerType()) {
5237-
const auto *MP = QT->getAs<MemberPointerType>();
5238-
assert(MP && "Must be member-pointer if its a memberfunctionpointer");
5239-
FProto = MP->getPointeeType()->getAs<FunctionProtoType>();
5240-
assert(FProto &&
5241-
"The call must have happened through a member function "
5242-
"pointer");
5243-
}
5244-
}
5245-
}
5246-
5247-
unsigned ParamIndex = 0;
52485215
bool Matched = false;
5249-
unsigned NumArgs = Node.getNumArgs();
5250-
if (FProto && FProto->isVariadic())
5251-
NumArgs = std::min(NumArgs, FProto->getNumParams());
5252-
5253-
for (; ArgIndex < NumArgs; ++ArgIndex, ++ParamIndex) {
5216+
auto ProcessParamAndArg = [&](QualType ParamType, const Expr *Arg) {
52545217
BoundNodesTreeBuilder ArgMatches(*Builder);
5255-
if (ArgMatcher.matches(*(Node.getArg(ArgIndex)->IgnoreParenCasts()), Finder,
5256-
&ArgMatches)) {
5257-
BoundNodesTreeBuilder ParamMatches(ArgMatches);
5218+
if (!ArgMatcher.matches(*Arg, Finder, &ArgMatches))
5219+
return;
5220+
BoundNodesTreeBuilder ParamMatches(std::move(ArgMatches));
5221+
if (!ParamMatcher.matches(ParamType, Finder, &ParamMatches))
5222+
return;
5223+
Result.addMatch(ParamMatches);
5224+
Matched = true;
5225+
return;
5226+
};
5227+
if (auto *Call = llvm::dyn_cast<CallExpr>(&Node))
5228+
matchEachArgumentWithParamType(*Call, ProcessParamAndArg);
5229+
else if (auto *Construct = llvm::dyn_cast<CXXConstructExpr>(&Node))
5230+
matchEachArgumentWithParamType(*Construct, ProcessParamAndArg);
5231+
else
5232+
llvm_unreachable("expected CallExpr or CXXConstructExpr");
52585233

5259-
// This test is cheaper compared to the big matcher in the next if.
5260-
// Therefore, please keep this order.
5261-
if (FProto && FProto->getNumParams() > ParamIndex) {
5262-
QualType ParamType = FProto->getParamType(ParamIndex);
5263-
if (ParamMatcher.matches(ParamType, Finder, &ParamMatches)) {
5264-
Result.addMatch(ParamMatches);
5265-
Matched = true;
5266-
continue;
5267-
}
5268-
}
5269-
if (expr(anyOf(cxxConstructExpr(hasDeclaration(cxxConstructorDecl(
5270-
hasParameter(ParamIndex, hasType(ParamMatcher))))),
5271-
callExpr(callee(functionDecl(
5272-
hasParameter(ParamIndex, hasType(ParamMatcher)))))))
5273-
.matches(Node, Finder, &ParamMatches)) {
5274-
Result.addMatch(ParamMatches);
5275-
Matched = true;
5276-
continue;
5277-
}
5278-
}
5279-
}
52805234
*Builder = std::move(Result);
52815235
return Matched;
52825236
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//===- LowLevelHelpers.h - helpers with pure AST interface ---- *- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
// Collects a number of helpers that are used by matchers, but can be reused
9+
// outside of them, e.g. when corresponding matchers cannot be used due to
10+
// performance constraints.
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef LLVM_CLANG_ASTMATCHERS_LOWLEVELHELPERS_H
14+
#define LLVM_CLANG_ASTMATCHERS_LOWLEVELHELPERS_H
15+
16+
#include "clang/AST/Expr.h"
17+
#include "clang/AST/ExprCXX.h"
18+
#include "clang/AST/Type.h"
19+
#include "llvm/ADT/STLFunctionalExtras.h"
20+
21+
namespace clang {
22+
namespace ast_matchers {
23+
24+
void matchEachArgumentWithParamType(
25+
const CallExpr &Node,
26+
llvm::function_ref<void(QualType /*Param*/, const Expr * /*Arg*/)>
27+
OnParamAndArg);
28+
29+
void matchEachArgumentWithParamType(
30+
const CXXConstructExpr &Node,
31+
llvm::function_ref<void(QualType /*Param*/, const Expr * /*Arg*/)>
32+
OnParamAndArg);
33+
34+
} // namespace ast_matchers
35+
} // namespace clang
36+
37+
#endif

clang/include/clang/Sema/Sema.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8336,7 +8336,8 @@ class Sema final : public SemaBase {
83368336
DeclarationName Name);
83378337
FunctionDecl *FindDeallocationFunctionForDestructor(SourceLocation StartLoc,
83388338
CXXRecordDecl *RD,
8339-
DeclarationName Name);
8339+
DeclarationName Name,
8340+
bool Diagnose = true);
83408341

83418342
/// ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
83428343
/// @code ::delete ptr; @endcode

clang/lib/AST/DeclCXX.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3031,8 +3031,7 @@ void CXXDestructorDecl::setOperatorDelete(FunctionDecl *OD, Expr *ThisArg) {
30313031
}
30323032
}
30333033

3034-
void CXXDestructorDecl::setOperatorArrayDelete(FunctionDecl *OD,
3035-
Expr *ThisArg) {
3034+
void CXXDestructorDecl::setOperatorArrayDelete(FunctionDecl *OD) {
30363035
auto *First = cast<CXXDestructorDecl>(getFirstDecl());
30373036
if (OD && !First->OperatorArrayDelete)
30383037
First->OperatorArrayDelete = OD;

clang/lib/ASTMatchers/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ add_clang_library(clangASTMatchers
99
ASTMatchFinder.cpp
1010
ASTMatchersInternal.cpp
1111
GtestMatchers.cpp
12+
LowLevelHelpers.cpp
1213

1314
LINK_LIBS
1415
clangAST

0 commit comments

Comments
 (0)