Ensure we never access a given CXTranslationUnit concurrently.
Review Request #118817 - Created June 18, 2014 and submitted
Ensure we never access a given CXTranslationUnit concurrently. ParseSession's data is moved into ParseSessionData, which is the actual IAstContainer implementation. It also now stores a QMutex. This mutex is implicitly locked inside ParseSession, so you can say a ParseSession is now similar to a QMutexLocker, with the difference that you can exchange the QMutex it operates on. This simplifies the code in the parse job in my opinion. The other places where the ParseSession was used are adapted to operate on the value type instead of the pointer, where appropriate. This patch hopefully fixes the assertions we currently trigger in LLVM debug builds. Further optimizations, to e.g. enable concurrent read-access, can be investigated later on. I'm not really sure it's going to be worth the effort though...
Tests pass and manual testing on a small project seems to work fine as well. I don't have a debug build of llvm though, so if anyone could test that it would be appreciated.
I like the approach. Makes it impossible to access the TU without acquiring the lock first (because you must instantiate a ParseSession object in order to get a hold of CXTranslationUnit from ParseSessionData). Fixes the assert for me and nothing broke as far as I can see.