Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IdentifierHiding: Improve performance, address some false positives/false negatives #813

Merged
merged 21 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
27efc31
Remove unused Scope import
lcartey Dec 6, 2024
0c92f2e
DCL53-CPP: Migrate to hidesStrict
lcartey Dec 6, 2024
90d4127
Scope: Remove hides(..) and related predicates
lcartey Dec 7, 2024
6b5021a
Scope: Add getParentScope testing
lcartey Dec 8, 2024
b8b4131
Scope: Address logic flaw creating multiple parents
lcartey Dec 8, 2024
1f8e2ba
Scope: Ensure loop entries have correct parent scope
lcartey Dec 8, 2024
63a60b1
Scope: Address performance issues with excludedViaNestedNamespace
lcartey Dec 8, 2024
1bd839c
Scope: Improve performance of hidesStrict
lcartey Dec 7, 2024
f25507e
Scope: Add a child scope accessor
lcartey Dec 8, 2024
b5ff407
Scope: Adopt use of getAChildScope()
lcartey Dec 8, 2024
dbd3fe6
Scope: Fix the parent scope of catch blocks
lcartey Dec 8, 2024
61521e0
Scope: Simplify mechanism for identifying declaration order
lcartey Dec 8, 2024
47b3fb2
Scope: refactor hides calculation to expose pairs of variables
lcartey Dec 9, 2024
9b7e129
Scope: Special case lambda expressions
lcartey Dec 9, 2024
117d0fb
Scope: Extend getParentScope for lambda expressions
lcartey Dec 9, 2024
411ecde
IdentifierHidden: remove lambda special casing
lcartey Dec 9, 2024
52e1bc1
IdentifierHiding - Add change note
lcartey Dec 9, 2024
cf315ba
Add extra change note entry
lcartey Dec 9, 2024
c56e1ce
TypographicallyDifferent: Update after changes to Scope
lcartey Dec 9, 2024
e563637
Merge branch 'main' into lcartey/scope-performance-fix
knewbury01 Dec 10, 2024
4d31f5f
Update change_notes/2024-12-08-identifier-hiding.md
knewbury01 Dec 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions change_notes/2024-12-08-identifier-hiding.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- `A2-10-1` - `IdentifierHiding.ql`:
- Improved evaluation performance.
- Addressed false negatives where nested loops used the same variable name.
- Exclude cases where a variable declared in a lambda expression shadowed a globa or namespace variable that did not appear in the same translation unit.
knewbury01 marked this conversation as resolved.
Show resolved Hide resolved
- `RULE-5-3` - `IdentifierHidingC.ql`:
knewbury01 marked this conversation as resolved.
Show resolved Hide resolved
- Improved evaluation performance.
- Addressed false negatives where nested loops used the same variable name.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ from UserVariable v, UserVariable hidden
where
not isExcluded(v, ScopePackage::localConstructorInitializedObjectHidesIdentifierQuery()) and
v.getInitializer().getExpr() instanceof ConstructorCall and
hides(hidden, v)
hidesStrict(hidden, v)
select v, "The declaration declares variable " + v.getName() + " that hides $@", hidden,
hidden.getName()
1 change: 0 additions & 1 deletion cpp/cert/src/rules/DCL53-CPP/LocalFunctionDeclaration.ql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import cpp
import codingstandards.cpp.cert
import codingstandards.cpp.Scope

class LocalUserFunctionDeclarationEntry extends FunctionDeclarationEntry {
DeclStmt ds;
Expand Down
Loading
Loading