Skip to content

Commit c4a8ac4

Browse files
committed
Add helper predicates for TypeSpec
1 parent 8b9cc99 commit c4a8ac4

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

go/ql/lib/semmle/go/Decls.qll

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,20 @@ class TypeSpec extends @typespec, Spec, TypeParamDeclParent {
381381
string getName() { result = this.getNameExpr().getName() }
382382

383383
/**
384-
* Gets the expression denoting the underlying type to which the newly declared type is bound.
384+
* Gets the declared type of this specifier.
385+
*
386+
* Note that for alias types this will give the underlying type.
387+
*/
388+
Type getDeclaredType() { result = this.getNameExpr().getType() }
389+
390+
/**
391+
* Gets the expression denoting the underlying type to which the declared type is bound.
385392
*/
386393
Expr getTypeExpr() { result = this.getChildExpr(1) }
387394

395+
/** Gets the underlying type to which the declared type is bound. */
396+
Type getRhsType() { result = this.getTypeExpr().getType() }
397+
388398
override string toString() { result = "type declaration specifier" }
389399

390400
override string getAPrimaryQlClass() { result = "TypeSpec" }

0 commit comments

Comments
 (0)