[PATCH] D56656: [clangd] Fix a reference invalidation

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 14 02:32:43 PST 2019


ilya-biryukov added inline comments.


================
Comment at: clangd/index/Background.cpp:488
+    Dependencies.push_back(std::move(ToVisit.front()));
+    auto &CurDependency = Dependencies.back();
+    ToVisit.pop();
----------------
ilya-biryukov wrote:
> This reference makes it just as easy to access the vector we'll be modifying inside the loop.
> Can we avoid modifying the values inside the vector completely? I.e. ideally we'll have only `push_back` into the vector and no modifications of the internal references?
> 
Ah, but we don't modify the vector anymore.
Could you leave a comment that `Dependencies` is not modified further in the loop body, so it's fine to have a reference inside it?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56656





More information about the cfe-commits mailing list