AST: Simplify some code

Iterator invalidation issues already force us to do one lookup and one
insert.
Don't use the particular bit-pattern of the 'Align' field to determine
whether or not we have already inserted into the TypeInfo DenseMap;
instead ask for an iterator to the TypeInfo entry.

llvm-svn: 214293
This commit is contained in:
David Majnemer 2014-07-30 08:42:33 +00:00
parent b0042c414e
commit f8d3864dbe
1 changed files with 7 additions and 6 deletions

View File

@ -1432,12 +1432,13 @@ bool ASTContext::isAlignmentRequired(QualType T) const {
}
TypeInfo ASTContext::getTypeInfo(const Type *T) const {
TypeInfo TI = MemoizedTypeInfo[T];
if (!TI.Align) {
// This call can invalidate MemoizedTypeInfo[T], so we need a second lookup.
TI = getTypeInfoImpl(T);
MemoizedTypeInfo[T] = TI;
}
TypeInfoMap::iterator I = MemoizedTypeInfo.find(T);
if (I != MemoizedTypeInfo.end())
return I->second;
// This call can invalidate MemoizedTypeInfo[T], so we need a second lookup.
TypeInfo TI = getTypeInfoImpl(T);
MemoizedTypeInfo[T] = TI;
return TI;
}