File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
common/src/codingstandards/cpp Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import cpp
18
18
import codingstandards.cpp.autosar
19
19
import codingstandards.cpp.LoggingOperation
20
20
import codingstandards.cpp.Literals
21
+ import codingstandards.cpp.Cpp14Literal
21
22
22
23
from Literal l
23
24
where
35
36
// Exclude literal 0
36
37
not l .getValue ( ) = "0" and
37
38
// Exclude character literals
38
- not l instanceof CharLiteral and
39
+ not l instanceof Cpp14Literal :: CharLiteral and
39
40
// Exclude `nullptr`
40
41
not l .getType ( ) instanceof NullPointerType and
41
42
// Exclude boolean `true` and `false`
Original file line number Diff line number Diff line change @@ -82,4 +82,24 @@ module Cpp14Literal {
82
82
83
83
override string getAPrimaryQlClass ( ) { result = "FloatingLiteral" }
84
84
}
85
+
86
+ /**
87
+ * A character literal. For example:
88
+ * ```
89
+ * char c1 = 'a';
90
+ * char16_t c2 = u'a';
91
+ * char32_t c3 = U'a';
92
+ * wchar_t c4 = L'b';
93
+ * ```
94
+ */
95
+ class CharLiteral extends StandardLibrary:: TextLiteral {
96
+ CharLiteral ( ) { this .getValueText ( ) .regexpMatch ( "(?s)\\s*(L|u|U)?'.*" ) }
97
+
98
+ override string getAPrimaryQlClass ( ) { result = "CharLiteral" }
99
+
100
+ /**
101
+ * Gets the character of this literal. For example `L'a'` has character `"a"`.
102
+ */
103
+ string getCharacter ( ) { result = this .getValueText ( ) .regexpCapture ( "(?s)\\s*(L|u|U)?'(.*)'" , 1 ) }
104
+ }
85
105
}
You can’t perform that action at this time.
0 commit comments