From: David Majnemer Date: Wed, 30 Jul 2014 08:42:33 +0000 (+0000) Subject: AST: Simplify some code X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f8d3864dbe3eafcf211a9f3af87c687e5060af80;p=platform%2Fupstream%2Fllvm.git 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 --- diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index a9d606c..220b61d 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -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; }