Cpp.ConcatenatedString Class
Namespace: Cpp
Superclasses: AstNodeProperties
Represents the concatenated_string nodes in the syntax tree of your code
Since R2026a
Description
The PQL class ConcatenatedString represents the node concatenated_string in the syntax tree of your code.
// example.cpp
#include <iostream>
int main() {
const char* s1 = "foo" "bar"; // concatenated string from two string literals
const char* s2 = R"(baz)" "qux"; // concatenated_string with a raw string + literal
(void)s1; (void)s2; (void)s3;
return 0;
}The initializers "foo" "bar" and R"(baz)" "qux" are
concatenated_string nodes that match with this class.
Predicates
| Type | Raisable | Printable |
|---|---|---|
ConcatenatedString
| 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 ConcatenatedString &cs)
| Checks whether a concatenated_string node exists in the code and returns it as cs for further inspection. |
This PQL defect checks for any defect find_concat =
when
Cpp.ConcatenatedString.is(&cs)
and cs.nodeText(&txt)
raise "found concatenated string: \"{txt}\""
on csIn this C++ code, the defect finds places where adjacent string-like tokens form a single concatenated string literal.
const char* s = "hello" " " "world";
int main() { (void)s; return 0; } |
cast(Cpp.Node.Node node, required ConcatenatedString &cast)
| Given any Cpp.Node.Node, succeeds if that node is a concatenated_string and returns it as cast for downstream checks. | This PQL defect checks whether an arbitrary node is specifically a
defect cast_to_concat =
when
Cpp.Node.is(&node, &,&,&)
and Cpp.ConcatenatedString.cast(node, &cs)
and cs.nodeText(&txt)
raise "node cast to concatenated string: \"{txt}\""
on csIn this C++ code, the defect detects a concatenated string after starting with all generic node.
const char* s = "part1" "part2";
int main() { (void)s; return 0; } |
isa(Cpp.Node.Node node)
| Returns true if the given node is a concatenated_string; useful in boolean checks or negations. | This PQL defect checks for nodes that are not
defect not_concat =
when
Cpp.Node.is(&node, &,&,&)
and not Cpp.ConcatenatedString.isa(node)
raise "node is not a concatenated string"
on nodeIn this C++ code, the defect finds the node that are not concatenated-strings.
const char* a = "x" "y"; // this is a concatenated_string
int b = 42; // this is not
int main() { (void)a; (void)b; return 0; } |
stringLiteral(ConcatenatedString self, Cpp.Node.Node &child)
| Matches each ordinary quoted string literal component inside a concatenated_string, returning the literal node as child. |
This PQL defect checks for plain defect find_string_parts =
when
Cpp.ConcatenatedString.is(&cs)
and cs.stringLiteral(&part)
and part.nodeText(&txt)
raise "stringLiteral part: \"{txt}\""
on csIn this C++ code, the defect finds each
const char* s = "foo" "bar";
int main() { (void)s; return 0; } |
rawStringLiteral(ConcatenatedString self, Cpp.Node.Node &child)
| Matches raw string literal components such as R"( ... )"
inside a concatenated_string and returns the raw-literal node as
child. |
This PQL defect checks for raw-string literal parts inside concatenations. defect find_raw_parts =
when
Cpp.ConcatenatedString.is(&cs)
and cs.rawStringLiteral(&part)
and part.nodeText(&txt)
raise "rawStringLiteral part: \"{txt}\""
on csIn this C++ code, the defect finds the raw literal
const char* s = R"(baz)" "qux";
int main() { (void)s; return 0; } |
identifier(ConcatenatedString self, Cpp.Node.Node &child)
| Matches identifier tokens that appear as components of a concatenated_string (e.g., macro-generated string tokens) and returns the identifier node as child. |
This PQL defect checks for identifier pieces inside a concatenated string. defect find_identifier_parts =
when
Cpp.ConcatenatedString.is(&cs)
and cs.identifier(&id)
and id.nodeText(&txt)
raise "identifier part: \"{txt}\""
on csIn this C++ code, the defect locates an identifier used adjacent to a string literal, forming a concatenated node.
#define ID lit
const char* s = ID "abc"; // identifier followed by string literal
int main() { (void)s; return 0; } |
getEnclosingConcatenatedString(Cpp.Node.Node child, required ConcatenatedString &parent)
| Finds the nearest concatenated_string parent of a given
child node and returns that parent as
parent. | This PQL defect checks for the concatenated-string that contains a
defect parent_of_child =
when
Cpp.Node.is(&node, &,&,&)
and Cpp.RawStringLiteral.isa(node)
and Cpp.ConcatenatedString.getEnclosingConcatenatedString(node, &cs)
and cs.nodeText(&txt)
raise "parent concatenated string containing a raw literal: \"{txt}\""
on csIn this C++ code, the defect finds the concatenated string that encloses a given string literal.
const char* s2 = R"(baz)" "qux"; |
isEnclosedInConcatenatedString(Cpp.Node.Node child)
| Returns true if the provided child node has any concatenated_string ancestor in the syntax tree. | This PQL defect finds defect child_in_concat =
when
Cpp.Node.is(&node, &,&,&)
and Cpp.StringContent.isa(node)
and Cpp.ConcatenatedString.isEnclosedInConcatenatedString(node)
raise "string literal is inside a concatenated string"
on nodeIn this C++ code, the defect finds the string
content
const char* s = "x" "y";
int main() { (void)s; return 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.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)