This patch includes the commit 01adf96ebc86 and a fix of unhandled declaration
references.
When looking up base classes, Clang first checks whether a base class is a
template and takes the specialized template based on it. However, the base class
might be instantiated, and the above behavior can lose information.
This patch fixes the problem by first checking whether a base class is a record
declaration, so the instantiated one will be taken.