Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 80432d8

Browse filesBrowse files
committed
IdentifierHidden: revert realisitic compile time constant model in lambda hiding
due to performance the simpler heurisitic is better
1 parent a9f55d2 commit 80432d8
Copy full SHA for 80432d8

File tree

Expand file treeCollapse file tree

3 files changed

+4
-6
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+4
-6
lines changed

‎cpp/common/src/codingstandards/cpp/rules/identifierhidden/IdentifierHidden.qll

Copy file name to clipboardExpand all lines: cpp/common/src/codingstandards/cpp/rules/identifierhidden/IdentifierHidden.qll
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import codingstandards.cpp.Customizations
77
import codingstandards.cpp.Exclusions
88
import codingstandards.cpp.Scope
99
import codingstandards.cpp.ConstHelpers
10-
import codingstandards.cpp.Expr
1110

1211
abstract class IdentifierHiddenSharedQuery extends Query { }
1312

@@ -59,11 +58,11 @@ predicate hiddenInLambda(UserVariable outerDecl, UserVariable innerDecl) {
5958
or
6059
//it is a reference that has been initialized with a constant expression.
6160
outerDecl.getType().stripTopLevelSpecifiers() instanceof ReferenceType and
62-
isCompileTimeEvaluatedExpression(outerDecl.getInitializer().getExpr())
61+
outerDecl.getInitializer().getExpr() instanceof Literal
6362
or
64-
//it const non-volatile integral or enumeration type and has been initialized with a constant expression
63+
// //it const non-volatile integral or enumeration type and has been initialized with a constant expression
6564
outerDecl instanceof NonVolatileConstIntegralOrEnumVariable and
66-
isCompileTimeEvaluatedExpression(outerDecl.getInitializer().getExpr())
65+
outerDecl.getInitializer().getExpr() instanceof Literal
6766
or
6867
//it is constexpr and has no mutable members
6968
outerDecl.isConstexpr() and

‎cpp/common/test/rules/identifierhidden/IdentifierHidden.expected

Copy file name to clipboardExpand all lines: cpp/common/test/rules/identifierhidden/IdentifierHidden.expected
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@
1515
| test.cpp:142:9:142:10 | a1 | Declaration is hiding declaration $@. | test.cpp:140:14:140:15 | a1 | a1 |
1616
| test.cpp:147:9:147:10 | a2 | Declaration is hiding declaration $@. | test.cpp:145:20:145:21 | a2 | a2 |
1717
| test.cpp:152:9:152:10 | a3 | Declaration is hiding declaration $@. | test.cpp:150:17:150:18 | a3 | a3 |
18-
| test.cpp:158:9:158:10 | a4 | Declaration is hiding declaration $@. | test.cpp:156:14:156:15 | a4 | a4 |
1918
| test.cpp:164:9:164:10 | a5 | Declaration is hiding declaration $@. | test.cpp:162:13:162:14 | a5 | a5 |

‎cpp/common/test/rules/identifierhidden/test.cpp

Copy file name to clipboardExpand all lines: cpp/common/test/rules/identifierhidden/test.cpp
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void f8() {
155155

156156
const int &a4 = a3;
157157
auto lambda4 = []() {
158-
int a4 = a4 + 1; // NON_COMPLIANT - Lambda can access
158+
int a4 = a4 + 1; // NON_COMPLIANT[FALSE_NEGATIVE] - Lambda can access
159159
// reference initialized with constant expression.
160160
};
161161

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.