Make temporary DUContext for default template parameters obsolete

Review Request #106757 - Created Oct. 7, 2012 and submitted

Milian Wolff
Use a thread-local QMultiHash<IndexedQualifiedIdentifier, IndexedType> lookup table to support default template parameters. This obsoletes the necessity of the temporary DUContext which may introduce instabilities as described in bug 297133.

One big caveat was cloning template declarations which contain an internal context. This resulted in both, the original and clone to reference the same internal context. Upon destruction of the clone, the ownership of the internal context was tried to be changed. This can crash, as it could happen while only holding a read lock, yet the referenced internal context is in the DUChain and thus must only be altered while holding a write lock.

This change also makes it possible to remove the code surrounding Declaration::clone and Declaration::clonePrivate, as this was the only places which actually used it. Considering the major pitfalls and caveats of this API, I say this is a very good thing.

Furthermore, while introducing the thread-local data, I fixed the two safety recursion counters: Previously they where shared between threads which does not make any sense when we want to count the recursion depth that is thread-specific.
All existing unit tests pass. KDE Rocs and boost/proto/matches.hpp get parsed without crashing.


  • 0
  • 1
  • 1
  • 2
Description From Last Updated
Milian Wolff
David Nolden
Commit Hook
This review has been submitted with commit e112a01c5c5b3562320afed848725f91e920a3c7 by Milian Wolff to branch master.
Milian Wolff
Review request changed

Status: Closed (submitted)