Skip to content

Commit 64a9a75

Browse files
committed
C++: Remove inverted named character properties
1 parent 0a3887d commit 64a9a75

2 files changed

Lines changed: 4 additions & 26 deletions

File tree

‎cpp/ql/lib/semmle/code/cpp/regex/RegexTreeView.qll‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,12 +1112,6 @@ private module Impl implements RegexTreeViewSig {
11121112
* `"digit"`.
11131113
*/
11141114
string getName() { result = re.getCharacterPropertyName(start, end) }
1115-
1116-
/**
1117-
* Holds if the property is inverted. For example, it holds for `[[:^digit:]]`,
1118-
* which matches non-digits.
1119-
*/
1120-
predicate isInverted() { re.namedCharacterPropertyIsInverted(start, end) }
11211115
}
11221116

11231117
class Top = RegExpParent;
@@ -1132,13 +1126,13 @@ private module Impl implements RegexTreeViewSig {
11321126
// TODO: expand to cover more properties
11331127
exists(RegExpNamedCharacterProperty escape | term = escape |
11341128
escape.getName().toLowerCase() = "digit" and
1135-
if escape.isInverted() then clazz = "D" else clazz = "d"
1129+
clazz = "d"
11361130
or
11371131
escape.getName().toLowerCase() = "space" and
1138-
if escape.isInverted() then clazz = "S" else clazz = "s"
1132+
clazz = "s"
11391133
or
11401134
escape.getName().toLowerCase() = "word" and
1141-
if escape.isInverted() then clazz = "W" else clazz = "w"
1135+
clazz = "w"
11421136
)
11431137
}
11441138

‎cpp/ql/lib/semmle/code/cpp/regex/internal/ParseRegExp.qll‎

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -304,23 +304,7 @@ abstract class RegExp extends StringLiteral {
304304
|
305305
e
306306
) and
307-
exists(int nameStart |
308-
this.getChar(start + 2) = "^" and nameStart = start + 3
309-
or
310-
not this.getChar(start + 2) = "^" and nameStart = start + 2
311-
|
312-
name = this.getText().substring(nameStart, end - 2)
313-
)
314-
}
315-
316-
/**
317-
* Holds if the named character property is inverted. This, e.g., holds for `[[:^digit:]]`.
318-
*
319-
* This does not hold for, e.g., `[[:alnum:]]`.
320-
*/
321-
predicate namedCharacterPropertyIsInverted(int start, int end) {
322-
this.posixStyleNamedCharacterProperty(start, end, _) and
323-
this.getChar(start + 3) = "^"
307+
name = this.getText().substring(start + 2, end - 2)
324308
}
325309

326310
/**

0 commit comments

Comments
 (0)