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.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)