Skip to content

Commit a306c3d

Browse files
authored
Merge branch 'main' into lld
2 parents 9591f5a + ddba036 commit a306c3d

File tree

795 files changed

+38039
-14797
lines changed

Some content is hidden

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

795 files changed

+38039
-14797
lines changed

.github/workflows/build-ci-container.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ jobs:
5959

6060
- name: Test Container
6161
run: |
62-
for image in ${{ steps.vars.outputs.container-name-tag }} ${{ steps.vars.outputs.container-name }}; do
63-
podman run --rm -it $image /usr/bin/bash -x -c 'cd $HOME && printf '\''#include <iostream>\nint main(int argc, char **argv) { std::cout << "Hello\\n"; }'\'' | clang++ -x c++ - && ./a.out | grep Hello'
62+
for image in ${{ steps.vars.outputs.container-name-tag }}; do
63+
# Use --pull=never to ensure we are testing the just built image.
64+
podman run --pull=never --rm -it $image /usr/bin/bash -x -c 'cd $HOME && printf '\''#include <iostream>\nint main(int argc, char **argv) { std::cout << "Hello\\n"; }'\'' | clang++ -x c++ - && ./a.out | grep Hello'
6465
done
6566
6667
push-ci-container:

.github/workflows/new-issues.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
steps:
1616
- uses: llvm/actions/issue-labeler@main
1717
with:
18-
repo-token: ${{ secrets.GITHUB_TOKEN }}
18+
repo-token: ${{ secrets.ISSUE_SUBSCRIBER_TOKEN }}
1919
configuration-path: .github/new-issues-labeler.yml
2020
include-title: 1
2121
include-body: 0

.github/workflows/release-binaries.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
USER_TOKEN: ${{ secrets.RELEASE_TASKS_USER_TOKEN }}
8484
shell: bash
8585
run: |
86-
./llvm/utils/release/./github-upload-release.py --token "$GITHUB_TOKEN" --user ${{ github.actor }} --user-token "$USER_TOKEN" check-permissions
86+
./llvm/utils/release/./github-upload-release.py --token "$GITHUB_TOKEN" --user "$GITHUB_ACTOR" --user-token "$USER_TOKEN" check-permissions
8787
8888
- name: Collect Variables
8989
id: vars
@@ -102,8 +102,8 @@ jobs:
102102
release_version="$trimmed"
103103
ref="llvmorg-$release_version"
104104
else
105-
release_version="${{ (github.event_name == 'pull_request' && format('PR{0}', github.event.pull_request.number)) || 'CI'}}-${{ github.sha }}"
106-
ref=${{ github.sha }}
105+
release_version="${{ (github.event_name == 'pull_request' && format('PR{0}', github.event.pull_request.number)) || 'CI'}}-$GITHUB_SHA"
106+
ref="$GITHUB_SHA"
107107
fi
108108
if [ -n "${{ inputs.upload }}" ]; then
109109
upload="${{ inputs.upload }}"
@@ -114,20 +114,20 @@ jobs:
114114
echo "ref=$ref" >> $GITHUB_OUTPUT
115115
echo "upload=$upload" >> $GITHUB_OUTPUT
116116
117-
release_binary_basename="LLVM-$release_version-${{ runner.os }}-${{ runner.arch }}"
117+
release_binary_basename="LLVM-$release_version-$RUNNER_OS-$RUNNER_ARCH"
118118
echo "release-binary-basename=$release_binary_basename" >> $GITHUB_OUTPUT
119119
echo "release-binary-filename=$release_binary_basename.tar.xz" >> $GITHUB_OUTPUT
120120
121121
# Detect necessary CMake flags
122-
target="${{ runner.os }}-${{ runner.arch }}"
122+
target="$RUNNER_OS-$RUNNER_ARCH"
123123
echo "enable-pgo=false" >> $GITHUB_OUTPUT
124124
target_cmake_flags="-DLLVM_RELEASE_ENABLE_PGO=OFF"
125125
# The macOS builds try to cross compile some libraries so we need to
126126
# add extra CMake args to disable them.
127127
# See https://github.com/llvm/llvm-project/issues/99767
128-
if [ "${{ runner.os }}" = "macOS" ]; then
128+
if [ "$RUNNER_OS" = "macOS" ]; then
129129
target_cmake_flags="$target_cmake_flags -DBOOTSTRAP_COMPILER_RT_ENABLE_IOS=OFF"
130-
if [ "${{ runner.arch }}" = "ARM64" ]; then
130+
if [ "$RUNNER_ARCH" = "ARM64" ]; then
131131
arches=arm64
132132
else
133133
arches=x86_64
@@ -137,7 +137,7 @@ jobs:
137137
138138
build_flang="true"
139139
140-
if [ "${{ runner.os }}" = "Windows" ]; then
140+
if [ "$RUNNER_OS" = "Windows" ]; then
141141
# The build times out on Windows, so we need to disable LTO.
142142
target_cmake_flags="$target_cmake_flags -DLLVM_RELEASE_ENABLE_LTO=OFF"
143143
fi

