Skip to content

Commit 3ffaa3a

Browse files
committed
Merge branch 'main' of https://github.com/llvm/llvm-project into feat/55474
2 parents 3970973 + bb27d5e commit 3ffaa3a

File tree

262 files changed

+6468
-1787
lines changed

Some content is hidden

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

262 files changed

+6468
-1787
lines changed

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/docs/ClangFormat.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ names. It has the following format:
150150
* Patterns follow the rules specified in `POSIX 2.13.1, 2.13.2, and Rule 1 of
151151
2.13.3 <https://pubs.opengroup.org/onlinepubs/9699919799/utilities/
152152
V3_chap02.html#tag_18_13>`_.
153+
* Bash globstar (``**``) is supported.
153154
* A pattern is negated if it starts with a bang (``!``).
154155

155156
To match all files in a directory, use e.g. ``foo/bar/*``. To match all files in

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6798,6 +6798,15 @@ the configuration (without a prefix: ``Auto``).
67986798

67996799

68006800

6801+
.. _VariableTemplates:
6802+
6803+
**VariableTemplates** (``List of Strings``) :versionbadge:`clang-format 20` :ref:`<VariableTemplates>`
6804+
A vector of non-keyword identifiers that should be interpreted as variable
6805+
template names.
6806+
6807+
A ``)`` after a variable template instantiation is **not** annotated as
6808+
the closing parenthesis of C-style cast operator.
6809+
68016810
.. _VerilogBreakBetweenInstancePorts:
68026811

68036812
**VerilogBreakBetweenInstancePorts** (``Boolean``) :versionbadge:`clang-format 17` :ref:`<VerilogBreakBetweenInstancePorts>`

clang/docs/ReleaseNotes.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,7 @@ Bug Fixes to C++ Support
887887
out of a module (which is the case e.g. in MSVC's implementation of ``std`` module). (#GH118218)
888888
- Fixed a pack expansion issue in checking unexpanded parameter sizes. (#GH17042)
889889
- Fixed a bug where captured structured bindings were modifiable inside non-mutable lambda (#GH95081)
890+
- Fixed an issue while resolving type of expression indexing into a pack of values of non-dependent type (#GH121242)
890891

891892
Bug Fixes to AST Handling
892893
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1125,6 +1126,8 @@ clang-format
11251126
- Adds ``RemoveEmptyLinesInUnwrappedLines`` option.
11261127
- Adds ``KeepFormFeed`` option and set it to ``true`` for ``GNU`` style.
11271128
- Adds ``AllowShortNamespacesOnASingleLine`` option.
1129+
- Adds ``VariableTemplates`` option.
1130+
- Adds support for bash globstar in ``.clang-format-ignore``.
11281131

11291132
libclang
11301133
--------
@@ -1155,6 +1158,13 @@ New features
11551158
Crash and bug fixes
11561159
^^^^^^^^^^^^^^^^^^^
11571160

1161+
- In loops where the loop condition is opaque (i.e. the analyzer cannot
1162+
determine whether it's true or false), the analyzer will no longer assume
1163+
execution paths that perform more that two iterations. These unjustified
1164+
assumptions caused false positive reports (e.g. 100+ out-of-bounds reports in
1165+
the FFMPEG codebase) in loops where the programmer intended only two or three
1166+
steps but the analyzer wasn't able to understand that the loop is limited.
1167+
11581168
Improvements
11591169
^^^^^^^^^^^^
11601170

clang/include/clang/Basic/arm_immcheck_incl.td

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@ class ImmCheckType<int val> {
22
int Value = val;
33
}
44

5-
// These must be kept in sync with the flags in include/clang/Basic/TargetBuiltins.h
5+
6+
// For SVE, container_size refers to the width of a vector segment (128b).
7+
// For NEON, container_size refers to the vector width (64b or 128b).
68
def ImmCheck0_31 : ImmCheckType<0>; // 0..31 (used for e.g. predicate patterns)
79
def ImmCheck1_16 : ImmCheckType<1>; // 1..16
810
def ImmCheckExtract : ImmCheckType<2>; // 0..(2048/sizeinbits(elt) - 1)
911
def ImmCheckShiftRight : ImmCheckType<3>; // 1..sizeinbits(elt)
1012
def ImmCheckShiftRightNarrow : ImmCheckType<4>; // 1..sizeinbits(elt)/2
1113
def ImmCheckShiftLeft : ImmCheckType<5>; // 0..(sizeinbits(elt) - 1)
1214
def ImmCheck0_7 : ImmCheckType<6>; // 0..7
13-
def ImmCheckLaneIndex : ImmCheckType<7>; // 0..(sizeinbits(vec)/(sizeinbits(elt)) - 1)
15+
def ImmCheckLaneIndex : ImmCheckType<7>; // 0..(container_size/(sizeinbits(elt)) - 1)
1416
def ImmCheckCvt : ImmCheckType<8>; // 1..sizeinbits(elt) (same as ShiftRight)
15-
def ImmCheckLaneIndexCompRotate : ImmCheckType<9>; // 0..(sizeinbits(vec)/(2*sizeinbits(elt)) - 1)
16-
def ImmCheckLaneIndexDot : ImmCheckType<10>; // 0..(sizeinbits(vec)/(4*sizeinbits(elt)) - 1)
17+
def ImmCheckLaneIndexCompRotate : ImmCheckType<9>; // 0..(container_size/(2*sizeinbits(elt)) - 1)
18+
def ImmCheckLaneIndexDot : ImmCheckType<10>; // 0..(container_size/(4*sizeinbits(elt)) - 1)
1719
def ImmCheckComplexRot90_270 : ImmCheckType<11>; // [90,270]
1820
def ImmCheckComplexRotAll90 : ImmCheckType<12>; // [0, 90, 180,270]
1921
def ImmCheck0_13 : ImmCheckType<13>; // 0..13

clang/include/clang/Format/Format.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5103,6 +5103,15 @@ struct FormatStyle {
51035103
/// \version 3.7
51045104
UseTabStyle UseTab;
51055105

5106+
/// A vector of non-keyword identifiers that should be interpreted as variable
5107+
/// template names.
5108+
///
5109+
/// A ``)`` after a variable template instantiation is **not** annotated as
5110+
/// the closing parenthesis of C-style cast operator.
5111+
///
5112+
/// \version 20
5113+
std::vector<std::string> VariableTemplates;
5114+
51065115
/// For Verilog, put each port on its own line in module instantiations.
51075116
/// \code
51085117
/// true:
@@ -5314,7 +5323,7 @@ struct FormatStyle {
53145323
TableGenBreakInsideDAGArg == R.TableGenBreakInsideDAGArg &&
53155324
TabWidth == R.TabWidth && TemplateNames == R.TemplateNames &&
53165325
TypeNames == R.TypeNames && TypenameMacros == R.TypenameMacros &&
5317-
UseTab == R.UseTab &&
5326+
UseTab == R.UseTab && VariableTemplates == R.VariableTemplates &&
53185327
VerilogBreakBetweenInstancePorts ==
53195328
R.VerilogBreakBetweenInstancePorts &&
53205329
WhitespaceSensitiveMacros == R.WhitespaceSensitiveMacros;

clang/include/clang/Frontend/Utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ class DependencyFileGenerator : public DependencyCollector {
120120
private:
121121
void outputDependencyFile(DiagnosticsEngine &Diags);
122122

123+
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS;
123124
std::string OutputFile;
124125
std::vector<std::string> Targets;
125126
bool IncludeSystemHeaders;

clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ class CoreEngine {
126126
ExplodedNode *generateCallExitBeginNode(ExplodedNode *N,
127127
const ReturnStmt *RS);
128128

129+
/// Helper function called by `HandleBranch()`. If the currently handled
130+
/// branch corresponds to a loop, this returns the number of already
131+
/// completed iterations in that loop, otherwise the return value is
132+
/// `std::nullopt`. Note that this counts _all_ earlier iterations, including
133+
/// ones that were performed within an earlier iteration of an outer loop.
134+
std::optional<unsigned> getCompletedIterationCount(const CFGBlock *B,
135+
ExplodedNode *Pred) const;
136+
129137
public:
130138
/// Construct a CoreEngine object to analyze the provided CFG.
131139
CoreEngine(ExprEngine &exprengine,

0 commit comments

Comments
 (0)