Cpp.ParameterDeclaration Class
Namespace: Cpp
Superclasses: AstNodeProperties
Represents the parameter_declaration nodes in the syntax tree of your code
Since R2026a
Description
The PQL class Cpp.ParameterDeclaration represents the node parameter_declaration in the syntax tree of your code.
void foo(int x, const int y, static int z, [[nodiscard]] int w, __declspec(dllexport) int v, virtual int u);
The function parameter list contains several parameter_declaration nodes. Each parameter such as int x or const int y corresponds to a Cpp.ParameterDeclaration node.
Predicates
| Type | Raisable | Printable |
|---|---|---|
ParameterDeclaration
| 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 ParameterDeclaration ¶mDecl)
| Matches a parameter_declaration node and returns it as
paramDecl. Use it to select parameters directly. | This PQL defect checks for parameter declarations in function parameter lists. defect paramIs =
when
Cpp.ParameterDeclaration.is(&pd)
raise "Found parameter: {pd}"
on pdIn this C++ code the defect finds each function
parameter declaration such as
void foo(int x, const int y) { (void)x; (void)y; } |
cast(Cpp.Node.Node node, required ParameterDeclaration &cast)
| If the provided Node is a
parameter_declaration then returns it as
cast. | This PQL defect checks whether a generic node is a
defect paramCast =
when
Cpp.Node.is(&nd,&,&,&)
and Cpp.ParameterDeclaration.cast(nd, &pd)
raise "Casted node is parameter: {pd}"
on pdIn this C++ code, the defect finds the parameter
declaration
void foo(int x) { (void)x; } |
isa(Cpp.Node.Node node)
| Checks whether a Node is a
parameter_declaration without binding. Use it for boolean tests
or negation. | This PQL defect checks for nodes that are parameter declarations by testing a generic node. defect paramIsa =
when
Cpp.Node.is(&nd,&,&,&)
and Cpp.ParameterDeclaration.isa(nd)
raise "Node is a parameter_declaration"
on ndIn this C++ code, the defect finds the parameter
declaration
void foo(int x) { (void)x; } |
declarator(ParameterDeclaration self, Cpp.Node.Node &child)
| Matches the declarator (the parameter name or declarator node) of the parameter
and returns it as child. | This PQL defect checks for the declarator child node inside a
defect paramDeclarator =
when
Cpp.ParameterDeclaration.is(&pd)
and pd.declarator(&decl)
raise "Parameter declarator: {decl}"
on pdIn this C++ code the defect extracts the
declarator
void foo(int x) { (void)x; } |
type(ParameterDeclaration self, Cpp.Node.Node &child)
| Matches the type node (the parameter type) of the parameter and returns it as
child. | This PQL defect checks for the type portion of a
defect paramType =
when
Cpp.ParameterDeclaration.is(&pd)
and pd.type(&ty)
raise "Parameter type: {ty}"
on pdIn this C++ code the defect finds the type
void foo(const int y) { (void)y; } |
attributeDeclaration(ParameterDeclaration self, Cpp.Node.Node
&child)
| Matches a C++11 attribute-declaration attached to the parameter and returns it
as child. | This PQL defect checks for attribute-declaration nodes on parameters. defect paramAttrDecl =
when
Cpp.ParameterDeclaration.is(&pd)
and pd.attributeDeclaration(&ad)
raise "Attribute declaration: {ad}"
on pdIn this C++ code the defect finds the
void foo([[nodiscard]] int w) { (void)w; } |
attributeSpecifier(ParameterDeclaration self, Cpp.Node.Node
&child)
| Matches an attribute specifier token or node associated with the parameter and
returns it as child. | This PQL defect checks for attribute specifiers on a parameter node. defect paramAttrSpec =
when
Cpp.ParameterDeclaration.is(&pd)
and pd.attributeSpecifier(&as)
raise "Attribute specifier: {as}"
on pd |
msDeclspecModifier(ParameterDeclaration self, Cpp.Node.Node
&child)
| Matches an MSVC __declspec(...) modifier attached to the
parameter and returns it as child. | This PQL defect checks for Microsoft defect paramMsDecl =
when
Cpp.ParameterDeclaration.is(&pd)
and pd.msDeclspecModifier(&ms)
raise "MS declspec modifier: {ms}"
on pdIn this C++ code the defect finds the
void foo(__declspec(dllexport) int v) { (void)v; } |
storageClassSpecifier(ParameterDeclaration self, Cpp.Node.Node
&child)
| Matches storage-class specifiers like static on the
parameter and binds the specifier node to child. | This PQL defect checks for storage-class specifiers used on parameters. defect paramStorageClass =
when
Cpp.ParameterDeclaration.is(&pd)
and pd.storageClassSpecifier(&sc)
raise "Storage class specifier: {sc}"
on pdIn this C++ code the defect detects the
void foo(static int z) { (void)z; } |
typeQualifier(ParameterDeclaration self, Cpp.Node.Node
&child)
| Matches type qualifiers such as const or
volatile on the parameter type and binds the qualifier node to
child. | This PQL defect checks for type qualifiers in parameter declarations. defect paramTypeQual =
when
Cpp.ParameterDeclaration.is(&pd)
and pd.typeQualifier(&tq)
raise "Type qualifier: {tq}"
on pdIn this C++ code the defect finds the
void foo(const int y) { (void)y; } |
virtual(ParameterDeclaration self, Cpp.Node.Node &child)
| Matches an uncommon or extension virtual keyword on a
parameter and returns it as child. | This PQL defect checks for a defect paramVirtual =
when
Cpp.ParameterDeclaration.is(&pd)
and pd.virtual(&v)
raise "Parameter has virtual specifier: {v}"
on pdIn this C++ code the defect reports the
// Some compilers accept 'virtual' as an extension on parameters
void foo(virtual int u) { (void)u; } |
getEnclosingParameterDeclaration(Cpp.Node.Node child, required
ParameterDeclaration &parent)
| Finds the closest enclosing parameter_declaration ancestor
of child and returns it as parent. | This PQL defect checks for the nearest parameter declaration that encloses a generic node. defect paramEnclosing =
when
Cpp.Node.is(&nd,&,&,&)
and Cpp.ParameterDeclaration.getEnclosingParameterDeclaration(nd, &pd)
raise "Enclosing parameter: {pd}"
on pdIn this C++ code the defect finds a parameter declaration that encloses any syntax node.
void foo(int x) { (void)x; } |
isEnclosedInParameterDeclaration(Cpp.Node.Node child)
| Checks whether child has a
parameter_declaration ancestor. Use it to test membership
inside a parameter. | This PQL defect checks if a node resides inside a parameter declaration. defect paramIsEnclosed =
when
Cpp.Node.is(&nd,&,&,&)
and Cpp.ParameterDeclaration.isEnclosedInParameterDeclaration(nd)
raise "Node is enclosed in a parameter_declaration"
on ndIn this C++ code the defect finds all generic nodes enclosed by a parameter declaration
void foo(int x) { (void)x; } |
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)