Skip to content

Commit 9541a94

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#3679)
2 parents c0572f6 + ac45cb3 commit 9541a94

File tree

309 files changed

+5646
-1555
lines changed

Some content is hidden

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

309 files changed

+5646
-1555
lines changed

clang-tools-extra/clangd/FeatureModule.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ FeatureModule::Facilities &FeatureModule::facilities() {
2222
return *Fac;
2323
}
2424

25+
void FeatureModuleSet::add(std::unique_ptr<FeatureModule> M) {
26+
Modules.push_back(std::move(M));
27+
}
28+
2529
bool FeatureModuleSet::addImpl(void *Key, std::unique_ptr<FeatureModule> M,
2630
const char *Source) {
2731
if (!Map.try_emplace(Key, M.get()).second) {
@@ -35,3 +39,5 @@ bool FeatureModuleSet::addImpl(void *Key, std::unique_ptr<FeatureModule> M,
3539

3640
} // namespace clangd
3741
} // namespace clang
42+
43+
LLVM_INSTANTIATE_REGISTRY(clang::clangd::FeatureModuleRegistry)

clang-tools-extra/clangd/FeatureModule.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "llvm/ADT/FunctionExtras.h"
1616
#include "llvm/Support/Compiler.h"
1717
#include "llvm/Support/JSON.h"
18+
#include "llvm/Support/Registry.h"
1819
#include <memory>
1920
#include <optional>
2021
#include <type_traits>
@@ -143,9 +144,14 @@ class FeatureModule {
143144

144145
/// A FeatureModuleSet is a collection of feature modules installed in clangd.
145146
///
146-
/// Modules can be looked up by type, or used via the FeatureModule interface.
147-
/// This allows individual modules to expose a public API.
148-
/// For this reason, there can be only one feature module of each type.
147+
/// Modules added with explicit type specification can be looked up by type, or
148+
/// used via the FeatureModule interface. This allows individual modules to
149+
/// expose a public API. For this reason, there can be only one feature module
150+
/// of each type.
151+
///
152+
/// Modules added using a base class pointer can be used only via the
153+
/// FeatureModule interface and can't be looked up by type, thus custom public
154+
/// API (if provided by the module) can't be used.
149155
///
150156
/// The set owns the modules. It is itself owned by main, not ClangdServer.
151157
class FeatureModuleSet {
@@ -172,6 +178,7 @@ class FeatureModuleSet {
172178
const_iterator begin() const { return const_iterator(Modules.begin()); }
173179
const_iterator end() const { return const_iterator(Modules.end()); }
174180

181+
void add(std::unique_ptr<FeatureModule> M);
175182
template <typename Mod> bool add(std::unique_ptr<Mod> M) {
176183
return addImpl(&ID<Mod>::Key, std::move(M), LLVM_PRETTY_FUNCTION);
177184
}
@@ -185,6 +192,8 @@ class FeatureModuleSet {
185192

186193
template <typename Mod> int FeatureModuleSet::ID<Mod>::Key;
187194

195+
using FeatureModuleRegistry = llvm::Registry<FeatureModule>;
196+
188197
} // namespace clangd
189198
} // namespace clang
190199
#endif

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,14 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var
10171017
: static_cast<int>(ErrorResultCode::CheckFailed);
10181018
}
10191019

1020+
FeatureModuleSet ModuleSet;
1021+
for (FeatureModuleRegistry::entry E : FeatureModuleRegistry::entries()) {
1022+
vlog("Adding feature module '{0}' ({1})", E.getName(), E.getDesc());
1023+
ModuleSet.add(E.instantiate());
1024+
}
1025+
if (ModuleSet.begin() != ModuleSet.end())
1026+
Opts.FeatureModules = &ModuleSet;
1027+
10201028
// Initialize and run ClangdLSPServer.
10211029
// Change stdin to binary to not lose \r\n on windows.
10221030
llvm::sys::ChangeStdinToBinary();

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

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4532,6 +4532,139 @@ TEST(CompletionTest, MemberAccessInExplicitObjMemfn) {
45324532
EXPECT_THAT(Result.Completions, ElementsAre());
45334533
}
45344534
}
4535+
4536+
TEST(CompletionTest, ListExplicitObjectOverloads) {
4537+
Annotations Code(R"cpp(
4538+
struct S {
4539+
void foo1(int a);
4540+
void foo2(int a) const;
4541+
void foo2(this const S& self, float a);
4542+
void foo3(this const S& self, int a);
4543+
void foo4(this S& self, int a);
4544+
};
4545+
4546+
void S::foo1(int a) {
4547+
this->$c1^;
4548+
}
4549+
4550+
void S::foo2(int a) const {
4551+
this->$c2^;
4552+
}
4553+
4554+
void S::foo3(this const S& self, int a) {
4555+
self.$c3^;
4556+
}
4557+
4558+
void S::foo4(this S& self, int a) {
4559+
self.$c4^;
4560+
}
4561+
4562+
void test1(S s) {
4563+
s.$c5^;
4564+
}
4565+
4566+
void test2(const S s) {
4567+
s.$c6^;
4568+
}
4569+
)cpp");
4570+
4571+
auto TU = TestTU::withCode(Code.code());
4572+
TU.ExtraArgs = {"-std=c++23"};
4573+
4574+
auto Preamble = TU.preamble();
4575+
ASSERT_TRUE(Preamble);
4576+
4577+
CodeCompleteOptions Opts{};
4578+
4579+
MockFS FS;
4580+
auto Inputs = TU.inputs(FS);
4581+
4582+
{
4583+
auto Result = codeComplete(testPath(TU.Filename), Code.point("c1"),
4584+
Preamble.get(), Inputs, Opts);
4585+
EXPECT_THAT(
4586+
Result.Completions,
4587+
UnorderedElementsAre(AllOf(named("foo1"), signature("(int a)"),
4588+
snippetSuffix("(${1:int a})")),
4589+
AllOf(named("foo2"), signature("(int a) const"),
4590+
snippetSuffix("(${1:int a})")),
4591+
AllOf(named("foo2"), signature("(float a) const"),
4592+
snippetSuffix("(${1:float a})")),
4593+
AllOf(named("foo3"), signature("(int a) const"),
4594+
snippetSuffix("(${1:int a})")),
4595+
AllOf(named("foo4"), signature("(int a)"),
4596+
snippetSuffix("(${1:int a})"))));
4597+
}
4598+
{
4599+
auto Result = codeComplete(testPath(TU.Filename), Code.point("c2"),
4600+
Preamble.get(), Inputs, Opts);
4601+
EXPECT_THAT(
4602+
Result.Completions,
4603+
UnorderedElementsAre(AllOf(named("foo2"), signature("(int a) const"),
4604+
snippetSuffix("(${1:int a})")),
4605+
AllOf(named("foo2"), signature("(float a) const"),
4606+
snippetSuffix("(${1:float a})")),
4607+
AllOf(named("foo3"), signature("(int a) const"),
4608+
snippetSuffix("(${1:int a})"))));
4609+
}
4610+
{
4611+
auto Result = codeComplete(testPath(TU.Filename), Code.point("c3"),
4612+
Preamble.get(), Inputs, Opts);
4613+
EXPECT_THAT(
4614+
Result.Completions,
4615+
UnorderedElementsAre(AllOf(named("foo2"), signature("(int a) const"),
4616+
snippetSuffix("(${1:int a})")),
4617+
AllOf(named("foo2"), signature("(float a) const"),
4618+
snippetSuffix("(${1:float a})")),
4619+
AllOf(named("foo3"), signature("(int a) const"),
4620+
snippetSuffix("(${1:int a})"))));
4621+
}
4622+
{
4623+
auto Result = codeComplete(testPath(TU.Filename), Code.point("c4"),
4624+
Preamble.get(), Inputs, Opts);
4625+
EXPECT_THAT(
4626+
Result.Completions,
4627+
UnorderedElementsAre(AllOf(named("foo1"), signature("(int a)"),
4628+
snippetSuffix("(${1:int a})")),
4629+
AllOf(named("foo2"), signature("(int a) const"),
4630+
snippetSuffix("(${1:int a})")),
4631+
AllOf(named("foo2"), signature("(float a) const"),
4632+
snippetSuffix("(${1:float a})")),
4633+
AllOf(named("foo3"), signature("(int a) const"),
4634+
snippetSuffix("(${1:int a})")),
4635+
AllOf(named("foo4"), signature("(int a)"),
4636+
snippetSuffix("(${1:int a})"))));
4637+
}
4638+
{
4639+
auto Result = codeComplete(testPath(TU.Filename), Code.point("c5"),
4640+
Preamble.get(), Inputs, Opts);
4641+
EXPECT_THAT(
4642+
Result.Completions,
4643+
UnorderedElementsAre(AllOf(named("foo1"), signature("(int a)"),
4644+
snippetSuffix("(${1:int a})")),
4645+
AllOf(named("foo2"), signature("(int a) const"),
4646+
snippetSuffix("(${1:int a})")),
4647+
AllOf(named("foo2"), signature("(float a) const"),
4648+
snippetSuffix("(${1:float a})")),
4649+
AllOf(named("foo3"), signature("(int a) const"),
4650+
snippetSuffix("(${1:int a})")),
4651+
AllOf(named("foo4"), signature("(int a)"),
4652+
snippetSuffix("(${1:int a})"))));
4653+
}
4654+
{
4655+
auto Result = codeComplete(testPath(TU.Filename), Code.point("c6"),
4656+
Preamble.get(), Inputs, Opts);
4657+
EXPECT_THAT(
4658+
Result.Completions,
4659+
UnorderedElementsAre(AllOf(named("foo2"), signature("(int a) const"),
4660+
snippetSuffix("(${1:int a})")),
4661+
AllOf(named("foo2"), signature("(float a) const"),
4662+
snippetSuffix("(${1:float a})")),
4663+
AllOf(named("foo3"), signature("(int a) const"),
4664+
snippetSuffix("(${1:int a})"))));
4665+
}
4666+
}
4667+
45354668
} // namespace
45364669
} // namespace clangd
45374670
} // namespace clang

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,9 @@ Improvements to Clang's diagnostics
455455
potential misaligned members get processed before they can get discarded.
456456
(#GH144729)
457457

458+
- Fixed false positive in ``-Wmissing-noreturn`` diagnostic when it was requiring the usage of
459+
``[[noreturn]]`` on lambdas before C++23 (#GH154493).
460+
458461
Improvements to Clang's time-trace
459462
----------------------------------
460463

0 commit comments

Comments
 (0)