Skip to content

Commit 2ef3cc3

Browse files
committed
CPP: Fix for functions with no definition.
1 parent 6f2274a commit 2ef3cc3

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

cpp/ql/src/Critical/LargeParameter.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ where f.getAParameter() = p
3030
exists(FunctionCall fc | fc.getQualifier().getAChild*() = a and not fc.getTarget().hasSpecifier("const"))
3131
)
3232
)
33+
// if there's no block, we can't tell how the parameter is used
34+
and exists(f.getBlock())
3335
select
3436
p, "This parameter of type $@ is " + size.toString() + " bytes - consider passing a const pointer/reference instead.",
3537
t, t.toString()

cpp/ql/test/query-tests/Critical/LargeParameter/LargeParameter.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@
77
| test.cpp:107:16:107:16 | d | This parameter of type $@ is 4100 bytes - consider passing a const pointer/reference instead. | test.cpp:58:8:58:19 | MyLargeClass | MyLargeClass |
88
| test.cpp:108:16:108:16 | e | This parameter of type $@ is 4100 bytes - consider passing a const pointer/reference instead. | test.cpp:58:8:58:19 | MyLargeClass | MyLargeClass |
99
| test.cpp:109:16:109:16 | f | This parameter of type $@ is 4100 bytes - consider passing a const pointer/reference instead. | test.cpp:58:8:58:19 | MyLargeClass | MyLargeClass |
10-
| test.cpp:149:31:149:31 | a | This parameter of type $@ is 4100 bytes - consider passing a const pointer/reference instead. | test.cpp:58:8:58:19 | MyLargeClass | MyLargeClass |

cpp/ql/test/query-tests/Critical/LargeParameter/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,4 @@ MyArithmeticClass operator+(MyArithmeticClass lhs, const MyArithmeticClass &rhs)
146146
return lhs;
147147
}
148148

149-
void myFunction6(MyLargeClass a); // GOOD (no definition, so we can't tell what's done with `a`) [FALSE POSITIVE]
149+
void myFunction6(MyLargeClass a); // GOOD (no definition, so we can't tell what's done with `a`)

0 commit comments

Comments
 (0)