]> granicus.if.org Git - clang/commitdiff
AST: Small simplification in VTableBuilder
authorDavid Majnemer <david.majnemer@gmail.com>
Tue, 1 Jul 2014 21:10:07 +0000 (21:10 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Tue, 1 Jul 2014 21:10:07 +0000 (21:10 +0000)
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

lib/AST/VTableBuilder.cpp

index 49e13559d7fc1d152ac31ec50300168e41a42460..edc82f8887e20397b2afafa7246c2e53fa2af4cc 100644 (file)
@@ -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<DLLImportAttr>())
+    HasRTTIComponent = Context.getLangOpts().RTTI &&
+                       !MostDerivedClass->hasAttr<DLLImportAttr>();
+    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!");