Cpp.ReferenceDeclarator Class
Namespace: Cpp
Superclasses: AstNodeProperties
Represents the reference_declarator nodes in the syntax tree of your code
Since R2026a
Description
The PQL class ReferenceDeclarator represents the node
reference_declarator in the syntax tree of your code.
int &x;
void foo(int &&... args) {}
struct S { int &field : 3; };The snippet contains three forms of reference_declarator:
Reference —
&xRvalue reference —
&&...argsReference to a bitfield —
&field : 3
Predicates
| Type | Raisable | Printable |
|---|---|---|
ReferenceDeclarator
| 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 ReferenceDeclarator &refDecl)
| Matches any reference_declarator node and returns it as refDecl, useful to locate all reference declarators. |
This PQL defect checks for any defect find_refs =
when
Cpp.ReferenceDeclarator.is(&ref)
and ref.nodeText(&txt)
raise "Found reference declarator: \"{txt}\""
on refIn this C++ code, the defect finds plain reference declarations such as
int &x; |
cast(Cpp.Node.Node node, required ReferenceDeclarator &cast)
| Checks whether node is a reference_declarator; if so, returns that node as cast for further inspection. |
This PQL defect checks whether a generic defect cast_check =
when
Cpp.Node.is(&n, &,&,&)
and Cpp.ReferenceDeclarator.cast(n, &r)
and r.nodeText(&txt)
raise "Node is reference declarator: \"{txt}\""
on rIn this C++ code, the defect detects that the node representing
int &x; |
isa(Cpp.Node.Node node)
| Returns true if node is a reference_declarator; use to test type without extracting the node. |
This PQL defect checks the type of a node and triggers when it is a defect isa_check =
when
Cpp.Node.is(&n, &,&,&)
and Cpp.ReferenceDeclarator.isa(n)
raise "Node is a reference_declarator"
on nIn this C++ code, the defect will identify the node corresponding to
void foo(int &&... args) {} |
variadicDeclarator(ReferenceDeclarator self, Cpp.Node.Node &child)
| Matches the variadic declarator child inside a reference_declarator, e.g., the ... args portion for parameter packs. |
This PQL defect checks for the presence of a variadic declarator inside a defect variadic_check =
when
Cpp.ReferenceDeclarator.is(&r)
and r.variadicDeclarator(&v)
and v.nodeText(&txt)
raise "Variadic part: \"{txt}\""
on vIn this C++ code, the defect finds the
void foo(int &&... args) {} |
typeDeclarator(ReferenceDeclarator self, Cpp.Node.Node &child)
| Selects the type portion inside a reference_declarator, e.g., the int in int &x. | This PQL defect checks for the type node that is part of a
defect type_check =
when
Cpp.ReferenceDeclarator.is(&r)
and r.typeDeclarator(&t)
and t.nodeText(&txt)
raise "Type part: \"{txt}\""
on t |
fieldDeclarator(ReferenceDeclarator self, Cpp.Node.Node &child)
| Matches a field declarator child when a reference_declarator occurs inside a struct/class field (including bit-field syntax). | This PQL defect checks for field declarators nested inside a
defect field_check =
when
Cpp.ReferenceDeclarator.is(&r)
and r.fieldDeclarator(&f)
and f.nodeText(&txt)
raise "Field declarator: \"{txt}\""
on f |
declarator(ReferenceDeclarator self, Cpp.Node.Node &child)
| Captures the declarator identifier or nested declarator node inside a reference_declarator, e.g., the x in int &x. | This PQL defect checks for the inner declarator (identifier) within a
defect decl_check =
when
Cpp.ReferenceDeclarator.is(&r)
and r.declarator(&d)
and d.nodeText(&txt)
raise "Declarator id: \"{txt}\""
on d |
getEnclosingReferenceDeclarator(Cpp.Node.Node child, required ReferenceDeclarator &parent)
| Finds the nearest enclosing reference_declarator ancestor of child and returns it as parent. |
This PQL defect checks for the closest defect enclosing_check =
when
Cpp.Node.is(&n, &,&,&)
and Cpp.ReferenceDeclarator.getEnclosingReferenceDeclarator(n, &parent)
and parent.nodeText(&txt)
raise "Enclosing reference declarator: \"{txt}\""
on parentIn this C++ code, the defect locates the
int &x; |
isEnclosedInReferenceDeclarator(Cpp.Node.Node child) | Matches every reference_declarator ancestor of
child. | This PQL defect checks for any ancestor
defect all_enclosing_check =
when
Cpp.Node.is(&n, &,&,&)
and Cpp.ReferenceDeclarator.isEnclosedInReferenceDeclarator(n)
and n.nodeText(&txt)
raise "Enclosed in Reference declarators: \"{txt}\""
on nIn this C++ code, the defect will find the reference
declarator(s) that enclose
struct S { int &field : 3; }; |
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.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)