Make ASTContext explicitly keep track of the declaration for the C

FILE type, rather than using name lookup to find FILE within the
translation unit. Within precompiled headers, FILE is treated as yet
another "special type" (like __builtin_va_list).

This change should provide a performance improvement (not verified),
since the lookup into the translation unit declaration 
forces the (otherwise unneeded) construction of a large hash table.
More importantly, with precompiled headers, the construction
of that table requires deserializing most of the top-level
declarations from the precompiled header, which are then unused.

Fixes PR 4509.

llvm-svn: 74911
This commit is contained in:
Douglas Gregor
2009-07-07 16:35:42 +00:00
parent 4f3675ca73
commit 27821cee82
7 changed files with 62 additions and 11 deletions

View File

@@ -1536,6 +1536,17 @@ void PCHReader::InitializeContext(ASTContext &Ctx) {
if (unsigned FastEnum
= SpecialTypes[pch::SPECIAL_TYPE_OBJC_FAST_ENUMERATION_STATE])
Context->setObjCFastEnumerationStateType(GetType(FastEnum));
if (unsigned File = SpecialTypes[pch::SPECIAL_TYPE_FILE]) {
QualType FileType = GetType(File);
assert(!FileType.isNull() && "FILE type is NULL");
if (const TypedefType *Typedef = FileType->getAsTypedefType())
Context->setFILEDecl(Typedef->getDecl());
else {
const TagType *Tag = FileType->getAsTagType();
assert(Tag && "Invalid FILE type in PCH file");
Context->setFILEDecl(Tag->getDecl());
}
}
}
/// \brief Retrieve the name of the original source file name