Skip to content

Commit 2430bf4

Browse files
committed
CPP: Deprecate helper version of getNumArgNeeded.
1 parent 2747864 commit 2430bf4

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

cpp/ql/src/semmle/code/cpp/commons/Printf.qll

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -800,21 +800,24 @@ class FormatLiteral extends Literal {
800800
int getFormatArgumentIndexFor(int n, int mode) {
801801
hasFormatArgumentIndexFor(n, mode) and
802802
result = count(int n2, int mode2 |
803-
hasFormatArgumentIndexFor(n2, mode2) and
804-
(
805-
n2 < n
806-
or
807-
n2 = n and
808-
mode2 < mode
803+
hasFormatArgumentIndexFor(n2, mode2) and
804+
(
805+
n2 < n
806+
or
807+
n2 = n and
808+
mode2 < mode
809+
)
809810
)
810-
)
811811
}
812812

813813
/**
814814
* Gets the number of arguments required by the nth conversion specifier
815815
* of this format string.
816+
*
817+
* DEPRECATED. This was a helper function for `getNumArgNeeded` and is no
818+
* longer required.
816819
*/
817-
int getNumArgNeeded(int n) {
820+
deprecated int getNumArgNeeded(int n) {
818821
exists(this.getConvSpecOffset(n)) and
819822
result = count(int mode | hasFormatArgumentIndexFor(n, mode))
820823
}
@@ -828,7 +831,7 @@ class FormatLiteral extends Literal {
828831
// At least one conversion specifier has a parameter field, in which case,
829832
// they all should have.
830833
result = max(string s | this.getParameterField(_) = s + "$" | s.toInt())
831-
else result = sum(int n, int toSum | toSum = this.getNumArgNeeded(n) | toSum)
834+
else result = count(int n, int mode | hasFormatArgumentIndexFor(n, mode))
832835
}
833836

834837
/**

0 commit comments

Comments
 (0)