ChuanqiXu9 wrote:

> > With both PRs I'm getting at least this Clang assertion error on some of 
> > our code. There's more, and I'll try to create a reproducer for this one, 
> > but maybe the stack trace is enough to figure out what's wrong:
> > ```
> > assert.h assertion failed at clang/include/clang/AST/Redeclarable.h:262 in 
> > redecl_iterator 
> > &clang::Redeclarable<clang::TagDecl>::redecl_iterator::operator++() [de
> > cl_type = clang::TagDecl]: 0 && "Passed first decl twice, invalid redecl 
> > chain!"
> >     @     0x561251408044  __assert_fail
> >     @     0x56124c214b91  clang::ASTDeclMerger::MergeDefinitionData()
> >     @     0x56124c21722e  
> > clang::ASTDeclReader::VisitClassTemplateSpecializationDeclImpl()
> >     @     0x56124c207953  clang::declvisitor::Base<>::Visit()
> >     @     0x56124c207135  clang::ASTDeclReader::Visit()
> >     @     0x56124d69ddcf  
> > clang::StackExhaustionHandler::runWithSufficientStackSpace()
> > ```
> 
> Thanks for testing! "Luckily" it's the exact code that I touched in 
> `MergeDefinitionData` in #170090. I guess it comes down to @ChuanqiXu9's 
> comment in [#170090 
> (comment)](https://github.com/llvm/llvm-project/pull/170090#discussion_r2576320393)
>  that `redecls()` can trigger deserialization and that may invalidate the 
> iterator (?). Unfortunately, I don't have an easy idea to fix it - going back 
> to the old code and just calling `getMostRecentDecl` at the beginning doesn't 
> pass the `Modules/GH170084.cpp` test case...

I feel it may not be too hard to implement a `noload_redecls()`. You can get 
the most recent decl without calling `getMostRecentDecl ()` (that will trigger 
the deserialization of all redecls, I hate it) in Redeclarable.h internally. 
And you can simply traverse the redecls.

https://github.com/llvm/llvm-project/pull/133057
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to