@@ -3,7 +3,10 @@ import semmle.code.cpp.models.interfaces.Taint
3
3
import semmle.code.cpp.models.interfaces.Alias
4
4
import semmle.code.cpp.models.interfaces.SideEffect
5
5
6
- /** Pure string functions. */
6
+ /**
7
+ * A function that operates on strings and is pure. That is, its evaluation is
8
+ * guaranteed to be side effect-free.
9
+ */
7
10
private class PureStrFunction extends AliasFunction , ArrayFunction , TaintFunction ,
8
11
SideEffectFunction {
9
12
PureStrFunction ( ) {
@@ -89,7 +92,9 @@ private string strcmp() {
89
92
]
90
93
}
91
94
92
- /** String standard `strlen` function, and related functions for computing string lengths. */
95
+ /**
96
+ * A function such as `strlen` that returns the length of the given string.
97
+ */
93
98
private class StrLenFunction extends AliasFunction , ArrayFunction , SideEffectFunction {
94
99
StrLenFunction ( ) {
95
100
hasGlobalOrStdOrBslName ( [ "strlen" , "strnlen" , "wcslen" ] )
@@ -123,7 +128,10 @@ private class StrLenFunction extends AliasFunction, ArrayFunction, SideEffectFun
123
128
}
124
129
}
125
130
126
- /** Pure functions. */
131
+ /**
132
+ * A function that is pure, that is, its evaluation is guaranteed to be side
133
+ * effect-free. Excludes functions modeled by `PureStrFunction` and `PureMemFunction`.
134
+ */
127
135
private class PureFunction extends TaintFunction , SideEffectFunction {
128
136
PureFunction ( ) { hasGlobalOrStdOrBslName ( [ "abs" , "labs" ] ) }
129
137
@@ -140,7 +148,10 @@ private class PureFunction extends TaintFunction, SideEffectFunction {
140
148
override predicate hasOnlySpecificWriteSideEffects ( ) { any ( ) }
141
149
}
142
150
143
- /** Pure raw-memory functions. */
151
+ /**
152
+ * A function that operates on memory buffers and is pure. That is, its
153
+ * evaluation is guaranteed to be side effect-free.
154
+ */
144
155
private class PureMemFunction extends AliasFunction , ArrayFunction , TaintFunction ,
145
156
SideEffectFunction {
146
157
PureMemFunction ( ) {
0 commit comments