Cpp.AbstractReferenceDeclarator Class
Namespace: Cpp
Superclasses: AstNodeProperties
Represents the abstract_reference_declarator nodes in the syntax tree of your code
Since R2026a
Description
The PQL class AbstractReferenceDeclarator represents the node abstract_reference_declarator in the syntax tree of your code.
// Rvalue reference abstract declarator int &&; // Lvalue reference abstract declarator int &; // Nested (syntactically odd) reference int &&&;
The examples declare C++ reference types; each && or & in these declarations corresponds to an abstract_reference_declarator node that the AbstractReferenceDeclarator class models.
Predicates
| Type | Raisable | Printable |
|---|---|---|
AbstractReferenceDeclarator
| 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 AbstractReferenceDeclarator &decl)
| Checks whether a node is an abstract_reference_declarator and returns that node as decl. | This PQL defect checks for any
defect findAbstractRef =
when
Cpp.AbstractReferenceDeclarator.is(&decl)
raise "Found abstract reference declarator"
on declIn this C++ code, the defect finds the reference
declarator without a name in the signature of the function
void foo(int&& );// expect-1-Rule1
void bar(){
int&& x = 0;
foo(0);
} |
cast(Cpp.Node.Node node, required AbstractReferenceDeclarator &cast)
| Tests whether a generic Cpp.Node.Node is an abstract_reference_declarator; if so, it returns that node as cast for further checks. | This PQL defect checks for generic nodes that can be cast to
defect castToAbstractRef =
when
Cpp.Node.is(&node, &,&,&)
and Cpp.AbstractReferenceDeclarator.cast(node, &cast)
raise "Node is an abstract_reference_declarator"
on castIn this C++ code, the defect searches the abstract syntax tree for generic nodes and flags the abstract reference declarator nodes
void foo(int&& );// expect-1-Rule1 void foo2(int&); // expect-1-Rule1 |
isa(Cpp.Node.Node node)
| Returns true if the given node is an abstract_reference_declarator; useful in boolean checks or negations. | This PQL defect checks whether a node is an
defect isaAbstractRef =
when
Cpp.Node.is(&node, &,&,&)
and Cpp.AbstractReferenceDeclarator.isa(node)
raise "Node is an abstract_reference_declarator (isa)"
on nodeIn this C++ code, the rule flags nodes that
correspond to
void foo(int&& ); void foo2(int&); |
abstractDeclarator(AbstractReferenceDeclarator self, Cpp.Node.Node &child)
| Returns the inner abstract-declarator child node (e.g., the &&/& component) of an abstract_reference_declarator. | This PQL defect checks for the specific inner abstract-declarator child
inside an
defect findInnerAbstractDecl =
when
Cpp.AbstractReferenceDeclarator.is(&ref)
and ref.abstractDeclarator(&inner)
raise "Found inner abstract declarator"
on inner |
getEnclosingAbstractReferenceDeclarator(Cpp.Node.Node child, required AbstractReferenceDeclarator &parent)
| Finds the nearest enclosing abstract_reference_declarator ancestor of child and returns it as parent. | This PQL defect checks for cases where a given child node sits inside an
defect enclosingAbstractRef =
when
Cpp.Node.is(&child, &,&,&)
and Cpp.AbstractReferenceDeclarator.getEnclosingAbstractReferenceDeclarator(child, &parent)
and child.nodeText(&childTxt)
and parent.nodeText(&parentTxt)
raise "Node \"{childTxt}\" is inside abstract_reference_declarator \"{parentTxt}\""
on parent&& and & and their enclosing
parent abstract declarators are
reported:void foo(int&& );// matches the && node void foo2(int&); // matches the & node |
isEnclosedInAbstractReferenceDeclarator(Cpp.Node.Node
child) | Matches any abstract_reference_declarator ancestor parent that encloses child (not only the nearest); useful to find all enclosing reference declarators. | This PQL defect checks for any ancestor
defect anyEnclosingAbstractRef =
when
Cpp.Node.is(&child, &,&,&)
and Cpp.AbstractReferenceDeclarator.isEnclosedInAbstractReferenceDeclarator(child)
and child.nodeText(&childTxt)
raise "Node \"{childTxt}\" is inside abstract_reference_declarator "
on child&&
and & and their enclosing parent abstract declarators are
reported:void foo(int&& );// matches the && node void foo2(int&); // matches the & node |
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)