ilya-biryukov added inline comments.

Comment at: clangd/index/CanonicalIncludes.cpp:21
                                    llvm::StringRef CanonicalPath) {
   addRegexMapping((llvm::Twine("^") + llvm::Regex::escape(Path) + "$").str(),
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?

  rCTE Clang Tools Extra

cfe-commits mailing list

Reply via email to