[PATCH] D134827: [clangd] Avoid recursion on UnresolvedUsingValueDecl during semantic highlighting

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 28 19:30:53 PDT 2022


sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Based on the stacktrace, I came up with this crashing example, maybe it's a usable testcase?

  template <int> class X {
  template <int> class Y {
      using Y<0>::xxx;
  };
  };

(not currently on a machine that can build clangd, so I haven't verified it's the same crash)

Another interesting indirect case

  template <int> class X {
  template <int> class Z;
  template <int> class Y {
      using Z<0>::xxx;
  };
  template <int> class Z {
      using Y<0>::xxx;
  };
  };



================
Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:143
     auto Targets = Resolver->resolveUsingValueDecl(UUVD);
-    if (!Targets.empty()) {
+    if (!Targets.empty() && Targets[0] != UUVD) {
       return kindForDecl(Targets[0], Resolver);
----------------
This looks good+safe.

I wonder if the check should be moved inside resolveUsingValueDecl - having it resolve to itself seems unhelpful always.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134827/new/

https://reviews.llvm.org/D134827



More information about the cfe-commits mailing list