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

Update of Decl 'isUsed' flag at ASTImporter #376

Closed balazske closed 6 years ago

balazske commented 6 years ago

There was a failure in lldb test (issue #374): test_top_level_expressions_dwarf (TestTopLevelExprs.TopLevelExpressionsTestCase) "Should not use decl without marking it used!" This problem should be fixed now.

martong commented 6 years ago

The Decl is first visited (without a DeclRefExpr and in non-used state), then the DeclRefExpr that contains the same Decl object and the 'used' flag is set to true here.

What about setting explicitly the used flag in VisitDeclRefExpr?

martong commented 6 years ago

The same Decl object is tried to be imported more than once

How could that happen? We should assert if we are trying to import something already imported.

balazske commented 6 years ago

"Already imported" means here that Import was called already on it. If Import is called again the existing (imported) object is returned. (With the new changes, the existing object's isUsed value can be updated. I suspect that it is possible that other flags or attributes needs to be updated too.)

martong commented 6 years ago

"Already imported" means here that Import was called already on it. If Import is called again the existing (imported) object is returned.

Then perhaps the flag update could be done in Import(Decl*) right before return. That seems more clean to me than to change in an already misused function which should be const and should not modify its parameters.

balazske commented 6 years ago

Updated code.

martong commented 6 years ago

https://reviews.llvm.org/D48722