[PATCH] CodeGen: Implement the hint value for dyn_cast as described in the Itanium C++ ABI.

Benjamin Kramer benny.kra at gmail.com
Sat Feb 2 14:23:54 PST 2013



================
Comment at: lib/CodeGen/CGExprCXX.cpp:1730
@@ +1729,3 @@
+       I != E; ++I) {
+    if (I->Access == AS_public) { // Ignore non-public inheritance.
+      for (CXXBasePath::iterator J = I->begin(), JE = I->end(); J != JE; ++J) {
----------------
Chandler Carruth wrote:
> As Doug commented, a continue seems better here.
done.

================
Comment at: lib/CodeGen/CGExprCXX.cpp:1737-1740
@@ +1736,6 @@
+
+        // Accumulate the base class offsets.
+        const ASTRecordLayout &Layout = Context.getASTRecordLayout(J->Class);
+        Offset +=
+          Layout.getBaseClassOffset(J->Base->getType()->getAsCXXRecordDecl());
+      }
----------------
Chandler Carruth wrote:
> If we're on our second path, you can skip this computation.
done.

================
Comment at: lib/CodeGen/CGExprCXX.cpp:1717
@@ +1716,3 @@
+  CXXBasePaths Paths(/*FindAmbiguities=*/true, /*RecordPaths=*/true,
+                     /*DetectVirtual=*/false);
+
----------------
Chandler Carruth wrote:
> Why not detect virtual? Then the path building can short circuit, and you can just detect it and return the -1?
That would fire on private virtual inheritance, which we don't want to abort on right now. It's arguably a weird edge case but it matches GCC's behavior. This is covered by a case in the test for this change.


http://llvm-reviews.chandlerc.com/D364



More information about the cfe-commits mailing list