Closed balazske closed 6 years ago
Anyway, I am ok with this change if we don't have regression in the CI.
I think the FoundByLookup
should be set anyway to get the decl chain. The import of templated function should work the same way as import of non-templated function (the decl chain is set for both the templates and the functions separately). More tests can be added to check these conditions.
In VisitFunctionTemplateDecl
the prev decl (for the template) is not set at all, maybe incorrectly.
OK, we can check/implement FunctionTemplateDecl
redecl chain related things in another PR.
There is a "endless loop" with this fix when a specific file in protobuf is analyzed. The problem is caused by setting the LexicalDC
of a templated FunctionDecl
to itself. This problem (setting lexical DC to itself) exist even without the change of this PR but the infinite loop does not occur (because hasExternalFormalLinkage
that walks through the parent DeclContext's is called on the template, not the templated function).
The latest code does not produce new errors with test-clang-with-projects.
Upstream of this change is handled together with #314.
This simplification should not make
VisitFunctionDecl
worse than before, and now the handling of templated case is similar as inVisitRecordDecl
. This version can be used for upstream instead of change in #314 (beneath the alreadyimported check).