@@ -3,7 +3,10 @@ import semmle.code.cpp.models.interfaces.Taint
33import semmle.code.cpp.models.interfaces.Alias
44import semmle.code.cpp.models.interfaces.SideEffect
55
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+ */
710private class PureStrFunction extends AliasFunction , ArrayFunction , TaintFunction ,
811 SideEffectFunction {
912 PureStrFunction ( ) {
@@ -89,7 +92,9 @@ private string strcmp() {
8992 ]
9093}
9194
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+ */
9398private class StrLenFunction extends AliasFunction , ArrayFunction , SideEffectFunction {
9499 StrLenFunction ( ) {
95100 hasGlobalOrStdOrBslName ( [ "strlen" , "strnlen" , "wcslen" ] )
@@ -123,7 +128,10 @@ private class StrLenFunction extends AliasFunction, ArrayFunction, SideEffectFun
123128 }
124129}
125130
126- /** Pure functions. */
131+ /**
132+ * A function that is pure, that is, its evaluation is guaranteed to be
133+ * side-effect free. Excludes functions modeled by `PureStrFunction` and `PureMemFunction`.
134+ */
127135private class PureFunction extends TaintFunction , SideEffectFunction {
128136 PureFunction ( ) { hasGlobalOrStdOrBslName ( [ "abs" , "labs" ] ) }
129137
@@ -140,7 +148,10 @@ private class PureFunction extends TaintFunction, SideEffectFunction {
140148 override predicate hasOnlySpecificWriteSideEffects ( ) { any ( ) }
141149}
142150
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+ */
144155private class PureMemFunction extends AliasFunction , ArrayFunction , TaintFunction ,
145156 SideEffectFunction {
146157 PureMemFunction ( ) {
0 commit comments