File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
cpp/common/src/codingstandards/cpp Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -17,3 +17,47 @@ FunctionType getExprCallFunctionType(ExprCall call) {
1717 // Returns a RoutineType
1818 result = call .( ExprCall ) .getChild ( - 1 ) .getType ( ) .( PointerToMemberType ) .getBaseType ( )
1919}
20+
21+ /**
22+ * An `Expr` that is used as an argument to a `Call`, and has helpers to handle with the differences
23+ * between `ExprCall` and `FunctionCall` cases.
24+ */
25+ class CallArgumentExpr extends Expr {
26+ Call call ;
27+ Type paramType ;
28+ int argIndex ;
29+
30+ CallArgumentExpr ( ) {
31+ this = call .getArgument ( argIndex ) and
32+ (
33+ paramType = call .getTarget ( ) .getParameter ( argIndex ) .getType ( )
34+ or
35+ paramType = getExprCallFunctionType ( call ) .getParameterType ( argIndex )
36+ )
37+ }
38+
39+ /**
40+ * Get the `FunctionExpr` or `FunctionCall` that this argument appears in.
41+ */
42+ Call getCall ( ) { result = call }
43+
44+ /**
45+ * Gets the `Type` of the parameter corresponding to this argument, whether its based on the target function or the function pointer type.
46+ */
47+ Type getParamType ( ) { result = paramType }
48+
49+ /**
50+ * Get the argument index of this argument in the call.
51+ */
52+ int getArgIndex ( ) { result = argIndex }
53+
54+ /**
55+ * Get the target `Function` if this is an argument to a `FunctionCall`.
56+ */
57+ Function getKnownFunction ( ) { result = call .getTarget ( ) }
58+
59+ /**
60+ * Get the target `Parameter` if this is an argument to a `FunctionCall`.
61+ */
62+ Parameter getKnownParameter ( ) { result = call .getTarget ( ) .getParameter ( argIndex ) }
63+ }
You can’t perform that action at this time.
0 commit comments