ilya-biryukov wrote:

We are seeing some internal tests (and tools) failing because the canonical 
declaration for template specializations has changed in cases like this:
```cpp
template <typename T>
void Foo(T target);  // #1

template <typename T>
void Foo(T defn) {} // #2

template <>
void Foo(int specialization) {} // #3
```

a matcher 
```cpp
functionDecl(
              hasName("Foo"), isDefinition(),
              hasParameter(
                  0, parmVarDecl(hasType(isInt()),
                                 mostCanonicalDecl(parmVarDecl().bind("p")))))),
```

with `mostCanonicalDecl` implemented as
```cpp
  if (const auto* param = clang::dyn_cast<clang::ParmVarDecl>(&Node)) {
    if (const auto* parent = clang::dyn_cast_or_null<clang::FunctionDecl>(
            Node.getParentFunctionOrMethod())) {
      const clang::FunctionDecl* func = parent;
      if (const auto* pattern = func->getTemplateInstantiationPattern()) {
        // Traverse from the instantiation to the pattern.
        func = pattern;
      }
      func = func->getCanonicalDecl();
      if (parent != func) {
         /* remap indicies and get the matching parameter*/
        /* ... */
      }
    }
  }
```
has previously returned `#1` when matching the specialization. Now it returns 
`#2`.

Is this change in the canonical declaration intended?

https://github.com/llvm/llvm-project/pull/111852
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to