@@ -12,17 +12,36 @@ import go
1212 * forks.
1313 */
1414module Glog {
15+ string packagePath ( ) {
16+ result =
17+ package ( [
18+ "github.com/golang/glog" , "gopkg.in/glog" , "k8s.io/klog" , "github.com/barakmich/glog"
19+ ] , "" )
20+ }
21+
1522 private class GlogFunction extends Function {
1623 int firstPrintedArg ;
24+ string format ;
25+ string level ;
1726
1827 GlogFunction ( ) {
19- exists ( string pkg , string fn , string level |
20- pkg = package ( [ "github.com/golang/glog" , "gopkg.in/glog" , "k8s.io/klog" ] , "" ) and
28+ exists ( string pkg , string context , int nContextArgs , string depth , int nDepthArgs , string fn |
29+ pkg = packagePath ( ) and
2130 level = [ "Error" , "Exit" , "Fatal" , "Info" , "Warning" ] and
2231 (
23- fn = level + [ "" , "f" , "ln" ] and firstPrintedArg = 0
32+ context = "" and nContextArgs = 0
33+ or
34+ context = "Context" and nContextArgs = 1
35+ ) and
36+ (
37+ depth = "" and nDepthArgs = 0
2438 or
25- fn = level + "Depth" and firstPrintedArg = 1
39+ depth = "Depth" and nDepthArgs = 1
40+ ) and
41+ format = [ "" , "f" , "ln" ] and
42+ (
43+ fn = level + context + depth + format and
44+ firstPrintedArg = nContextArgs + nDepthArgs
2645 )
2746 |
2847 this .hasQualifiedName ( pkg , fn )
@@ -35,10 +54,14 @@ module Glog {
3554 * Gets the index of the first argument that may be output, including a format string if one is present.
3655 */
3756 int getFirstPrintedArg ( ) { result = firstPrintedArg }
57+
58+ predicate formatter ( ) { format = "f" }
59+
60+ override predicate mayReturnNormally ( ) { level != "Fatal" and level != "Exit" }
3861 }
3962
4063 private class StringFormatter extends StringOps:: Formatting:: Range instanceof GlogFunction {
41- StringFormatter ( ) { this .getName ( ) . matches ( "%f" ) }
64+ StringFormatter ( ) { this .formatter ( ) }
4265
4366 override int getFormatStringIndex ( ) { result = super .getFirstPrintedArg ( ) }
4467 }
0 commit comments