Skip to content

Commit

Permalink
Use arg position instead of arg as class field to reduce number of in…
Browse files Browse the repository at this point in the history
…stances
  • Loading branch information
atorralba committed Jan 10, 2024
1 parent 78c0cdf commit ea21829
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions go/ql/lib/semmle/go/frameworks/stdlib/Log.qll
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,21 @@ module Log {
}

private class LogCall extends LoggerCall::Range, DataFlow::CallNode {
DataFlow::Node messageComponent;
int firstPrintedArg;

LogCall() {
exists(Function f | this = f.getACall() |
f instanceof LogFunction and
messageComponent = this.getASyntacticArgument()
firstPrintedArg = 0
or
f instanceof LogOutput and
messageComponent = this.getSyntacticArgument(1)
firstPrintedArg = 1
)
}

override DataFlow::Node getAMessageComponent() { result = messageComponent }
override DataFlow::Node getAMessageComponent() {
result = this.getSyntacticArgument(any(int i | i >= firstPrintedArg))
}
}

/** A fatal log function, which calls `os.Exit`. */
Expand Down

0 comments on commit ea21829

Please sign in to comment.