Skip to content

Commit

Permalink
Handle wide-character string literals in regex (#867)
Browse files Browse the repository at this point in the history
Does not add support for wide-character strings per se, only for parsing the clang AST without crashing.

Fixes #866
  • Loading branch information
kroppt committed Jul 21, 2020
1 parent 99646ac commit 72b29fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ast/string_literal.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type StringLiteral struct {

func parseStringLiteral(line string) *StringLiteral {
groups := groupsFromRegex(
`<(?P<position>.*)> '(?P<type>.*)'(?P<lvalue> lvalue)? (?P<value>".*")`,
`<(?P<position>.*)> '(?P<type>.*)'(?P<lvalue> lvalue)? L?(?P<value>".*")`,
line,
)

Expand Down
8 changes: 8 additions & 0 deletions ast/string_literal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ func TestStringLiteral(t *testing.T) {
Value: "foo",
ChildNodes: []Node{},
},
`0x61b80c8 <col:19> 'wchar_t [21]' lvalue L"hello$$\x4F60\x597D\242\242\x4E16\x754C\x20AC\x20ACworld"`: &StringLiteral{
Addr: 0x61b80c8,
Pos: NewPositionFromString("col:19"),
Type: "wchar_t [21]",
Lvalue: true,
Value: "hello$$\x4F60\x597D\242\242\x4E16\x754C\x20AC\x20ACworld",
ChildNodes: []Node{},
},
}

runNodeTests(t, nodes)
Expand Down

0 comments on commit 72b29fc

Please sign in to comment.