[clangd] Fix an inlay-hint crash on a null deduced type.

This commit is contained in:
Haojian Wu
2023-01-07 22:59:50 +01:00
parent 7223bcf04c
commit f7e9d5b43e
2 changed files with 8 additions and 2 deletions

View File

@@ -671,7 +671,8 @@ private:
if (QT->isDecltypeType())
return true;
if (const AutoType *AT = QT->getContainedAutoType())
if (AT->getDeducedType()->isDecltypeType())
if (!AT->getDeducedType().isNull() &&
AT->getDeducedType()->isDecltypeType())
return true;
return false;
}

View File

@@ -1378,11 +1378,16 @@ TEST(TypeHints, Decltype) {
using G = Foo<$g[[decltype(0)]], float>;
auto $h[[h]] = $i[[decltype(0)]]{};
// No crash
/* error-ok */
auto $j[[s]];
)cpp",
ExpectedHint{": int", "a"}, ExpectedHint{": int", "b"},
ExpectedHint{": int", "c"}, ExpectedHint{": int", "e"},
ExpectedHint{": int", "f"}, ExpectedHint{": int", "g"},
ExpectedHint{": int", "h"}, ExpectedHint{": int", "i"});
ExpectedHint{": int", "h"}, ExpectedHint{": int", "i"},
ExpectedHint{": auto", "j"});
}
TEST(DesignatorHints, Basic) {