Commit a0153e2
Parser: skip class members in the buggy-substitute-default-template-args path
The block's own comment already says this path is only needed for free
function templates and that "something else already instantiates them for
the class member functions". When the path is exercised on a CXXMethodDecl
(in particular a CXXConstructorDecl), `Sema::SubstDecl` on the member
template's pattern null-derefs inside
`TemplateDeclInstantiator::InitMethodInstantiation`.
Captured stack from CI (clang 22.1.4) parsing
`<boost/multiprecision/cpp_int.hpp>` with
`--buggy-substitute-default-template-args`:
#0 clang::TemplateDeclInstantiator::InitMethodInstantiation
#1 clang::TemplateDeclInstantiator::VisitCXXMethodDecl
#2 lambda inside Sema::SubstDecl (runWithSufficientStackSpace)
#3 clang::StackExhaustionHandler::runWithSufficientStackSpace
#4 clang::Sema::runWithSufficientStackSpace
#5 clang::Sema::SubstDecl
#6 mrbind::ClangAstVisitor_InstTypesAndCollectNewTypes::VisitFunctionDecl
main.cpp:2815 <- this call site
#7 clang::RecursiveASTVisitor::TraverseCXXConstructorDecl
Adding `!llvm::isa<clang::CXXMethodDecl>(decl)` to the existing
`decl->isTemplated()` check matches the comment and avoids the crash.
This is consistent with the previous commit, which skipped primary
function templates from `InstantiateDefaultArgument` /
`InstantiateFunctionDefinition` for the same class of latent libclang
bug (public Sema API null-derefs on a primary template's pattern).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent fe3473b commit a0153e2
1 file changed
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2689 | 2689 | | |
2690 | 2690 | | |
2691 | 2691 | | |
2692 | | - | |
| 2692 | + | |
| 2693 | + | |
| 2694 | + | |
| 2695 | + | |
| 2696 | + | |
| 2697 | + | |
2693 | 2698 | | |
2694 | 2699 | | |
2695 | 2700 | | |
| |||
0 commit comments