Skip to content

[clang] [Index] The requirements are not handled when generates USR for TemplateDecl #125390

Open
@16bit-ykiko

Description

@16bit-ykiko

Consider following example:

template <typename T, typename U>
struct function;

template <typename T, typename U>
    requires (__is_same(U, int))
struct function<T, U> {
    void foo();
};

template <typename T, typename U>
    requires (__is_same(U, float))
struct function<T, U> {
    void foo();
};

The second specialization and third specialization should have different USR, but actually same

c:@SP>2#T#T@function>#t0.0#t0.1
c:@SP>2#T#T@function>#t0.0#t0.1

Thie is beacuse the USRGenerator doesn't handle requirements in TemplateDecl. See

if (const VarTemplateSpecializationDecl *Spec
= dyn_cast<VarTemplateSpecializationDecl>(D)) {
const TemplateArgumentList &Args = Spec->getTemplateArgs();
Out << '>';
for (unsigned I = 0, N = Args.size(); I != N; ++I) {
Out << '#';
VisitTemplateArgument(Args.get(I));
}
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"conceptsC++20 concepts

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions