r345496 - [ASTImporter] Import overrides before importing the rest of the chain

Gabor Marton via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 29 03:18:28 PDT 2018


Author: martong
Date: Mon Oct 29 03:18:28 2018
New Revision: 345496

URL: http://llvm.org/viewvc/llvm-project?rev=345496&view=rev
Log:
[ASTImporter] Import overrides before importing the rest of the chain

Summary:
During method import we check for structural eq of two methods.
In the structural eq check we check for their isVirtual() flag. That
flag, however, may depend on the number of overrides. Before this
change we imported the overrides *after* we had imported the rest of the
redecl chain.  So, during the import of another decl from the chain
IsVirtual() gave false result.

Writing tests for this is not really possible, because there is no way
to remove an overridden method via the AST API.
(We should access the private ASTContext::OverriddenMethods container.)
Also, we should do the remove in the middle of the import process.

Reviewers: a_sidorin, a.sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, cfe-commits

Differential Revision: https://reviews.llvm.org/D53704

Modified:
    cfe/trunk/lib/AST/ASTImporter.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=345496&r1=345495&r2=345496&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Mon Oct 29 03:18:28 2018
@@ -3258,6 +3258,9 @@ ExpectedDecl ASTNodeImporter::VisitFunct
     DC->makeDeclVisibleInContext(ToFunction);
   }
 
+  if (auto *FromCXXMethod = dyn_cast<CXXMethodDecl>(D))
+    ImportOverrides(cast<CXXMethodDecl>(ToFunction), FromCXXMethod);
+
   // Import the rest of the chain. I.e. import all subsequent declarations.
   for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
     ExpectedDecl ToRedeclOrErr = import(*RedeclIt);
@@ -3265,9 +3268,6 @@ ExpectedDecl ASTNodeImporter::VisitFunct
       return ToRedeclOrErr.takeError();
   }
 
-  if (auto *FromCXXMethod = dyn_cast<CXXMethodDecl>(D))
-    ImportOverrides(cast<CXXMethodDecl>(ToFunction), FromCXXMethod);
-
   return ToFunction;
 }
 




More information about the cfe-commits mailing list