C++: add getUnspecifiedType() for exprs and decls

This commit is contained in:
Robert Marsh
2019-05-20 14:34:01 +01:00
parent 8256f2e736
commit a72fff7ed0
4 changed files with 32 additions and 0 deletions

View File

@@ -270,6 +270,16 @@ abstract class DeclarationEntry extends Locatable {
*/
abstract Type getType();
/**
* Gets the type associated with this declaration entrry after specifiers
* have been deeply stripped and typedefs have been resolved.
*
* For variable declarations, get the type of the variable.
* For function declarations, get the return type of the function.
* For type declarations, get the type being declared.
*/
Type getUnspecifiedType() { result = this.getType().getUnspecifiedType() }
/**
* Holds if this declaration entry has a specifier with the given name.
*/

View File

@@ -133,6 +133,12 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
/** Gets the return type of this function. */
Type getType() { function_return_type(underlyingElement(this),unresolveElement(result)) }
/**
* Gets the return type of this function after specifiers have been deeply
* stripped and typedefs have been resolved.
*/
Type getUnspecifiedType() { result = getType().getUnspecifiedType() }
/** Gets the nth parameter of this function. */
Parameter getParameter(int n) { params(unresolveElement(result),underlyingElement(this),n,_) }

View File

@@ -47,6 +47,12 @@ class Variable extends Declaration, @variable {
/** Gets the type of this variable, after typedefs have been resolved. */
Type getUnderlyingType() { result = this.getType().getUnderlyingType() }
/**
* Gets the type of this variable, after specifiers have been deeply
* stripped and typedefs have been resolved.
*/
Type getUnspecifiedType() { result = this.getType().getUnspecifiedType() }
/**
* Gets the type of this variable prior to deduction caused by the C++11
* `auto` keyword.

View File

@@ -68,6 +68,16 @@ class Expr extends StmtParent, @expr {
*/
Type getUnderlyingType() { result = this.getType().getUnderlyingType() }
/**
* Gets the type of this expression after specifiers have been deeply
* stripped and typedefs have been resolved.
*
* In most cases, this predicate will be the same as getType(). It will
* only differ when the result of getType() is a TypedefType, in which
* case this predicate will (possibly recursively) resolve the typedef.
*/
Type getUnspecifiedType() { result = this.getType().getUnspecifiedType() }
/**
* Gets an integer indicating the type of expression that this represents.
*