[clangd] PopulateSwitch: disable on dependent enums.

If the enum is a dependent type, we would crash somewhere in
getIntWidth(). -Wswitch diagnostic doesn't work on dependent enums
either.

Differential Revision: https://reviews.llvm.org/D92051
This commit is contained in:
Adam Czachorowski 2020-11-24 20:47:37 +01:00
parent 1ba4b82f67
commit f6970503d2
2 changed files with 7 additions and 1 deletions

View File

@ -126,7 +126,7 @@ bool PopulateSwitch::prepare(const Selection &Sel) {
return false;
EnumD = EnumT->getDecl();
if (!EnumD)
if (!EnumD || EnumD->isDependentType())
return false;
// We trigger if there are any values in the enum that aren't covered by the

View File

@ -3084,6 +3084,12 @@ TEST_F(PopulateSwitchTest, Test) {
R""(enum Enum {A,B,b=B}; ^switch (A) {case A:case B:break;})"",
"unavailable",
},
{
// Enum is dependent type
File,
R""(template<typename T> void f() {enum Enum {A}; ^switch (A) {}})"",
"unavailable",
},
};
for (const auto &Case : Cases) {