Cpp.PointerDeclarator Class
Namespace: Cpp
Superclasses: AstNodeProperties
Represents the pointer_declarator nodes in the syntax tree of your code
Since R2026a
Description
The PQL class PointerDeclarator represents the node
pointer_declarator in the syntax tree of your code.
int *a; int * const b = nullptr;
The sample shows pointer declarators *a and * const
b that are matched by this class.
Predicates
| Type | Raisable | Printable |
|---|---|---|
PointerDeclarator
| Yes | Yes |
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 PointerDeclarator &pd)
| Matches a pointer_declarator node and returns it as
pd; use this to locate pointer declarators in the tree. | This PQL defect checks for pointer declarator nodes anywhere in the translation unit. defect find_pointer =
when
Cpp.PointerDeclarator.is(&pd)
and pd.nodeText(&txt)
raise "Found pointer declarator: \"{txt}\""
on pdIn this C++ code, the defect finds each pointer
declarator such as
int *a; int * const b = nullptr; |
cast(Cpp.Node.Node node, required PointerDeclarator &cast)
| Checks whether a generic Cpp.Node.Node is a
pointer_declarator. If so, returns it as
cast for further pointer-specific queries. | This PQL defect checks whether a given generic node is specifically a
defect cast_node_to_pointer =
when
Cpp.Node.is(&node, &,&,&)
and Cpp.PointerDeclarator.cast(node, &pd)
and pd.nodeText(&txt)
raise "Node cast to pointer_declarator: \"{txt}\""
on pdIn this C++ code, the defect finds that the generic
node for
int *c; |
isa(Cpp.Node.Node node)
| Returns true if the given Cpp.Node.Node is a
pointer_declarator; useful in boolean checks or
negation. | This PQL defect checks whether a node is a
defect not_a_pointer =
when
Cpp.Node.is(&node, &,&,&)
and not Cpp.PointerDeclarator.isa(node)
raise "Node is not a pointer_declarator"
on nodeIn this C++ code, the defect finds all syntax nodes that are not a pointer declarator.
int x = 5; int *p = &x; |
declarator(PointerDeclarator self, Cpp.Node.Node &child)
| Matches the child declarator node under a
pointer_declarator, i.e., the identifier or nested declarator
after the *. | This PQL defect checks for the inner declarator (identifier) within a
defect pointer_declarator_has_declarator =
when
Cpp.PointerDeclarator.is(&pd)
and pd.declarator(&decl)
and decl.nodeText(&txt)
raise "Pointer declarator contains declarator: \"{txt}\""
on pdIn this C++ code, the defect inspects the identifier
int *a; int * const b = nullptr; |
typeQualifier(PointerDeclarator self, Cpp.Node.Node &child)
| Matches a type_qualifier child (like
const or volatile) attached to a
pointer_declarator. | This PQL defect checks for
defect pointer_has_type_qualifier =
when
Cpp.PointerDeclarator.is(&pd)
and pd.typeQualifier(&qual)
and qual.nodeText(&txt)
raise "Pointer has type qualifier: \"{txt}\""
on pdIn this C++ code, the defect finds the
int * const b = nullptr; |
msPointerModifier(PointerDeclarator self, Cpp.Node.Node
&child)
| Matches Microsoft-specific pointer modifiers present in the pointer declarator. | This PQL defect checks for MS pointer modifiers attached to pointers. defect ms_pointer_modifier_found =
when
Cpp.PointerDeclarator.is(&pd)
and pd.msPointerModifier(&mod)
and mod.nodeText(&txt)
raise "MS pointer modifier: \"{txt}\""
on pdIn this C++ code, the defect detects the MS modifier
int * __restrict p; |
msBasedModifier(PointerDeclarator self, Cpp.Node.Node &child)
| Matches Microsoft __based(...) modifiers applied to the
pointer declarator. | This PQL defect checks for MS defect ms_based_modifier_found =
when
Cpp.PointerDeclarator.is(&pd)
and pd.msBasedModifier(&mod)
and mod.nodeText(&txt)
raise "MS based modifier: \"{txt}\""
on pdIn this C++ code, the defect finds the
int __based(something) *d; |
getEnclosingPointerDeclarator(Cpp.Node.Node child, required
PointerDeclarator &parent)
| Finds the nearest enclosing pointer_declarator ancestor of
child and returns it as parent. | This PQL defect checks for the closest
defect find_enclosing_pointer =
when
Cpp.Node.is(&inner, &,&,&)
and Cpp.PointerDeclarator.getEnclosingPointerDeclarator(inner, &parent)
and parent.nodeText(&txt)
raise "Enclosing pointer declarator: \"{txt}\""
on parentIn this C++ code, the defect locates the pointer
declarator that encloses the identifier
int *a; |
isEnclosedInPointerDeclarator(Cpp.Node.Node child)
| Matches every pointer_declarator ancestor of
child. | This PQL defect checks for all pointer declarator ancestors of a given node. defect all_enclosing_pointers =
when
Cpp.Node.is(&inner, &,&,&)
and Cpp.PointerDeclarator.isEnclosedInPointerDeclarator(inner)
and inner.nodeText(&txt)
raise "Node has ancestor pointer declarator: \"{txt}\""
on innerIn this C++ code, the defect locates the pointer
declarator that are ancestor of the identifier
int *a; |
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)