diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-07-30 08:42:33 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-07-30 08:42:33 +0000 |
commit | f8d3864dbe3eafcf211a9f3af87c687e5060af80 (patch) | |
tree | 7a43dcebb6a93ddc1d520915f26e0847ac2794ac /clang/lib/AST/ASTContext.cpp | |
parent | b0042c414e0296b9d3e9cd9b256b63ef28571f1e (diff) | |
download | bcm5719-llvm-f8d3864dbe3eafcf211a9f3af87c687e5060af80.tar.gz bcm5719-llvm-f8d3864dbe3eafcf211a9f3af87c687e5060af80.zip |
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
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index a9d606c60dc..220b61dbe00 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; } |