diff options
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index c7685e4a6dd..ea18d562b43 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1432,11 +1432,14 @@ bool ASTContext::isAlignmentRequired(QualType T) const { } TypeInfo ASTContext::getTypeInfo(const Type *T) const { - TypeInfo &TI = MemoizedTypeInfo[T]; - if (!TI.Align) - TI = getTypeInfoImpl(T); - - return TI; + TypeInfo TI = MemoizedTypeInfo[T]; + if (TI.Align) + return TI; + + // This call can invalidate TI, so we need a second lookup. + TypeInfo Temp = getTypeInfoImpl(T); + MemoizedTypeInfo[T] = Temp; + return Temp; } /// getTypeInfoImpl - Return the size of the specified type, in bits. This |