Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialized ATN const array generates horrible machine code fix #3009

Merged
merged 3 commits into from
Mar 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contributors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,4 @@ YYYY/MM/DD, github id, Full name, email
2021/02/21, namasikanam, Xingyu Xie, namasikanam@gmail.com
2021/02/27, khmarbaise, Karl Heinz Marbaise, github@soebes.com
2021/03/02, hackeris
2021/03/03, xTachyon, Damian Andrei, xTachyon@users.noreply.github.com
10 changes: 1 addition & 9 deletions tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Cpp.stg
Original file line number Diff line number Diff line change
Expand Up @@ -422,22 +422,14 @@ static std::vector\<uint16_t> _serializedATN;

// Constructs the serialized ATN and writes init code for static member vars.
SerializedATN(model) ::= <<
<if (rest(model.segments))>
<model.segments: {segment | static uint16_t serializedATNSegment<i0>[] = {
<model.segments: {segment | static const uint16_t serializedATNSegment<i0>[] = {
<segment; wrap={<\n> }>
\};}; separator="\n">

<model.segments: {segment | _serializedATN.insert(_serializedATN.end(), serializedATNSegment<i0>,
serializedATNSegment<i0> + sizeof(serializedATNSegment<i0>) / sizeof(serializedATNSegment<i0>[0]));
}>

<else>
<! only one segment, can be inlined !>
_serializedATN = {
<model.serialized; wrap = {<\n>}>
};
<endif>

atn::ATNDeserializer deserializer;
_atn = deserializer.deserialize(_serializedATN);

Expand Down