[Lldb-commits] [PATCH] D35083: [TypeSystem] Guard the global `ASTSourceMap` with a mutex

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Sun Jul 9 06:15:02 PDT 2017

labath added a comment.

In https://reviews.llvm.org/D35083#802400, @jingham wrote:

> Ah, maybe you meant applying the thread safety annotation to Sean's solution to enforce the contract.  That's an interesting solution, but makes a non-straightforward solution even more non-straightforward, so I agree this isn't the best example...

Actually, I meant applying the annotations to *your* solution :). The "alternatively" meant that instead of passing the by-reference locker argument to enforce the contract, you would annotate the function like:

  static GetASTMap() REQUIRES_CAPABILITY(my_mutex)

Then the caller could just lock the mutex any way he likes and the compiler would smack him on the head if he forgets that.

However, after playing around with this more, I have become less enthusiastic about it -- it basically requires you to wrap all locking primitives with your own (annotated) classes (recent libc++'s have them out of the box, but only on std::mutex). So, maybe you should just ignore my comments :)



More information about the lldb-commits mailing list