clang-tools-extra/clang-tidy/ClangTidyCheck.cpp

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "ClangTidyCheck.h"
10-
#include "llvm/ADT/SmallString.h"
1110
#include "llvm/ADT/StringRef.h"
12-
#include "llvm/Support/Error.h"
11+
#include "llvm/ADT/StringSet.h"
1312
#include "llvm/Support/YAMLParser.h"
1413
#include <optional>
14+
#include <string>
1515

1616
namespace clang::tidy {
1717

@@ -62,16 +62,29 @@ ClangTidyCheck::OptionsView::get(StringRef LocalName) const {
6262
return std::nullopt;
6363
}
6464

65+
static const llvm::StringSet<> DeprecatedGlobalOptions{
66+
"StrictMode",
67+
"IgnoreMacros",
68+
};
69+
6570
static ClangTidyOptions::OptionMap::const_iterator
6671
findPriorityOption(const ClangTidyOptions::OptionMap &Options,
6772
StringRef NamePrefix, StringRef LocalName,
68-
llvm::StringSet<> *Collector) {
73+
ClangTidyContext *Context) {
74+
llvm::StringSet<> *Collector = Context->getOptionsCollector();
6975
if (Collector) {
7076
Collector->insert((NamePrefix + LocalName).str());
7177
Collector->insert(LocalName);
7278
}
7379
auto IterLocal = Options.find((NamePrefix + LocalName).str());
7480
auto IterGlobal = Options.find(LocalName);
81+
// FIXME: temporary solution for deprecation warnings, should be removed
82+
// after 22.x. Warn configuration deps on deprecation global options.
83+
if (IterLocal == Options.end() && IterGlobal != Options.end() &&
84+
DeprecatedGlobalOptions.contains(LocalName))
85+
Context->configurationDiag(
86+
"global option '%0' is deprecated, please use '%1%0' instead.")
87+
<< LocalName << NamePrefix;
7588
if (IterLocal == Options.end())
7689
return IterGlobal;
7790
if (IterGlobal == Options.end())
@@ -83,8 +96,7 @@ findPriorityOption(const ClangTidyOptions::OptionMap &Options,
8396

8497
std::optional<StringRef>
8598
ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName) const {
86-
auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName,
87-
Context->getOptionsCollector());
99+
auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName, Context);
88100
if (Iter != CheckOptions.end())
89101
return StringRef(Iter->getValue().Value);
90102
return std::nullopt;
@@ -117,8 +129,7 @@ ClangTidyCheck::OptionsView::get<bool>(StringRef LocalName) const {
117129
template <>
118130
std::optional<bool>
119131
ClangTidyCheck::OptionsView::getLocalOrGlobal<bool>(StringRef LocalName) const {
120-
auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName,
121-
Context->getOptionsCollector());
132+
auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName, Context);
122133
if (Iter != CheckOptions.end()) {
123134
if (auto Result = getAsBool(Iter->getValue().Value, Iter->getKey()))
124135
return Result;
@@ -157,10 +168,9 @@ std::optional<int64_t> ClangTidyCheck::OptionsView::getEnumInt(
157168
bool IgnoreCase) const {
158169
if (!CheckGlobal && Context->getOptionsCollector())
159170
Context->getOptionsCollector()->insert((NamePrefix + LocalName).str());
160-
auto Iter = CheckGlobal
161-
? findPriorityOption(CheckOptions, NamePrefix, LocalName,
162-
Context->getOptionsCollector())
163-
: CheckOptions.find((NamePrefix + LocalName).str());
171+
auto Iter = CheckGlobal ? findPriorityOption(CheckOptions, NamePrefix,
172+
LocalName, Context)
173+
: CheckOptions.find((NamePrefix + LocalName).str());
164174
if (Iter == CheckOptions.end())
165175
return std::nullopt;
166176

clang-tools-extra/clangd/tool/ClangdMain.cpp

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,13 @@ opt<std::string> FallbackStyle{
242242
init(clang::format::DefaultFallbackStyle),
243243
};
244244

245-
opt<int> EnableFunctionArgSnippets{
245+
opt<std::string> EnableFunctionArgSnippets{
246246
"function-arg-placeholders",
247247
cat(Features),
248248
desc("When disabled (0), completions contain only parentheses for "
249249
"function calls. When enabled (1), completions also contain "
250250
"placeholders for method parameters"),
251-
init(-1),
251+
init("-1"),
252252
};
253253

254254
opt<CodeCompleteOptions::IncludeInsertion> HeaderInsertion{
@@ -636,6 +636,22 @@ loadExternalIndex(const Config::ExternalIndexSpec &External,
636636
llvm_unreachable("Invalid ExternalIndexKind.");
637637
}
638638

639+
std::optional<bool> shouldEnableFunctionArgSnippets() {
640+
std::string Val = EnableFunctionArgSnippets;
641+
// Accept the same values that a bool option parser would, but also accept
642+
// -1 to indicate "unspecified", in which case the ArgumentListsPolicy
643+
// config option will be respected.
644+
if (Val == "1" || Val == "true" || Val == "True" || Val == "TRUE")
645+
return true;
646+
if (Val == "0" || Val == "false" || Val == "False" || Val == "FALSE")
647+
return false;
648+
if (Val != "-1")
649+
elog("Value specified by --function-arg-placeholders is invalid. Provide a "
650+
"boolean value or leave unspecified to use ArgumentListsPolicy from "
651+
"config instead.");
652+
return std::nullopt;
653+
}
654+
639655
class FlagsConfigProvider : public config::Provider {
640656
private:
641657
config::CompiledFragment Frag;
@@ -696,10 +712,9 @@ class FlagsConfigProvider : public config::Provider {
696712
BGPolicy = Config::BackgroundPolicy::Skip;
697713
}
698714

699-
if (EnableFunctionArgSnippets >= 0) {
700-
ArgumentLists = EnableFunctionArgSnippets
701-
? Config::ArgumentListsPolicy::FullPlaceholders
702-
: Config::ArgumentListsPolicy::Delimiters;
715+
if (std::optional<bool> Enable = shouldEnableFunctionArgSnippets()) {
716+
ArgumentLists = *Enable ? Config::ArgumentListsPolicy::FullPlaceholders
717+
: Config::ArgumentListsPolicy::Delimiters;
703718
}
704719

705720
Frag = [=](const config::Params &, Config &C) {

clang-tools-extra/clangd/unittests/Matchers.h

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -127,74 +127,6 @@ PolySubsequenceMatcher<Args...> HasSubsequence(Args &&... M) {
127127
llvm::consumeError(ComputedValue.takeError()); \
128128
} while (false)
129129

130-
// Implements the HasValue(m) matcher for matching an Optional whose
131-
// value matches matcher m.
132-
template <typename InnerMatcher> class OptionalMatcher {
133-
public:
134-
explicit OptionalMatcher(const InnerMatcher &matcher) : matcher_(matcher) {}
135-
OptionalMatcher(const OptionalMatcher&) = default;
136-
OptionalMatcher &operator=(const OptionalMatcher&) = delete;
137-
138-
// This type conversion operator template allows Optional(m) to be
139-
// used as a matcher for any Optional type whose value type is
140-
// compatible with the inner matcher.
141-
//
142-
// The reason we do this instead of relying on
143-
// MakePolymorphicMatcher() is that the latter is not flexible
144-
// enough for implementing the DescribeTo() method of Optional().
145-
template <typename Optional> operator Matcher<Optional>() const {
146-
return MakeMatcher(new Impl<Optional>(matcher_));
147-
}
148-
149-
private:
150-
// The monomorphic implementation that works for a particular optional type.
151-
template <typename Optional>
152-
class Impl : public ::testing::MatcherInterface<Optional> {
153-
public:
154-
using Value = typename std::remove_const<
155-
typename std::remove_reference<Optional>::type>::type::value_type;
156-
157-
explicit Impl(const InnerMatcher &matcher)
158-
: matcher_(::testing::MatcherCast<const Value &>(matcher)) {}
159-
160-
Impl(const Impl&) = default;
161-
Impl &operator=(const Impl&) = delete;
162-
163-
virtual void DescribeTo(::std::ostream *os) const {
164-
*os << "has a value that ";
165-
matcher_.DescribeTo(os);
166-
}
167-
168-
virtual void DescribeNegationTo(::std::ostream *os) const {
169-
*os << "does not have a value that ";
170-
matcher_.DescribeTo(os);
171-
}
172-
173-
virtual bool
174-
MatchAndExplain(Optional optional,
175-
::testing::MatchResultListener *listener) const {
176-
if (!optional)
177-
return false;
178-
179-
*listener << "which has a value ";
180-
return MatchPrintAndExplain(*optional, matcher_, listener);
181-
}
182-
183-
private:
184-
const Matcher<const Value &> matcher_;
185-
};
186-
187-
const InnerMatcher matcher_;
188-
};
189-
190-
// Creates a matcher that matches an Optional that has a value
191-
// that matches inner_matcher.
192-
template <typename InnerMatcher>
193-
inline OptionalMatcher<InnerMatcher>
194-
HasValue(const InnerMatcher &inner_matcher) {
195-
return OptionalMatcher<InnerMatcher>(inner_matcher);
196-
}
197-
198130
} // namespace clangd
199131
} // namespace clang
200132
#endif

clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ using ::testing::ElementsAre;
2828
using ::testing::Field;
2929
using ::testing::IsEmpty;
3030
using ::testing::Matcher;
31+
using ::testing::Optional;
3132
using ::testing::SizeIs;
3233
using ::testing::UnorderedElementsAre;
3334

@@ -38,12 +39,12 @@ MATCHER_P(selectionRangeIs, R, "") { return arg.selectionRange == R; }
3839
template <class... ParentMatchers>
3940
::testing::Matcher<TypeHierarchyItem> parents(ParentMatchers... ParentsM) {
4041
return Field(&TypeHierarchyItem::parents,
41-
HasValue(UnorderedElementsAre(ParentsM...)));
42+
Optional(UnorderedElementsAre(ParentsM...)));
4243
}
4344
template <class... ChildMatchers>
4445
::testing::Matcher<TypeHierarchyItem> children(ChildMatchers... ChildrenM) {
4546
return Field(&TypeHierarchyItem::children,
46-
HasValue(UnorderedElementsAre(ChildrenM...)));
47+
Optional(UnorderedElementsAre(ChildrenM...)));
4748
}
4849
// Note: "not resolved" is different from "resolved but empty"!
4950
MATCHER(parentsNotResolved, "") { return !arg.parents; }
@@ -790,7 +791,7 @@ struct Child : Parent1, Parent2 {};
790791
Children,
791792
UnorderedElementsAre(
792793
AllOf(withName("Child"),
793-
withResolveParents(HasValue(UnorderedElementsAre(withResolveID(
794+
withResolveParents(Optional(UnorderedElementsAre(withResolveID(
794795
getSymbolID(&findDecl(AST, "Parent1")).str())))))));
795796
}
796797

@@ -810,9 +811,9 @@ struct Chil^d : Parent {};
810811
ASSERT_THAT(Result, SizeIs(1));
811812
auto Parents = superTypes(Result.front(), Index.get());
812813

813-
EXPECT_THAT(Parents, HasValue(UnorderedElementsAre(
814+
EXPECT_THAT(Parents, Optional(UnorderedElementsAre(
814815
AllOf(withName("Parent"),
815-
withResolveParents(HasValue(IsEmpty()))))));
816+
withResolveParents(Optional(IsEmpty()))))));
816817
}
817818
} // namespace
818819
} // namespace clangd

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ Improvements to clang-tidy
119119

120120
- Removed :program:`clang-tidy`'s global options for most of checks. All options
121121
are changed to local options except `IncludeStyle`, `StrictMode` and
122-
`IgnoreMacros`.
122+
`IgnoreMacros`. Global scoped `StrictMode` and `IgnoreMacros` are deprecated
123+
and will be removed in further releases.
123124

124125
.. csv-table::
125126
:header: "Check", "Options removed from global option"

clang-tools-extra/docs/clang-tidy/checks/bugprone/unhandled-self-assignment.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,5 +120,7 @@ temporary object into ``this`` (needs a move assignment operator):
120120
121121
.. option:: WarnOnlyIfThisHasSuspiciousField
122122

123-
When `true`, the check will warn only if the container class of the copy assignment operator
124-
has any suspicious fields (pointer or C array). This option is set to `true` by default.
123+
When `true`, the check will warn only if the container class of the copy
124+
assignment operator has any suspicious fields (pointer, C array and C++ smart
125+
pointer).
126+
This option is set to `true` by default.

clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format-fmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %check_clang_tidy %s modernize-use-std-format %t -- \
22
// RUN: -config="{CheckOptions: { \
3-
// RUN: StrictMode: true, \
3+
// RUN: modernize-use-std-format.StrictMode: true, \
44
// RUN: modernize-use-std-format.StrFormatLikeFunctions: 'fmt::sprintf', \
55
// RUN: modernize-use-std-format.ReplacementFormatFunction: 'fmt::format', \
66
// RUN: modernize-use-std-format.FormatHeader: '<fmt/core.h>' \

0 commit comments

Comments
 (0)