From: David Majnemer Date: Tue, 1 Jul 2014 21:10:07 +0000 (+0000) Subject: AST: Small simplification in VTableBuilder X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=998ac07b10af91ac834f9f9009c6bd52d4538958;p=clang AST: Small simplification in VTableBuilder Stash whether or not we have an RTTI component away instead of recomputing it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212127 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/VTableBuilder.cpp b/lib/AST/VTableBuilder.cpp index 49e13559d7..edc82f8887 100644 --- a/lib/AST/VTableBuilder.cpp +++ b/lib/AST/VTableBuilder.cpp @@ -2446,6 +2446,9 @@ private: MethodVFTableLocationsTy MethodVFTableLocations; + /// \brief Does this class have an RTTI component? + bool HasRTTIComponent; + /// MethodInfo - Contains information about a method in a vtable. /// (Used for computing 'this' pointer adjustment thunks. struct MethodInfo { @@ -2576,8 +2579,9 @@ public: Overriders(MostDerivedClass, CharUnits(), MostDerivedClass) { // Only include the RTTI component if we know that we will provide a // definition of the vftable. - if (Context.getLangOpts().RTTI && - !MostDerivedClass->hasAttr()) + HasRTTIComponent = Context.getLangOpts().RTTI && + !MostDerivedClass->hasAttr(); + if (HasRTTIComponent) Components.push_back(VTableComponent::MakeRTTI(MostDerivedClass)); LayoutVFTable(); @@ -2921,8 +2925,8 @@ void VFTableBuilder::AddMethods(BaseSubobject Base, unsigned BaseDepth, // it requires return adjustment. Insert the method info for this method. unsigned VBIndex = LastVBase ? VTables.getVBTableIndex(MostDerivedClass, LastVBase) : 0; - MethodInfo MI(VBIndex, Context.getLangOpts().RTTI ? Components.size() - 1 - : Components.size()); + MethodInfo MI(VBIndex, + HasRTTIComponent ? Components.size() - 1 : Components.size()); assert(!MethodInfoMap.count(MD) && "Should not have method info for this method yet!");