<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">On Jul 25, 2013, at 10:16 AM, Timur Iskhodzhanov <<a href="mailto:timurrrr@google.com">timurrrr@google.com</a>> wrote:<br><div><blockquote type="cite"> Fixed wording in one of the comments.<br></blockquote></div><br><div><div>+visitAllOverriddenMethods(const CXXMethodDecl *MD,</div><div>+                          VisitorTy &Visitor,</div><div>+                          OverriddenMethodsSetTy &VisitedMethods) {</div></div><div><br></div><div>Don’t have this take VisitedMethods.  Make the visitor that cares about</div><div>collecting methods collect them.</div><div><br></div><div><div>-ComputeAllOverriddenMethods(const CXXMethodDecl *MD,</div><div>-                            OverriddenMethodsSetTy& OverriddenMethods) {</div><div><br></div></div><div>You can actually leave this function around if you like.  It’s just:</div><div><br></div><div>namespace {</div><div>  struct MethodCollector {</div><div>    OverriddenMethodsSetTy *Methods;</div><div>    bool visit(const CXXMethodDecl *MD) {</div><div>      Methods->push_back(MD);</div><div>      return true;</div><div>    }</div><div>  };</div><div>}</div><div><div>void ComputeAllOverriddenMethods(const CXXMethodDecl *MD,</div><div>                            OverriddenMethodsSetTy& OverriddenMethods) {</div></div><div>  MethodCollector collector = { &OverriddenMethods };</div><div>  visitAllOverriddenMethods(MD, collector);</div><div>}</div><div><br></div><div><div>+static const CXXMethodDecl *</div><div> FindNearestOverriddenMethod(const CXXMethodDecl *MD,</div><div>-                            VTableBuilder::PrimaryBasesSetVectorTy &Bases) {</div><div>+                            BasesSetVectorTy &Bases) {</div></div><div><br></div><div>Sorry, I didn’t mean to ask you to rewrite this algorithm; I just wanted a way to</div><div>re-use the recursive visitation without redundantly copying them out into an array</div><div>if that wasn’t needed.</div><div><br></div><div><div>+    ThisAdjustment ThisAdjustmentOffset;</div><div>+    // Check if this virtual member function overrides</div><div>+    // a method in one of the visited bases.</div><div>+    if (const CXXMethodDecl *OverriddenMD =</div><div>+            FindDirectlyOverriddenMethodInBases(MD, VisitedBases)) {</div><div>+      // Replace the method info of the overridden method with our own</div><div>+      // method - only if it's in the vftable we're laying out.</div><div>+      MethodInfoMapTy::iterator OverriddenMDIterator =</div></div><div><br></div><div>I’m confused about what’s actually going into MethodInfoMap and what</div><div>needs to be replaced, exactly.</div><div><br></div><div>John.</div></body></html>