[PATCH] D43462: [clangd] Fixes for #include insertion.

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 19 10:16:08 PST 2018


ilya-biryukov added inline comments.


================
Comment at: clangd/index/CanonicalIncludes.cpp:21
                                    llvm::StringRef CanonicalPath) {
   addRegexMapping((llvm::Twine("^") + llvm::Regex::escape(Path) + "$").str(),
                   CanonicalPath);
----------------
ilya-biryukov wrote:
> Technically, if one thread initializes `CanonicalIncludes` and the other thread reads from it, this is a data race.
> Maybe we're ok with our current usage, but I don't have enough confidence in that (i.e. don't know C++'s memory model good enough) and would advice to take the lock in other functions of `CanonicalIncludes` too.
> 
As Sam pointed out, it's fine the way it is right now. We don't want any thread-safety guarantees from the non-const methods of the class.
But could you please add a comment to the class that non-const methods of it are not thread-safe even though it has a `mutex` inside?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43462





More information about the cfe-commits mailing list