Cpp.False Class
Namespace: Cpp
Superclasses: AstNodeProperties
Represents the false nodes in the syntax tree of your code
Since R2026a
Description
The PQL class Cpp.False represents the node false in the syntax tree of your code.
void foo() {
if (false) {
// unreachable
}
}The if (false) contains the false literal which corresponds to the false node matched by Cpp.False in PQL.
Predicates
| Type | Raisable | Printable |
|---|---|---|
False
| 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 False &false)
| Match a false literal node and return it through the output variable. Use this to directly find false tokens in code. |
This PQL defect checks for defect find_false_is =
when
Cpp.False.is(&f)
and f.nodeText(&txt)
raise "Found false via is: \"{txt}\""
on fIn this C++ code, the defect finds the
// compile with: g++ -std=c++17 example_is.cpp -o example_is
#include <iostream>
int main() {
if (false) { // matches Cpp.False.is
std::cout << "won't run\n";
}
return 0;
} |
is(required Cpp.False &false)
| Matches a false literal and binds it to the given output variable for further checks or reporting. |
This PQL defect checks for occurrences of a defect false_is_example =
when
Cpp.False.is(&f)
and f.nodeText(&txt)
raise "Found false literal: \"{txt}\""
on fIn this C++ code, the defect finds the
#include <iostream>
int main() {
if (false) {
std::cout << "won't run\n";
}
return 0;
} |
cast(Cpp.Node.Node node, required Cpp.False &cast)
| Checks whether a given Node is a false
literal and if so returns the false node as the output variable
for further inspection. | This PQL defect checks whether a previously obtained node is the
defect false_cast_example =
when
Cpp.node.is(&n,&,&,&)
and Cpp.False.cast(n, &f)
and f.nodeText(&txt)
raise "Cast confirmed false literal: \"{txt}\""
on fIn this C++ code, the defect finds a
int main() {
bool b = false;
return b ? 1 : 0;
} |
isa(Cpp.Node.Node node)
| Returns true when the given generic Node is a false literal allowing negation or conditional checks in queries. | This PQL defect checks whether a generic node corresponds to a
defect false_isa_example =
when
Cpp.node.is(&n,&,&,&)
and Cpp.False.isa(n)
raise "Node is a false literal"
on nIn this C++ code, the defect finds a
void test() {
if (false) {
// intentionally empty
}
} |
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)