r202870 - First step towards fixing PR18967 - simplify the ComputeThisOffset interface

Timur Iskhodzhanov timurrrr at google.com
Tue Mar 4 11:48:10 PST 2014


FTR, this was reviewed as http://llvm-reviews.chandlerc.com/D2931

2014-03-04 22:17 GMT+04:00 Timur Iskhodzhanov <timurrrr at google.com>:
> Author: timurrrr
> Date: Tue Mar  4 12:17:38 2014
> New Revision: 202870
>
> URL: http://llvm.org/viewvc/llvm-project?rev=202870&view=rev
> Log:
> First step towards fixing PR18967 - simplify the ComputeThisOffset interface
>
> Modified:
>     cfe/trunk/lib/AST/VTableBuilder.cpp
>
> Modified: cfe/trunk/lib/AST/VTableBuilder.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=202870&r1=202869&r2=202870&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/VTableBuilder.cpp (original)
> +++ cfe/trunk/lib/AST/VTableBuilder.cpp Tue Mar  4 12:17:38 2014
> @@ -2511,11 +2511,8 @@ private:
>    }
>
>    /// ComputeThisOffset - Returns the 'this' argument offset for the given
> -  /// method in the given subobject, relative to the beginning of the
> -  /// MostDerivedClass.
> -  CharUnits ComputeThisOffset(const CXXMethodDecl *MD,
> -                              BaseSubobject Base,
> -                              FinalOverriders::OverriderInfo Overrider);
> +  /// method, relative to the beginning of the MostDerivedClass.
> +  CharUnits ComputeThisOffset(FinalOverriders::OverriderInfo Overrider);
>
>    void CalculateVtordispAdjustment(FinalOverriders::OverriderInfo Overrider,
>                                     CharUnits ThisOffset, ThisAdjustment &TA);
> @@ -2686,14 +2683,13 @@ static bool BaseInSet(const CXXBaseSpeci
>  }
>
>  CharUnits
> -VFTableBuilder::ComputeThisOffset(const CXXMethodDecl *MD,
> -                                  BaseSubobject Base,
> -                                  FinalOverriders::OverriderInfo Overrider) {
> +VFTableBuilder::ComputeThisOffset(FinalOverriders::OverriderInfo Overrider) {
>    InitialOverriddenDefinitionCollector Collector;
> -  visitAllOverriddenMethods(MD, Collector);
> +  visitAllOverriddenMethods(Overrider.Method, Collector);
>
>    CXXBasePaths Paths;
> -  Base.getBase()->lookupInBases(BaseInSet, &Collector.Bases, Paths);
> +  Overrider.Method->getParent()->lookupInBases(BaseInSet, &Collector.Bases,
> +                                               Paths);
>
>    // This will hold the smallest this offset among overridees of MD.
>    // This implies that an offset of a non-virtual base will dominate an offset
> @@ -2705,7 +2701,7 @@ VFTableBuilder::ComputeThisOffset(const
>    for (CXXBasePaths::paths_iterator I = Paths.begin(), E = Paths.end();
>         I != E; ++I) {
>      const CXXBasePath &Path = (*I);
> -    CharUnits ThisOffset = Base.getBaseOffset();
> +    CharUnits ThisOffset = Overrider.Offset;
>      CharUnits LastVBaseOffset;
>
>      // For each path from the overrider to the parents of the overridden methods,
> @@ -2736,16 +2732,16 @@ VFTableBuilder::ComputeThisOffset(const
>        }
>      }
>
> -    if (isa<CXXDestructorDecl>(MD)) {
> +    if (isa<CXXDestructorDecl>(Overrider.Method)) {
>        if (LastVBaseOffset.isZero()) {
>          // If a "Base" class has at least one non-virtual base with a virtual
>          // destructor, the "Base" virtual destructor will take the address
>          // of the "Base" subobject as the "this" argument.
> -        return Base.getBaseOffset();
> +        ThisOffset = Overrider.Offset;
>        } else {
>          // A virtual destructor of a virtual base takes the address of the
>          // virtual base subobject as the "this" argument.
> -        return LastVBaseOffset;
> +        ThisOffset = LastVBaseOffset;
>        }
>      }
>
> @@ -2920,7 +2916,7 @@ void VFTableBuilder::AddMethods(BaseSubo
>        MethodInfo &OverriddenMethodInfo = OverriddenMDIterator->second;
>
>        // Create a this-adjusting thunk if needed.
> -      CharUnits TI = ComputeThisOffset(MD, Base, Overrider);
> +      CharUnits TI = ComputeThisOffset(Overrider);
>        if (TI != WhichVFPtr.FullOffsetInMDC) {
>          ThisAdjustmentOffset.NonVirtual =
>              (TI - WhichVFPtr.FullOffsetInMDC).getQuantity();
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list