Cpp.FunctionDeclarator Class
Namespace: Cpp
Superclasses: AstNodeProperties
Represents the function_declarator nodes in the syntax tree of your code
Since R2026a
Description
The PQL class FunctionDeclarator represents the node function_declarator in the syntax tree of your code.
[[nodiscard]] void foo(int a) noexcept [[gnu::always_inline]] __asm__("bar") & requires (true) -> int;
int main() { return 0; }The preceding example contains several function_declarator nodes:
In
foo(int a),foois a function declarator.In
main(){...},main()is a function declarator.
Predicates
| Type | Raisable | Printable |
|---|---|---|
FunctionDeclarator
| 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 FunctionDeclarator &fd)
| Matches any function_declarator node and returns it as fd. Use to obtain the function-declarator node for further inspection. |
This PQL defect checks for any defect find_fd =
when
Cpp.FunctionDeclarator.is(&fd)
and fd.nodeText(&txt)
raise "Found function declarator: \"{txt}\""
on fdIn this C++ code, the defect checks for the top-level function declarator for
void foo(int) {}
|
cast(Cpp.Node.Node node, required FunctionDeclarator &cast)
| Checks whether a generic Cpp.Node.Node is a function_declarator; if so, returns it as cast for further predicates. |
This PQL defect checks whether a given node is a defect cast_check =
when
Cpp.Node.is(&n, &,&,&)
and Cpp.FunctionDeclarator.cast(n, &fd)
and fd.nodeText(&txt)
raise "Node cast to function_declarator: \"{txt}\""
on fdIn this C++ code, the defect finds the node for
int bar(double); |
isa(Cpp.Node.Node node)
| Checks whether node is a function_declarator. Useful for negation or presence checks. |
This PQL defect checks if a node is a defect isa_check =
when
Cpp.Node.is(&n, &,&,&)
and Cpp.FunctionDeclarator.isa(n)
raise "Node is a function_declarator"
on nIn this C++ code, the defect verifies the
void foo(int); |
declarator(FunctionDeclarator self, Cpp.Node.Node &child)
| Returns the nested declarator node (e.g., the identifier and possible nested declarator) inside the function declarator. |
This PQL defect checks for the inner declarator portion of a defect decl_part =
when
Cpp.FunctionDeclarator.is(&fd)
and fd.declarator(&d)
and d.nodeText(&txt)
raise "Declarator part: \"{txt}\""
on fdIn this C++ code, the defect extracts the
void foo(int); |
parameters(FunctionDeclarator self, Cpp.Node.Node &child)
| Matches the parameter list node (the parentheses and contents) of the function declarator. |
This PQL defect checks for the parameter list of a defect params_check =
when
Cpp.FunctionDeclarator.is(&fd)
and fd.parameters(&p)
and p.nodeText(&txt)
raise "Parameters: \"{txt}\""
on fdIn this C++ code, the defect captures
void f(int, double); |
throwSpecifier(FunctionDeclarator self, Cpp.Node.Node &child)
| Matches the exception-specification node (old-style throw(type) form) present on the function declarator. |
This PQL defect checks for an old-style defect throw_spec =
when
Cpp.FunctionDeclarator.is(&fd)
and fd.throwSpecifier(&ts)
and ts.nodeText(&txt)
raise "Throw spec: \"{txt}\""
on fdIn this C++ code, the defect finds
void foo() throw(int);
int main() { return 0; } |
attributeSpecifier(FunctionDeclarator self, Cpp.Node.Node &child)
| Matches attribute-specifier sequences (e.g., [[nodiscard]]) attached to the function declarator. | This PQL defect checks for defect attr_spec =
when
Cpp.FunctionDeclarator.is(&fd)
and fd.attributeSpecifier(&as)
and as.nodeText(&txt)
raise "Attribute specifier: \"{txt}\""
on fdIn this C++ code, the defect finds the function
declarator that has an attribute specifier like the
void my_function() __attribute__((section(".my_funcs"))); |
trailingReturnType(FunctionDeclarator self, Cpp.Node.Node &child)
| Matches a trailing return type (-> type) attached to a function declarator. |
This PQL defect checks for a trailing return type on a function declarator. defect trailing_rt =
when
Cpp.FunctionDeclarator.is(&fd)
and fd.trailingReturnType(&tr)
and tr.nodeText(&txt)
raise "Trailing return: \"{txt}\""
on fdIn this C++ code, the defect finds
auto foo() -> int;
int main() { return 0; } |
gnuAsmExpression(FunctionDeclarator self, Cpp.Node.Node &child)
| Matches a GNU-style __asm__("...") expression attached to the function declarator. | This PQL defect checks for a defect asm_expr =
when
Cpp.FunctionDeclarator.is(&fd)
and fd.gnuAsmExpression(&ga)
and ga.nodeText(&txt)
raise "GNU asm: \"{txt}\""
on fd |
typeQualifier(FunctionDeclarator self, Cpp.Node.Node &child)
| Matches trailing cv-qualifiers (e.g., const, volatile) on the function declarator. |
This PQL defect checks for defect type_qual =
when
Cpp.FunctionDeclarator.is(&fd)
and fd.typeQualifier(&tq)
and tq.nodeText(&txt)
raise "Type qualifier: \"{txt}\""
on fdIn this C++ code, the defect finds
struct S { void m() const; };
int main() { return 0; } |
noexcept(FunctionDeclarator self, Cpp.Node.Node &child)
| Matches a noexcept specifier (with or without expression) on the function declarator. |
This PQL defect checks for defect noex =
when
Cpp.FunctionDeclarator.is(&fd)
and fd.noexcept(&ne)
and ne.nodeText(&txt)
raise "Noexcept: \"{txt}\""
on fdIn this C++ code, the defect captures
void foo() noexcept(true);
int main() { return 0; } |
virtualSpecifier(FunctionDeclarator self, Cpp.Node.Node &child)
| Matches a override or final specifier
present on a member function declarator. | This PQL defect checks for the defect virt_spec =
when
Cpp.FunctionDeclarator.is(&fd)
and fd.virtualSpecifier(&vs)
and vs.nodeText(&txt)
raise "Virtual specifier: \"{txt}\""
on fdIn this C++ code, the defect finds
class Shape {
public:
double area() final;
}; |
refQualifier(FunctionDeclarator self, Cpp.Node.Node &child)
| Matches ref-qualifiers (& or &&) applied to member function declarators. |
This PQL defect checks for reference qualifiers on a member function declarator. defect ref_q =
when
Cpp.FunctionDeclarator.is(&fd)
and fd.refQualifier(&rq)
and rq.nodeText(&txt)
raise "Ref qualifier: \"{txt}\""
on fdIn this C++ code, the defect detects the
struct S { void g() &; };
int main() { return 0; } |
requiresClause(FunctionDeclarator self, Cpp.Node.Node &child)
| Matches a trailing requires clause (C++20 constraints) on the function declarator. |
This PQL defect checks for a defect req_clause =
when
Cpp.FunctionDeclarator.is(&fd)
and fd.requiresClause(&rc)
and rc.nodeText(&txt)
raise "Requires clause: \"{txt}\""
on fdIn this C++ code, the defect finds
template<typename T> void h() requires (true);
int main() { return 0; } |
attributeDeclaration(FunctionDeclarator self, Cpp.Node.Node &child)
| Matches an attribute-declaration (attribute-list) that applies to the function declarator (often same as attributeSpecifier but placed differently in grammar). | This PQL defect checks for attribute declarations (the
defect attr_decl =
when
Cpp.FunctionDeclarator.is(&fd)
and fd.attributeDeclaration(&ad)
and ad.nodeText(&txt)
raise "Attribute declaration: \"{txt}\""
on fd |
getEnclosingFunctionDeclarator(Cpp.Node.Node child, required FunctionDeclarator &parent)
| Finds the closest enclosing function_declarator ancestor of child and returns it as parent. | This PQL defect checks which function declarator encloses a given child node. defect enclosing_fd =
when
Cpp.Node.is(&n, &,&,&)
and Cpp.FunctionDeclarator.getEnclosingFunctionDeclarator(n, &fd)
and fd.nodeText(&txt)
raise "Enclosing function declarator: \"{txt}\""
on fdIn this C++ code, the defect finds the function declarator that encloses a child node.
void foo(int a) {}
|
isEnclosedInFunctionDeclarator(Cpp.Node.Node child)
| Matches any function_declarator ancestor of
child. | This PQL defect checks all function declarator ancestors of a node. defect all_enclosing =
when
Cpp.Node.is(&n, &,&,&)
and Cpp.FunctionDeclarator.isEnclosedInFunctionDeclarator(n)
and n.nodeText(&txt)
raise "Node enclosws in function declarator ancestor: \"{txt}\""
on nIn this C++ code, the defect enumerates any function declarators that enclose a child node.
int (*fp(int x))(double) { return nullptr; }
int main() { return 0; } |
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)