diff --git a/ql/lib/semmle/go/Decls.qll b/ql/lib/semmle/go/Decls.qll index 8cfb78ccc9c..515e3f7b9ef 100644 --- a/ql/lib/semmle/go/Decls.qll +++ b/ql/lib/semmle/go/Decls.qll @@ -137,6 +137,8 @@ class FuncDef extends @funcdef, StmtParent, ExprParent { */ DataFlow::CallNode getACall() { result.getACallee() = this } + predicate isVariadic() { getType().isVariadic() } + override string getAPrimaryQlClass() { result = "FuncDef" } } diff --git a/ql/lib/semmle/go/Scopes.qll b/ql/lib/semmle/go/Scopes.qll index 159f0b6bc5d..d10f5d80919 100644 --- a/ql/lib/semmle/go/Scopes.qll +++ b/ql/lib/semmle/go/Scopes.qll @@ -377,6 +377,12 @@ class Function extends ValueEntity, @functionobject { /** Gets the declaration of this function, if any. */ FuncDecl getFuncDecl() { none() } + predicate isVariadic() { + this.(BuiltinFunction).getName() = ["append", "make", "print", "println"] + or + this.(DeclaredFunction).getFuncDecl().isVariadic() + } + /** Holds if this function has no observable side effects. */ predicate mayHaveSideEffects() { none() }