[clang] [AST] Iterate redecls starting from the canonical one in getRawCommentsForAnyRedecl() (PR #108475)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 16 05:07:29 PDT 2024
zyn0217 wrote:
@HighCommander4
I extended your test case a little to validate the `TemplateDeclKind` we would have.
```cpp
struct FoundComment {
std::string DeclName;
bool IsDefinition;
std::string Comment;
comments::DeclInfo::TemplateDeclKind TDK;
// ... comparators are snipped ...
};
```
```cpp
Action.Comments.push_back(FoundComment{
ND->getNameAsString(), IsDefinition(D),
RC ? RC->getRawText(Ctx.getSourceManager()).str() : "",
RC->parse(Ctx, &Action.getCompilerInstance().getPreprocessor(), D)
->getDeclInfo()
->getTemplateKind()});
```
So for the following test case,
```cpp
/// Aaa.
template<typename T, typename U>
void foo(T aaa, U bbb);
/// Bbb.
template<>
void foo(int aaa, int bbb);
```
I didn't see the following failing
```cpp
EXPECT_THAT(
Comments,
testing::ElementsAre(
FoundComment{"foo", false, "/// Aaa.",
comments::DeclInfo::TemplateDeclKind::Template},
FoundComment{
"foo", false, "/// Bbb.",
comments::DeclInfo::TemplateDeclKind::TemplateSpecialization}));
```
Did I misread anything from your last comment?
https://github.com/llvm/llvm-project/pull/108475
More information about the cfe-commits
mailing list