FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codeql/cpp/ql/src/Critical/DeadCodeFunction.ql at codeql-cli/v2.15.5 · github/codeql · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
github
/
codeql
Public
Notifications
You must be signed in to change notification settings
Fork
2.1k
Star
10k
Code
Issues
997
Pull requests
454
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
codeql
/
cpp
/
ql
/
src
/
Critical
/
DeadCodeFunction.ql
Copy path
More file actions
More file actions
Latest commit
History
History
History
36 lines (32 loc) · 1 KB
Breadcrumbs
codeql
/
cpp
/
ql
/
src
/
Critical
/
DeadCodeFunction.ql
Copy path
File metadata and controls
36 lines (32 loc) · 1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* @name Function is never called
* @description Unused functions may increase object size, decrease readability, and create the possibility of misuse.
* @kind problem
* @id cpp/dead-code-function
* @problem.severity warning
* @tags maintainability
* external/cwe/cwe-561
*/
import
cpp
predicate
limitedScope
(
Function
f
)
{
f
.
isStatic
(
)
and
not
f
instanceof
MemberFunction
or
f
.
(
MemberFunction
)
.
isPrivate
(
)
}
predicate
uncalled
(
Function
f
)
{
limitedScope
(
f
)
and
not
exists
(
Function
g
|
g
=
f
or
g
=
f
.
(
VirtualFunction
)
.
getAnOverriddenFunction
+
(
)
|
exists
(
g
.
getACallToThisFunction
(
)
)
or
exists
(
FunctionAccess
fa
|
fa
.
getTarget
(
)
=
g
)
)
}
from
Function
f
where
uncalled
(
f
)
and
forall
(
Function
instance
|
f
.
(
TemplateFunction
)
.
getAnInstantiation
(
)
=
instance
|
uncalled
(
instance
)
)
and
// tweaks for good results:
exists
(
f
.
getBlock
(
)
)
and
not
(
f
instanceof
Constructor
or
f
instanceof
Destructor
or
f
.
hasName
(
"operator="
)
)
select
f
,
"Dead Code: this function is never called."
Back
|
FazBrowse Home
|
New Git URL