mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
C++: Support attribute arguments that are expressions
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
class AttributeArg extends @attribute_arg {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
class Attribute extends @attribute {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
class Location extends @location_default {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
from AttributeArg arg, int kind, int kind_new, Attribute attr, int index, Location location
|
||||
where
|
||||
attribute_args(arg, kind, attr, index, location) and
|
||||
if arg instanceof @attribute_arg_expr then kind_new = 0 else kind_new = kind
|
||||
select arg, kind_new, attr, index, location
|
||||
2238
cpp/downgrades/d8149ca90e695fe26f9a0c5a7fa0edd6d4ea3f5d/old.dbscheme
Normal file
2238
cpp/downgrades/d8149ca90e695fe26f9a0c5a7fa0edd6d4ea3f5d/old.dbscheme
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,4 @@
|
||||
description: Support expression attribute arguments
|
||||
compatibility: partial
|
||||
attribute_arg_expr.rel: delete
|
||||
attribute_args.rel: run attribute_args.qlo
|
||||
@@ -281,6 +281,11 @@ class AttributeArgument extends Element, @attribute_arg {
|
||||
attribute_arg_constant(underlyingElement(this), unresolveElement(result))
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of this argument, if its value is a expression.
|
||||
*/
|
||||
Expr getValueExpr() { attribute_arg_expr(underlyingElement(this), unresolveElement(result)) }
|
||||
|
||||
/**
|
||||
* Gets the attribute to which this is an argument.
|
||||
*/
|
||||
@@ -308,6 +313,9 @@ class AttributeArgument extends Element, @attribute_arg {
|
||||
else
|
||||
if underlyingElement(this) instanceof @attribute_arg_constant_expr
|
||||
then tail = this.getValueConstant().toString()
|
||||
else
|
||||
if underlyingElement(this) instanceof @attribute_arg_expr
|
||||
then tail = this.getValueExpr().toString()
|
||||
else tail = this.getValueText()
|
||||
) and
|
||||
result = prefix + tail
|
||||
|
||||
@@ -937,6 +937,7 @@ case @attribute_arg.kind of
|
||||
| 2 = @attribute_arg_constant
|
||||
| 3 = @attribute_arg_type
|
||||
| 4 = @attribute_arg_constant_expr
|
||||
| 5 = @attribute_arg_expr
|
||||
;
|
||||
|
||||
attribute_arg_value(
|
||||
@@ -951,6 +952,10 @@ attribute_arg_constant(
|
||||
unique int arg: @attribute_arg ref,
|
||||
int constant: @expr ref
|
||||
)
|
||||
attribute_arg_expr(
|
||||
unique int arg: @attribute_arg ref,
|
||||
int expr: @expr ref
|
||||
)
|
||||
attribute_arg_name(
|
||||
unique int arg: @attribute_arg ref,
|
||||
string name: string ref
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
description: Support expression attribute arguments
|
||||
compatibility: backwards
|
||||
Reference in New Issue
Block a user