[PATCH] D47532: [ASTImporter] Import the whole redecl chain of functions

Gabor Marton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 25 07:39:30 PDT 2018


martong added inline comments.


================
Comment at: unittests/AST/ASTImporterTest.cpp:2021
+
+TEST_P(ImportFriendFunctions,
+       DISABLED_ImportFriendFunctionRedeclChainDefWithClass_ImportTheProto) {
----------------
a_sidorin wrote:
> Could you add comments why these tests are disabled?
Added the comment, plus copied the explanation here as well.

This test is disabled, because ATM we create a redundant FunctionDecl.  We start the import with the definition of `f` then we continue with the import of the type of `f` which involves `X`. During the import of `X` we start again the import of the definition of `f` and then finally we create the node. But then in the first frame of `VisitFunctionDecl` we create a node again since we do not check if such a node exists yet or not. This is being fixed in a separate patch: https://reviews.llvm.org/D47632 .

Backtrace to support the above explanation:
```
#0  clang::ASTNodeImporter::VisitFunctionDecl (this=0x7fffffffae30, D=0xb02b68) at ../../git/llvm/tools/clang/lib/AST/ASTImporter.cpp:2372
#1  0x00007ffff694adbc in clang::declvisitor::Base<clang::declvisitor::make_ptr, clang::ASTNodeImporter, clang::Decl*>::Visit (this=0x7fffffffae30, D=0xb02b68) at tools/clang/include/clang/AST/DeclNodes.inc:389
#2  0x00007ffff690fa64 in clang::ASTImporter::Import (this=0x7fffffffca18, FromD=0xb02b68) at ../../git/llvm/tools/clang/lib/AST/ASTImporter.cpp:6821
#3  0x00007ffff6920570 in clang::ASTNodeImporter::VisitFriendDecl (this=0x7fffffffb1e0, D=0xb02c20) at ../../git/llvm/tools/clang/lib/AST/ASTImporter.cpp:2844
#4  0x00007ffff694a95c in clang::declvisitor::Base<clang::declvisitor::make_ptr, clang::ASTNodeImporter, clang::Decl*>::Visit (this=0x7fffffffb1e0, D=0xb02c20) at tools/clang/include/clang/AST/DeclNodes.inc:71
#5  0x00007ffff690fa64 in clang::ASTImporter::Import (this=0x7fffffffca18, FromD=0xb02c20) at ../../git/llvm/tools/clang/lib/AST/ASTImporter.cpp:6821
#6  0x00007ffff6916a27 in clang::ASTNodeImporter::ImportDeclContext (this=0x7fffffffb9b0, FromDC=0xb02970, ForceImport=true) at ../../git/llvm/tools/clang/lib/AST/ASTImporter.cpp:1161
#7  0x00007ffff69164a0 in clang::ASTNodeImporter::ImportDefinition (this=0x7fffffffb9b0, From=0xb02938, To=0xbcea58, Kind=clang::ASTNodeImporter::IDK_Default) at ../../git/llvm/tools/clang/lib/AST/ASTImporter.cpp:1287
#8  0x00007ffff691bdf0 in clang::ASTNodeImporter::VisitRecordDecl (this=0x7fffffffb9b0, D=0xb02938) at ../../git/llvm/tools/clang/lib/AST/ASTImporter.cpp:2215
#9  0x00007ffff6964678 in clang::declvisitor::Base<clang::declvisitor::make_ptr, clang::ASTNodeImporter, clang::Decl*>::VisitCXXRecordDecl (this=0x7fffffffb9b0, D=0xb02938) at tools/clang/include/clang/AST/DeclNodes.inc:251
#10 0x00007ffff694abe0 in clang::declvisitor::Base<clang::declvisitor::make_ptr, clang::ASTNodeImporter, clang::Decl*>::Visit (this=0x7fffffffb9b0, D=0xb02938) at tools/clang/include/clang/AST/DeclNodes.inc:251
#11 0x00007ffff690fa64 in clang::ASTImporter::Import (this=0x7fffffffca18, FromD=0xb02938) at ../../git/llvm/tools/clang/lib/AST/ASTImporter.cpp:6821
#12 0x00007ffff69128e7 in clang::ASTNodeImporter::VisitRecordType (this=0x7fffffffbac0, T=0xb02720) at ../../git/llvm/tools/clang/lib/AST/ASTImporter.cpp:857
#13 0x00007ffff694a254 in clang::TypeVisitor<clang::ASTNodeImporter, clang::QualType>::Visit (this=0x7fffffffbac0, T=0xb02720) at ../../git/llvm/tools/clang/include/clang/AST/TypeNodes.def:92
#14 0x00007ffff690ff05 in clang::ASTImporter::Import (this=0x7fffffffca18, FromT=...) at ../../git/llvm/tools/clang/lib/AST/ASTImporter.cpp:6765
#15 0x00007ffff691107c in clang::ASTNodeImporter::VisitPointerType (this=0x7fffffffbc50, T=0xb02740) at ../../git/llvm/tools/clang/lib/AST/ASTImporter.cpp:570
#16 0x00007ffff6949fb4 in clang::TypeVisitor<clang::ASTNodeImporter, clang::QualType>::Visit (this=0x7fffffffbc50, T=0xb02740) at ../../git/llvm/tools/clang/include/clang/AST/TypeNodes.def:64
#17 0x00007ffff690ff05 in clang::ASTImporter::Import (this=0x7fffffffca18, FromT=...) at ../../git/llvm/tools/clang/lib/AST/ASTImporter.cpp:6765
#18 0x00007ffff6911d21 in clang::ASTNodeImporter::VisitFunctionProtoType (this=0x7fffffffbf90, T=0xb027e0) at ../../git/llvm/tools/clang/lib/AST/ASTImporter.cpp:712
#19 0x00007ffff694a120 in clang::TypeVisitor<clang::ASTNodeImporter, clang::QualType>::Visit (this=0x7fffffffbf90, T=0xb027e0) at ../../git/llvm/tools/clang/include/clang/AST/TypeNodes.def:80
#20 0x00007ffff690ff05 in clang::ASTImporter::Import (this=0x7fffffffca18, FromT=...) at ../../git/llvm/tools/clang/lib/AST/ASTImporter.cpp:6765
#21 0x00007ffff691d55a in clang::ASTNodeImporter::VisitFunctionDecl (this=0x7fffffffc990, D=0xb02840) at ../../git/llvm/tools/clang/lib/AST/ASTImporter.cpp:2482
#22 0x00007ffff694adbc in clang::declvisitor::Base<clang::declvisitor::make_ptr, clang::ASTNodeImporter, clang::Decl*>::Visit (this=0x7fffffffc990, D=0xb02840) at tools/clang/include/clang/AST/DeclNodes.inc:389
#23 0x00007ffff690fa64 in clang::ASTImporter::Import (this=0x7fffffffca18, FromD=0xb02840) at ../../git/llvm/tools/clang/lib/AST/ASTImporter.cpp:6821
#24 0x00000000004d4673 in clang::ast_matchers::ASTImporterTestBase::Import (this=0xa9e620, From=0xb02840, ToLang=clang::ast_matchers::Lang_CXX) at ../../git/llvm/tools/clang/unittests/AST/ASTImporterTest.cpp:300
```


Repository:
  rC Clang

https://reviews.llvm.org/D47532





More information about the cfe-commits mailing list