Decl::getASTContext and DeclContext::getParentASTContext are not that cheap
since they must walk back to the TUDecl, potentially after many cache misses along the way.
Instrumentation shows that most of the iterations in getTranslationUnitDecl could be
eliminated by passing a ref to the ASTContext as a function parameter.
The goal here is not to remove all the calls to getASTContext, but instead
eliminate a good fraction of the iterations in getTranslationUnitDecl.
This patch deals with:
VarDecl::isThisDeclarationADefinition
VarTemplateDecl::isThisDeclarationADefinition
Decl::canBeWeakImported
Decl::isWeakImported
VarDecl::getActingDefinition
ValueDecl::isWeak
VarDecl::checkInitIsICE
ComparisonCategoryInfo::ValueInfo::getIntValue
ComparisonCategoryInfo::ValueInfo::hasValidIntValue
VarDecl::isKnownToBeDefined
VarDecl::getDefinition
VarDecl::hasDefinition
VarTemplateDecl::getDefinition
VarDecl::getTemplateInstantiationPattern
I don't care for this refactoring -- the new code repeats the types from the function definition and is considerably harder to read.