[cfe-dev] Question about failed assertion ASTMatchFinder.cc "Found node that is not in the parent map."

Manuel Klimek klimek at google.com
Thu Mar 27 08:41:47 PDT 2014


I'll need to look into this more. As a workaround, you can compile without
assertions, and the code should work fine (or just remove the assertion).



On Thu, Mar 27, 2014 at 5:21 AM, Christian Schafmeister <
chris.schaf at verizon.net> wrote:

>
> I isolated the problem to a function call that passes a lambda to another
> function.
> For some reason I get this assertion failure when I run an AST matcher on
> C++ source with a function call that passes a lambda to another function.
>
> Assertion failed: (false && "Found node that is not in the parent map."),
> function memoizedMatchesAncestorOfRecursively, file
> /Users/meister/Development/new_cando/brcl/externals/src/llvm-198807/tools/clang/lib/ASTMatchers/ASTMatchFinder.cpp,
> line 505.
>
>
> I’m in the call stack after the assertion was thrown in the clang function
> ASTMatchersInternal.h:760
>
>   template <typename T>
>   bool matchesAncestorOf(const T &Node,
>                          const DynTypedMatcher &Matcher,
>                          BoundNodesTreeBuilder *Builder,
>                          AncestorMatchMode MatchMode) {
>     TOOLING_COMPILE_ASSERT((llvm::is_base_of<Decl, T>::value ||
>                             llvm::is_base_of<Stmt, T>::value),
>
>  only_Decl_or_Stmt_allowed_for_recursive_matching);
> —>    return matchesAncestorOf(ast_type_traits::DynTypedNode::create(Node),
>                              Matcher, Builder, MatchMode);
>   }
>
>
>
>
> (lldb) call Node.dump()
> call Node.dump()
> CXXRecordDecl 0x130e47260 <../../src/core/serialize.cc:487:30> class
> definition
> |-CXXMethodDecl 0x130e47390 <col:62, line:490:6> operator() 'void
> (mem::smart_ptr<SNode_O>) const' inline
> | |-ParmVarDecl 0x130e471a0 <line:487:34, col:58> node
> 'mem::smart_ptr<SNode_O>':'class mem::smart_ptr<class core::SNode_O>'
> | `-CompoundStmt 0x130e479a0 <col:65, line:490:6>
> |   |-DeclStmt 0x130e47720 <line:488:3, col:28>
> |   | `-VarDecl 0x130e47460 <col:3, col:27> obj 'T_sp':'class
> mem::smart_ptr<class core::T_O>'
> |   |   `-ExprWithCleanups 0x130e47708 <col:14, col:27> 'T_sp':'class
> mem::smart_ptr<class core::T_O>'
> |   |     `-CXXConstructExpr 0x130e476d0 <col:14, col:27> 'T_sp':'class
> mem::smart_ptr<class core::T_O>' 'void (const smart_ptr<class core::T_O>
> &)' elidable
> |   |       `-MaterializeTemporaryExpr 0x130e476b0 <col:14, col:27> 'const
> smart_ptr<class core::T_O>':'const class mem::smart_ptr<class core::T_O>'
> lvalue
> |   |         `-ImplicitCastExpr 0x130e47698 <col:14, col:27> 'const
> smart_ptr<class core::T_O>':'const class mem::smart_ptr<class core::T_O>'
> <NoOp>
> |   |           `-CXXBindTemporaryExpr 0x130e475f8 <col:14, col:27>
> 'T_sp':'class mem::smart_ptr<class core::T_O>' (CXXTemporary 0x130e475f0)
> |   |             `-CXXMemberCallExpr 0x130e475b0 <col:14, col:27>
> 'T_sp':'class mem::smart_ptr<class core::T_O>'
> |   |               `-MemberExpr 0x130e47580 <col:14, col:20> '<bound
> member function type>' ->object 0x130a7ad20
> |   |                 `-ImplicitCastExpr 0x130e475d8 <col:14> 'const class
> core::SNode_O *' <NoOp>
> |   |                   `-CXXOperatorCallExpr 0x130e47540 <col:14> 'class
> core::SNode_O *'
> |   |                     |-ImplicitCastExpr 0x130e47528 <col:18> 'class
> core::SNode_O *(*)(void) const' <FunctionToPointerDecay>
> |   |                     | `-DeclRefExpr 0x130e47500 <col:18> 'class
> core::SNode_O *(void) const' lvalue CXXMethod 0x12b445470 'operator->'
> 'class core::SNode_O *(void) const'
> |   |                     `-ImplicitCastExpr 0x130e474e0 <col:14> 'const
> class mem::tagged_ptr<class core::SNode_O>' lvalue <UncheckedDerivedToBase
> (tagged_ptr)>
> |   |                       `-DeclRefExpr 0x130e474b8 <col:14>
> 'mem::smart_ptr<SNode_O>':'class mem::smart_ptr<class core::SNode_O>'
> lvalue ParmVar 0x130e471a0 'node' 'mem::smart_ptr<SNode_O>':'class
> mem::smart_ptr<class core::SNode_O>'
> |   `-ExprWithCleanups 0x130e47988 <line:489:3, col:25> '_Bool'
> |     `-CXXMemberCallExpr 0x130e47858 <col:3, col:25> '_Bool'
> |       |-MemberExpr 0x130e47800 <col:3, col:8> '<bound member function
> type>' ->loadFinalize 0x12b4300a0
> |       | `-CXXOperatorCallExpr 0x130e477c0 <col:3> 'class core::T_O *'
> |       |   |-ImplicitCastExpr 0x130e477a8 <col:6> 'class core::T_O
> *(*)(void) const' <FunctionToPointerDecay>
> |       |   | `-DeclRefExpr 0x130e47780 <col:6> 'class core::T_O *(void)
> const' lvalue CXXMethod 0x113d6bc80 'operator->' 'class core::T_O *(void)
> const'
> |       |   `-ImplicitCastExpr 0x130e47760 <col:3> 'const class
> mem::tagged_ptr<class core::T_O>' lvalue <UncheckedDerivedToBase
> (tagged_ptr)>
> |       |     `-DeclRefExpr 0x130e47738 <col:3> 'T_sp':'class
> mem::smart_ptr<class core::T_O>' lvalue Var 0x130e47460 'obj' 'T_sp':'class
> mem::smart_ptr<class core::T_O>'
> |       `-CXXBindTemporaryExpr 0x130e47968 <col:21>
> 'core::ArchiveP':'class mem::smart_ptr<class core::SNode_O>' (CXXTemporary
> 0x130e47960)
> |         `-CXXConstructExpr 0x130e47920 <col:21> 'core::ArchiveP':'class
> mem::smart_ptr<class core::SNode_O>' 'void (const smart_ptr<class
> core::SNode_O> &)'
> |           `-ImplicitCastExpr 0x130e47908 <col:21> 'const smart_ptr<class
> core::SNode_O>':'const class mem::smart_ptr<class core::SNode_O>' lvalue
> <NoOp>
> |             `-DeclRefExpr 0x130e47830 <col:21>
> 'mem::smart_ptr<SNode_O>':'class mem::smart_ptr<class core::SNode_O>'
> lvalue ParmVar 0x130e471a0 'node' 'mem::smart_ptr<SNode_O>':'class
> mem::smart_ptr<class core::SNode_O>'
> |-CXXConversionDecl 0x130e47c00 <line:487:30, line:490:6> operator void
> (*)(class mem::smart_ptr<class core::SNode_O>) 'void (*(void)
> const)(mem::smart_ptr<SNode_O>)' inline
> |-CXXMethodDecl 0x130e47cb0 <line:487:30, line:490:6> __invoke 'void
> (mem::smart_ptr<SNode_O>)' static inline
> | `-ParmVarDecl 0x130e47ba0 <line:487:34, col:58> node
> 'mem::smart_ptr<SNode_O>':'class mem::smart_ptr<class core::SNode_O>'
> |-CXXDestructorDecl 0x130e47db0 <col:30> ~ 'void (void) noexcept' inline
> | `-CompoundStmt 0x130e47e98 <col:30>
> |-CXXConstructorDecl 0x130e5ed40 <col:30>  'void (void)' inline
> noexcept-unevaluated 0x130e5ed40
> |-CXXConstructorDecl 0x130e5ee70 <col:30>  'void (const class <lambda at
> ../../src/core/serialize.cc:487:30> &) noexcept' inline
> | |-ParmVarDecl 0x130e5efb0 <col:30> 'const class <lambda at
> ../../src/core/serialize.cc:487:30> &'
> | `-CompoundStmt 0x131c8d988 <col:30>
> `-CXXConstructorDecl 0x130e5f010 <col:30>  'void (class <lambda at
> ../../src/core/serialize.cc:487:30> &&) noexcept' inline
>   |-ParmVarDecl 0x130e5f150 <col:30> 'class <lambda at ../../src/core/
> serialize.cc:487:30> &&'
>   `-CompoundStmt 0x130e5f1d0 <col:30>
> (lldb)
>
>
>
> serialize.cc:487 corresponds to a function call that passes a lambda to
> another function:
>
>     void LoadArchive_O::finalizeObjects()
>     {_G();
> this->_NodesToFinalize.map( [] (mem::smart_ptr<SNode_O> node)  {  //
> <<<<<---- Line 487
> T_sp obj = node->object();
> obj->loadFinalize(node);
>     });
>     }
>
>
> On Mar 26, 2014, at 1:02 PM, Christian Schafmeister <
> chris.schaf at verizon.net> wrote:
>
>
> I ran into an assertion failure while running matchers on my source code.
>
> It will take me several hours of run time to recreate the error in the
> debugger - does anyone have an idea what might be causing this failure?
> Any advice would arm me as I enter into what could be many hours of trying
> to recreate it under conditions where I can interrogate the local variables
> to see what in my source code is causing this problem.
>
>
> Assertion failed: (false && "Found node that is not in the parent map."),
> function memoizedMatchesAncestorOfRecursively, file
> /Users/meister/Development/new_cando/brcl/externals/src/llvm-198807/tools/clang/lib/ASTMatchers/ASTMatchFinder.cpp,
> line 505.
>
> Thanks,
>
> .Chris.
>
>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140327/d9e4df70/attachment.html>


More information about the cfe-dev mailing list