mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Do not report "Declaration hides variable" for unnamed variables
This commit is contained in:
@@ -18,6 +18,7 @@ where
|
||||
not lv1.isCompilerGenerated() and
|
||||
not lv2.isCompilerGenerated() and
|
||||
not lv1.getParentScope().(BlockStmt).isInMacroExpansion() and
|
||||
not lv2.getParentScope().(BlockStmt).isInMacroExpansion()
|
||||
not lv2.getParentScope().(BlockStmt).isInMacroExpansion() and
|
||||
not lv1.getName() = "(unnamed local variable)"
|
||||
select lv1, "Variable " + lv1.getName() + " hides another variable of the same name (on $@).", lv2,
|
||||
"line " + lv2.getLocation().getStartLine().toString()
|
||||
|
||||
@@ -1,4 +1,2 @@
|
||||
| hiding.cpp:6:17:6:17 | i | Variable i hides another variable of the same name (on $@). | hiding.cpp:4:13:4:13 | i | line 4 |
|
||||
| hiding.cpp:18:15:18:15 | k | Variable k hides another variable of the same name (on $@). | hiding.cpp:15:11:15:11 | k | line 15 |
|
||||
| hiding.cpp:38:10:38:10 | (unnamed local variable) | Variable (unnamed local variable) hides another variable of the same name (on $@). | hiding.cpp:36:8:36:8 | (unnamed local variable) | line 36 |
|
||||
| hiding.cpp:39:10:39:10 | (unnamed local variable) | Variable (unnamed local variable) hides another variable of the same name (on $@). | hiding.cpp:36:8:36:8 | (unnamed local variable) | line 36 |
|
||||
|
||||
@@ -35,7 +35,7 @@ void structuredBinding() {
|
||||
int xs[1] = {1};
|
||||
auto [x] = xs;
|
||||
{
|
||||
auto [x] = xs; // BAD
|
||||
auto [y] = xs; // GOOD [FALSE POSITIVE]
|
||||
auto [x] = xs; // BAD [NOT DETECTED]
|
||||
auto [y] = xs; // GOOD
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user