Cpp.FieldExpression Class
Namespace: Cpp
Superclasses: AstNodeProperties
Represents the field_expression nodes in the syntax tree of your code
Since R2026a
Description
The PQL class FieldExpression represents the node field_expression in the syntax tree of your code.
struct S { int x; };
void f() {
S s;
int a = s.x;
S* p = &s;
int b = p->x;
}The s.x and p->x expressions in f correspond to field_expression nodes and are what Cpp.FieldExpression models.
Predicates
| Type | Raisable | Printable |
|---|---|---|
FieldExpression
| Yes | No |
This class defines these predicates that act on the objects of this class. In addition, objects of this class can access the predicates defined by the base class AstNodeProperties. An object of this class is an object of AstNodeProperties class.
| Predicates | Description | Example |
|---|---|---|
is(required FieldExpression &fe)
| Checks whether a syntax node is a field_expression and
returns the node fe for further queries. | This PQL defect checks for defect find_field_expr =
when
Cpp.FieldExpression.is(&fe)
and fe.nodeText(&txt)
raise "Found field expression: \"{txt}\""
on feIn this C++ code the defect finds each member access
expression such as
struct S { int x; };
void g() {
S s;
int v = s.x; // matched
} |
cast(Cpp.Node.Node node, required FieldExpression &cast)
| Converts a generic Node to a
FieldExpression when the node is a
field_expression and returns the converted node as
cast. | This PQL defect checks whether a generic defect cast_node_to_field =
when
Cpp.Node.is(&node)
and Cpp.FieldExpression.cast(node, &cast)
and cast.nodeText(&txt)
raise "cast succeeded: \"{txt}\""
on castIn this C++ code the defect finds the nodes that are
of type
struct S { int x; };
void h() {
S s;
int t = s.x; // node convertible to FieldExpression
} |
isa(Cpp.Node.Node node)
| Tests whether a Node is a field_expression without binding it. | This PQL defect checks whether a defect node_is_field_expr =
when
Cpp.Node.is(&node)
and Cpp.FieldExpression.isa(node)
raise "Node is a FieldExpression"
on feIn this C++ code the defect finds checks if a generic
node is a
struct S { int x; };
void k() {
S s;
S* p = &s;
int r = p->x; // isa true for this node
} |
argument(FieldExpression self, Cpp.Node.Node &child)
| Selects the left-hand side of a member access expression such as the obj in obj.field or obj->field. |
This PQL defect checks for the object (argument) part of a defect find_argument =
when
Cpp.FieldExpression.is(&fe)
and fe.argument(&child)
and child.nodeText(&txt)
raise "Argument part: \"{txt}\""
on childIn this C++ code the defect reports the expression used as the object in
struct S { int x; };
void m() {
S s;
int a = s.x; // argument is 's'
} |
field(FieldExpression self, Cpp.Node.Node &child)
| Selects the member name on the right-hand side of a member access such as the field in obj.field or obj->field. |
This PQL defect checks for the member identifier part of a defect find_field_name =
when
Cpp.FieldExpression.is(&fe)
and fe.field(&child)
and child.nodeText(&txt)
raise "Field name: \"{txt}\""
on childIn this C++ code the defect reports the member name
struct S { int x; };
void n() {
S s;
int b = s.x; // field is 'x'
} |
operator(FieldExpression self, Cpp.Node.Node &child)
| Selects the operator token that performs member access such as . or ->. |
This PQL defect checks for the operator token inside a defect find_member_operator =
when
Cpp.FieldExpression.is(&fe)
and fe.operator(&child)
and child.nodeText(&txt)
raise "Member operator: \"{txt}\""
on childIn this C++ code the defect will match the
struct S { int x; };
void o() {
S s;
S* p = &s;
int u = s.x; // operator is '.'
int v = p->x; // operator is '->'
} |
getEnclosingFieldExpression(Cpp.Node.Node child, required FieldExpression &parent)
| Finds the nearest enclosing field_expression that contains child and binds it to parent. | This PQL defect checks which defect enclosing_field_expr =
when
Cpp.Identifier.is(&iden)
and iden.toNode(&node)
and Cpp.FieldExpression.getEnclosingFieldExpression(node, &parent)
and parent.nodeText(&txt)
raise "Enclosing field expression: \"{txt}\""
on parentIn this C++ code the finds a
struct S { int x; };
void p() {
S s;
int z = s.x; // enclosing field_expression for 's' is 's.x'
} |
isEnclosedInFieldExpression(Cpp.Node.Node child)
| Tests whether a node has a field_expression ancestor anywhere above it in the syntax tree. | This PQL defect checks if a particular node is inside a
defect child_in_field_expr =
when
Cpp.Identifier.is(&iden)
and iden.toNode(&node)
and Cpp.FieldExpression.isEnclosedInFieldExpression(node)
raise "Identifier is enclosed in a field expression"
on idenIn this C++ code the defect finds identifier nodes that are enclosed in a field expression.
struct S { int x; };
void q() {
S s;
int y = s.x; // 'x' is enclosed in a field_expression
} |
Version History
Introduced in R2026a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)