From 7a0841ef2f597d3f7bc36385288aedbd781cb80c Mon Sep 17 00:00:00 2001 From: Gabor Marton Date: Mon, 29 Oct 2018 10:18:28 +0000 Subject: [PATCH] [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 llvm-svn: 345496 --- clang/lib/AST/ASTImporter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 0de50ae..df96809 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -3258,6 +3258,9 @@ ExpectedDecl ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) { DC->makeDeclVisibleInContext(ToFunction); } + if (auto *FromCXXMethod = dyn_cast(D)) + ImportOverrides(cast(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::VisitFunctionDecl(FunctionDecl *D) { return ToRedeclOrErr.takeError(); } - if (auto *FromCXXMethod = dyn_cast(D)) - ImportOverrides(cast(ToFunction), FromCXXMethod); - return ToFunction; } -- 2.7.4