[clang] [clang-tools-extra] [Clang][AST] Introduce `ExplicitInstantiationDecl` to preserve source info and fix diagnostic locations (PR #191658)
Yanzuo Liu via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 12 02:44:49 PDT 2026
================
@@ -683,6 +683,18 @@ class ASTNodeTraverser
Visit(D->getMessage());
}
+ void VisitExplicitInstantiationDecl(const ExplicitInstantiationDecl *D) {
+ // The specialization is already elsewhere in the AST; don't re-traverse it.
+ // Traverse source-location sub-nodes: template arguments and
+ // type-as-written.
+ if (const auto *ArgsAsWritten = D->getTemplateArgsAsWritten())
+ for (unsigned I = 0, E = ArgsAsWritten->NumTemplateArgs; I != E; ++I)
----------------
zwuis wrote:
```cpp
for (TemplateArgumentLoc Loc : ArgsAsWritten->arguments()) {
// ...
}
```
Use range-based `for`. Ditto elsewhere.
https://github.com/llvm/llvm-project/pull/191658
More information about the cfe-commits
mailing list