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.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)