Model message components for Fprintf and friends more precisely.

This commit is contained in:
Max Schaefer
2020-06-30 09:28:06 +01:00
parent c80314a3fb
commit 25c969d14c

View File

@@ -96,9 +96,17 @@ module Fmt {
/** A call to `Print`, `Fprint`, or similar. */
private class PrintCall extends LoggerCall::Range, DataFlow::CallNode {
PrintCall() { this.getTarget() instanceof Printer or this.getTarget() instanceof Fprinter }
int firstPrintedArg;
override DataFlow::Node getAMessageComponent() { result = this.getAnArgument() }
PrintCall() {
this.getTarget() instanceof Printer and firstPrintedArg = 0
or
this.getTarget() instanceof Fprinter and firstPrintedArg = 1
}
override DataFlow::Node getAMessageComponent() {
result = this.getArgument(any(int i | i >= firstPrintedArg))
}
}
/** The `Fprint` function or one of its variants. */