[clangd] Fix a declare-constructor tweak crash on incomplete fields.

Differential Revision: https://reviews.llvm.org/D124154
This commit is contained in:
Haojian Wu 2022-04-21 11:14:36 +02:00
parent e4085a012c
commit 84051d8226
2 changed files with 4 additions and 0 deletions

View File

@ -178,6 +178,8 @@ private:
// Decide what to do with a field of type C.
static FieldAction considerClassValue(const CXXRecordDecl &C) {
if (!C.hasDefinition())
return Skip;
// We can't always tell if C is copyable/movable without doing Sema work.
// We assume operations are possible unless we can prove not.
bool CanCopy = C.hasUserDeclaredCopyConstructor() ||

View File

@ -23,6 +23,8 @@ TWEAK_TEST(MemberwiseConstructor);
TEST_F(MemberwiseConstructorTest, Availability) {
EXPECT_AVAILABLE("^struct ^S ^{ int x, y; };");
// Verify no crashes on incomplete member fields.
EXPECT_UNAVAILABLE("/*error-ok*/class Forward; class ^A { Forward f;}");
EXPECT_UNAVAILABLE("struct S { ^int ^x, y; }; struct ^S;");
EXPECT_UNAVAILABLE("struct ^S {};");
EXPECT_UNAVAILABLE("union ^S { int x; };");