Commit f6970503 authored by Adam Czachorowski's avatar Adam Czachorowski
Browse files

[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
parent 1ba4b82f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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
+6 −0
Original line number Diff line number Diff line
@@ -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) {