Ast.TypeDescriptor Class
Namespace: Ast
Superclasses: AstNodeProperties
Represents the type_descriptor nodes in the syntax tree of your code
Since R2026a
Description
The PQL class Cpp.TypeDescriptor represents the node type_descriptor in the syntax tree of your code.
int* p; const int* q; volatile double& r = *reinterpret_cast<volatile double*>(0);
The sample shows three type_descriptor occurrences: int*, const int*, and volatile double& which correspond to Cpp.TypeDescriptor nodes.
Predicates
| Type | Raisable | Printable |
|---|---|---|
TypeDescriptor
| 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 TypeDescriptor &typeDesc)
| Matches a type_descriptor node and returns it as the output
variable. Use this to locate a type description in code. | This PQL defect checks for any defect find_type_descriptor =
when
Cpp.TypeDescriptor.is(&td)
and td.nodeText(&txt)
raise "Found type descriptor: \"{txt}\""
on tdIn this C++ code the defect finds each type descriptor such as pointer, reference, or qualified types.
int *p;
const int *q;
volatile double &r = *reinterpret_cast<volatile double *>(0);
void foo() {
*p = *q + 1;
} |
cast(Cpp.Node.Node node, required TypeDescriptor &cast)
| Checks whether a given node is a
type_descriptor and if so returns that node as a
TypeDescriptor. | This PQL defect checks whether an arbitrary node is a
defect find_castable_node =
when
Cpp.Node.is(&n, &,&,&)
and Cpp.TypeDescriptor.cast(n, &td)
and td.nodeText(&txt)
raise "Node is a type_descriptor: \"{txt}\""
on tdIn this C++ code the defect finds nodes that
represent type descriptions such as
int *p;
const int *q;
volatile double &r = *reinterpret_cast<volatile double *>(0);
void foo() {
*p = *q + 1;
}; |
isa(Cpp.Node.Node node)
| Tests whether the given node is a
type_descriptor node. Useful for conditional checks or
negation. | This PQL defect checks for nodes that are not
defect find_non_type_descriptor =
when
Cpp.Node.is(&n, &,&,&)
and not Cpp.TypeDescriptor.isa(n)
raise "Node is not a type_descriptor"
on nIn this C++ code the defect finds nodes that are not type descriptors..
int *p;
const int *q;
volatile double &r = *reinterpret_cast<volatile double *>(0);
void foo() { // function declaration is not type descriptor
*p = *q + 1;
} |
declarator(TypeDescriptor self, Cpp.Node.Node &child)
| Returns the declarator subnode of the type_descriptor such
as pointer or array declarators. | This PQL defect checks for defect find_declarator =
when
Cpp.TypeDescriptor.is(&td)
and td.declarator(&decl)
and decl.nodeText(&txt)
raise "Declarator text: \"{txt}\""
on td |
type(TypeDescriptor self, Cpp.Node.Node &child)
| Returns the underlying base type subnode of the
type_descriptor such as int or
double. | This PQL defect checks for defect find_base_type =
when
Cpp.TypeDescriptor.is(&td)
and td.type(&base)
and base.nodeText(&txt)
raise "Base type: \"{txt}\""
on tdIn this C++ code the defect retrieves the base
type
const int* q; volatile double& r = *reinterpret_cast<volatile double*>(0); |
typeQualifier(TypeDescriptor self, Cpp.Node.Node &child)
| Returns qualifier nodes associated with the type such as
const, volatile, or
restrict. | This PQL defect checks for qualified types and extracts their qualifier tokens. defect find_type_qualifier =
when
Cpp.TypeDescriptor.is(&td)
and td.typeQualifier(&qual)
and qual.nodeText(&txt)
raise "Type qualifier: \"{txt}\""
on tdIn this C++ code the defect finds
const int* q; volatile double& r = *reinterpret_cast<volatile double*>(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)