Ericsson / clang

Cross Translation Unit analysis capability for Clang Static Analyzer. (Fork of official clang at http://llvm.org/git/clang)
http://clang.llvm.org/
Other
15 stars 10 forks source link

[ASTImporter] Simplified VisitFunctionDecl. #394

Closed balazske closed 6 years ago

balazske commented 6 years ago

This simplification should not make VisitFunctionDecl worse than before, and now the handling of templated case is similar as in VisitRecordDecl. This version can be used for upstream instead of change in #314 (beneath the alreadyimported check).

martong commented 6 years ago

Anyway, I am ok with this change if we don't have regression in the CI.

balazske commented 6 years ago

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.

martong commented 6 years ago

OK, we can check/implement FunctionTemplateDecl redecl chain related things in another PR.

balazske commented 6 years ago

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).

balazske commented 6 years ago

The latest code does not produce new errors with test-clang-with-projects.

balazske commented 6 years ago

Upstream of this change is handled together with #314.