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)