Skip to content

Commit 0bafa7d

Browse files
SC llvm teamdstutt
SC llvm team
authored andcommitted
Merged main:bc87a537d9b8 into amd-gfx:f699e122cfa0
Local branch amd-gfx f699e12 Merged main:2feffecb8853 into amd-gfx:ba1f05bbae53 Remote branch main bc87a53 [clangd] Remove clangds HasValue GMock matcher (llvm#121309) Change-Id: Iba35b52abe783df69de1e1717af7140b6820f0b0
2 parents f699e12 + bc87a53 commit 0bafa7d

File tree

119 files changed

+1654
-548
lines changed

Some content is hidden

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

119 files changed

+1654
-548
lines changed

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

890891
Bug Fixes to AST Handling
891892
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1124,6 +1125,8 @@ clang-format
11241125
- Adds ``RemoveEmptyLinesInUnwrappedLines`` option.
11251126
- Adds ``KeepFormFeed`` option and set it to ``true`` for ``GNU`` style.
11261127
- Adds ``AllowShortNamespacesOnASingleLine`` option.
1128+
- Adds ``VariableTemplates`` option.
1129+
- Adds support for bash globstar in ``.clang-format-ignore``.
11271130

11281131
libclang
11291132
--------

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/lib/AST/ExprCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1722,7 +1722,7 @@ PackIndexingExpr *PackIndexingExpr::Create(
17221722
if (Index && FullySubstituted && !SubstitutedExprs.empty())
17231723
Type = SubstitutedExprs[*Index]->getType();
17241724
else
1725-
Type = Context.DependentTy;
1725+
Type = PackIdExpr->getType();
17261726

17271727
void *Storage =
17281728
Context.Allocate(totalSizeToAlloc<Expr *>(SubstitutedExprs.size()));

clang/lib/Driver/ToolChains/OHOS.cpp

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include "llvm/ProfileData/InstrProf.h"
2020
#include "llvm/Support/FileSystem.h"
2121
#include "llvm/Support/Path.h"
22-
#include "llvm/Support/VirtualFileSystem.h"
2322
#include "llvm/Support/ScopedPrinter.h"
23+
#include "llvm/Support/VirtualFileSystem.h"
2424

2525
using namespace clang::driver;
2626
using namespace clang::driver::toolchains;
@@ -58,11 +58,9 @@ static bool findOHOSMuslMultilibs(const Driver &D,
5858
return false;
5959
}
6060

61-
static bool findOHOSMultilibs(const Driver &D,
62-
const ToolChain &TC,
63-
const llvm::Triple &TargetTriple,
64-
StringRef Path, const ArgList &Args,
65-
DetectedMultilibs &Result) {
61+
static bool findOHOSMultilibs(const Driver &D, const ToolChain &TC,
62+
const llvm::Triple &TargetTriple, StringRef Path,
63+
const ArgList &Args, DetectedMultilibs &Result) {
6664
Multilib::flags_list Flags;
6765
bool IsA7 = false;
6866
if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
@@ -172,8 +170,7 @@ OHOS::OHOS(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
172170
Paths);
173171
}
174172

175-
ToolChain::RuntimeLibType OHOS::GetRuntimeLibType(
176-
const ArgList &Args) const {
173+
ToolChain::RuntimeLibType OHOS::GetRuntimeLibType(const ArgList &Args) const {
177174
if (Arg *A = Args.getLastArg(clang::driver::options::OPT_rtlib_EQ)) {
178175
StringRef Value = A->getValue();
179176
if (Value != "compiler-rt")
@@ -184,20 +181,19 @@ ToolChain::RuntimeLibType OHOS::GetRuntimeLibType(
184181
return ToolChain::RLT_CompilerRT;
185182
}
186183

187-
ToolChain::CXXStdlibType
188-
OHOS::GetCXXStdlibType(const ArgList &Args) const {
184+
ToolChain::CXXStdlibType OHOS::GetCXXStdlibType(const ArgList &Args) const {
189185
if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) {
190186
StringRef Value = A->getValue();
191187
if (Value != "libc++")
192188
getDriver().Diag(diag::err_drv_invalid_stdlib_name)
193-
<< A->getAsString(Args);
189+
<< A->getAsString(Args);
194190
}
195191

196192
return ToolChain::CST_Libcxx;
197193
}
198194

199195
void OHOS::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
200-
ArgStringList &CC1Args) const {
196+
ArgStringList &CC1Args) const {
201197
const Driver &D = getDriver();
202198
const llvm::Triple &Triple = getTriple();
203199
std::string SysRoot = computeSysRoot();
@@ -258,7 +254,7 @@ void OHOS::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
258254
}
259255

260256
void OHOS::AddCXXStdlibLibArgs(const ArgList &Args,
261-
ArgStringList &CmdArgs) const {
257+
ArgStringList &CmdArgs) const {
262258
switch (GetCXXStdlibType(Args)) {
263259
case ToolChain::CST_Libcxx:
264260
CmdArgs.push_back("-lc++");
@@ -291,7 +287,8 @@ ToolChain::path_list OHOS::getRuntimePaths() const {
291287

292288
// First try the triple passed to driver as --target=<triple>.
293289
P.assign(D.ResourceDir);
294-
llvm::sys::path::append(P, "lib", D.getTargetTriple(), SelectedMultilib.gccSuffix());
290+
llvm::sys::path::append(P, "lib", D.getTargetTriple(),
291+
SelectedMultilib.gccSuffix());
295292
Paths.push_back(P.c_str());
296293

297294
// Second try the normalized triple.
@@ -340,26 +337,20 @@ std::string OHOS::getDynamicLinker(const ArgList &Args) const {
340337

341338
std::string OHOS::getCompilerRT(const ArgList &Args, StringRef Component,
342339
FileType Type) const {
340+
std::string CRTBasename =
341+
buildCompilerRTBasename(Args, Component, Type, /*AddArch=*/false);
342+
343343
SmallString<128> Path(getDriver().ResourceDir);
344344
llvm::sys::path::append(Path, "lib", getMultiarchTriple(getTriple()),
345-
SelectedMultilib.gccSuffix());
346-
const char *Prefix =
347-
Type == ToolChain::FT_Object ? "" : "lib";
348-
const char *Suffix;
349-
switch (Type) {
350-
case ToolChain::FT_Object:
351-
Suffix = ".o";
352-
break;
353-
case ToolChain::FT_Static:
354-
Suffix = ".a";
355-
break;
356-
case ToolChain::FT_Shared:
357-
Suffix = ".so";
358-
break;
359-
}
360-
llvm::sys::path::append(
361-
Path, Prefix + Twine("clang_rt.") + Component + Suffix);
362-
return static_cast<std::string>(Path.str());
345+
SelectedMultilib.gccSuffix(), CRTBasename);
346+
if (getVFS().exists(Path))
347+
return std::string(Path);
348+
349+
std::string NewPath = ToolChain::getCompilerRT(Args, Component, Type);
350+
if (getVFS().exists(NewPath))
351+
return NewPath;
352+
353+
return std::string(Path);
363354
}
364355

365356
void OHOS::addExtraOpts(llvm::opt::ArgStringList &CmdArgs) const {
@@ -396,7 +387,7 @@ SanitizerMask OHOS::getSupportedSanitizers() const {
396387

397388
// TODO: Make a base class for Linux and OHOS and move this there.
398389
void OHOS::addProfileRTLibs(const llvm::opt::ArgList &Args,
399-
llvm::opt::ArgStringList &CmdArgs) const {
390+
llvm::opt::ArgStringList &CmdArgs) const {
400391
// Add linker option -u__llvm_profile_runtime to cause runtime
401392
// initialization module to be linked in.
402393
if (needsProfileRT(Args))
@@ -413,7 +404,8 @@ ToolChain::path_list OHOS::getArchSpecificLibPaths() const {
413404
return Paths;
414405
}
415406

416-
ToolChain::UnwindLibType OHOS::GetUnwindLibType(const llvm::opt::ArgList &Args) const {
407+
ToolChain::UnwindLibType
408+
OHOS::GetUnwindLibType(const llvm::opt::ArgList &Args) const {
417409
if (Args.getLastArg(options::OPT_unwindlib_EQ))
418410
return Generic_ELF::GetUnwindLibType(Args);
419411
return GetDefaultUnwindLibType();

clang/lib/Format/Format.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,7 @@ template <> struct MappingTraits<FormatStyle> {
11661166
IO.mapOptional("TypeNames", Style.TypeNames);
11671167
IO.mapOptional("TypenameMacros", Style.TypenameMacros);
11681168
IO.mapOptional("UseTab", Style.UseTab);
1169+
IO.mapOptional("VariableTemplates", Style.VariableTemplates);
11691170
IO.mapOptional("VerilogBreakBetweenInstancePorts",
11701171
Style.VerilogBreakBetweenInstancePorts);
11711172
IO.mapOptional("WhitespaceSensitiveMacros",

clang/lib/Format/FormatToken.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ namespace format {
186186
TYPE(UnionLBrace) \
187187
TYPE(UnionRBrace) \
188188
TYPE(UntouchableMacroFunc) \
189+
TYPE(VariableTemplate) \
189190
/* Like in 'assign x = 0, y = 1;' . */ \
190191
TYPE(VerilogAssignComma) \
191192
/* like in begin : block */ \

clang/lib/Format/FormatTokenLexer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ FormatTokenLexer::FormatTokenLexer(
7676
TemplateNames.insert(&IdentTable.get(TemplateName));
7777
for (const auto &TypeName : Style.TypeNames)
7878
TypeNames.insert(&IdentTable.get(TypeName));
79+
for (const auto &VariableTemplate : Style.VariableTemplates)
80+
VariableTemplates.insert(&IdentTable.get(VariableTemplate));
7981
}
8082

8183
ArrayRef<FormatToken *> FormatTokenLexer::lex() {
@@ -1382,6 +1384,8 @@ FormatToken *FormatTokenLexer::getNextToken() {
13821384
FormatTok->setFinalizedType(TT_TemplateName);
13831385
else if (TypeNames.contains(Identifier))
13841386
FormatTok->setFinalizedType(TT_TypeName);
1387+
else if (VariableTemplates.contains(Identifier))
1388+
FormatTok->setFinalizedType(TT_VariableTemplate);
13851389
}
13861390
}
13871391

clang/lib/Format/FormatTokenLexer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ class FormatTokenLexer {
129129

130130
llvm::SmallMapVector<IdentifierInfo *, TokenType, 8> Macros;
131131

132-
llvm::SmallPtrSet<IdentifierInfo *, 8> TemplateNames, TypeNames;
132+
llvm::SmallPtrSet<IdentifierInfo *, 8> TemplateNames, TypeNames,
133+
VariableTemplates;
133134

134135
bool FormattingDisabled;
135136

0 commit comments

Comments
 (0)