Skip to content

Comments

C++: Improvements to "Declaration hides parameter"#751

Merged
geoffw0 merged 4 commits intogithub:masterfrom
jbj:hides-parameter-crossfile
Jan 11, 2019
Merged

C++: Improvements to "Declaration hides parameter"#751
geoffw0 merged 4 commits intogithub:masterfrom
jbj:hides-parameter-crossfile

Conversation

@jbj
Copy link
Contributor

@jbj jbj commented Jan 11, 2019

The forum post https://discuss.lgtm.com/t/please-help-me-understand-this-issue-local-variable-buffer-hides-a-parameter-of-the-same-name/1662 prompted me to look at this query. I auto-formatted the query and fixed a performance bug, and then I worked around the issue that was causing false positives. I think it's an extractor bug, and I've filed CPP-331 to track it.

I wasn't able to create a unit test that demonstrates the problem, but you can see how the results change on the jx_application_framework project: before and after.

jbj added 3 commits January 11, 2019 11:02
Bad magic ended up in `LocalVariable.getFunction` and effectively
created a Cartesian product. Before this change, the timing looked like
this:

    Variable::LocalVariable::getFunction_dispred#bb ... 50.1s
    #select#cpe#123#fff ............................... 20.6s

After this change, those predicates become much faster:

    Variable::LocalVariable::getFunction_dispred#ff ... 121ms
    DeclarationHidesParameter::localVariableNames#fff . 77ms
    #select#cpe#123#fff ............................... 28ms

Introducing the predicate `localVariableNames` ensures that we can do
the main join on two columns simultaneously, so that's a change we
should keep even if we remove the `pragma[nomagic]` later.
This change suppresses results from "Declaration hides parameter" where
the ParameterDeclarationEntry does not link up to the right
FunctionDeclarationEntry.
@jbj jbj added the C++ label Jan 11, 2019
@jbj jbj requested a review from geoffw0 January 11, 2019 10:34
@jbj jbj requested a review from a team as a code owner January 11, 2019 10:34
// We also exclude names from functions that have multiple definitions.
// This should not happen in a single application but since we
// have a system wide view it is likely to happen for instance for
// the main function.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this perhaps be a QLDoc comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@geoffw0 geoffw0 merged commit c8cbc8e into github:master Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants