[PATCH] D94382: [clangd] Avoid recursion in TargetFinder::add()

Nathan Ridge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 10 18:29:38 PST 2021


nridge marked an inline comment as done.
nridge added inline comments.


================
Comment at: clang-tools-extra/clangd/FindTarget.cpp:333
       Decls;
+  const Decl *CurrentlyProcessing = nullptr;
   RelSet Flags;
----------------
njames93 wrote:
> Whats the purpose in tracking this? Is the Decls lookup not enough?
No, because the possibly-recursive call is [here](https://searchfox.org/llvm/rev/9f2d9364b04c4d9651b1ec8612a3968b969fe71d/clang-tools-extra/clangd/FindTarget.cpp#366), but we only insert into `Decls` [here](https://searchfox.org/llvm/rev/9f2d9364b04c4d9651b1ec8612a3968b969fe71d/clang-tools-extra/clangd/FindTarget.cpp#417).


================
Comment at: clang-tools-extra/clangd/FindTarget.cpp:361-364
+    for (const auto &D : Decls)
+      if (D.first == Dcl)
+        return true;
+    return false;
----------------
njames93 wrote:
> Couldn't this just be a map lookup?
Yup, good point!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94382



More information about the cfe-commits mailing list