-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[C++] Fix const correctness in ATN and DFA #3530
Conversation
3a1ed5f
to
dc6b311
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Just fix the few issues I mentioned and we are good to go.
Please refrain from moving code to header files, if there's not really an absolute compelling reason.
dc6b311
to
27e74df
Compare
Something is weird with the MacOS runtime. I need to get a signal handler installed that dumps the stacktrace when it fails. |
e3fffbd
to
140094c
Compare
Something is super weird. I am going to need to grab my Wife's personal mac to investigate. I'll bump this when I figure out whats up. Looks like SEGFAULT via nullptr, but its hard to tell. |
592c801
to
53df497
Compare
I tickled some weird MacOS bug in their toolchain. I'm going to split this up into separate CLs to narrow down the root cause. Leaving this open for the timebeing for reference. |
53df497
to
0cabe79
Compare
runtime-testsuite/test/org/antlr/v4/test/runtime/cpp/BaseCppTest.java
Outdated
Show resolved
Hide resolved
0bad220
to
2bc31fc
Compare
Okay, I think its good now @mike-lischke , I didn't need to split. There is something super sketchy going on with I removed the changes to equality and hashing for |
2bc31fc
to
ba76a39
Compare
I accidentally squashed the change I was talking about. Updated, and tests are all green. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks ok now. @parrt This patch can be merged.
if (!a[i] && !b[i]) | ||
continue; | ||
if (!a[i] || !b[i]) | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an issue per se, just mentioning that these two checks can be combined into one:
if (!a[i] != !b[i])
continue;
Thanks guys! |
This is a safe but large change that fixes const correctness in various places in the ATN and DFA. Historically things were passed around as
std::shared_ptr<T>
which allowedT
to be modified even if it never was. This change fixes it so that most things are passed around asstd::shared_ptr<const T>
. This makes thread saftey analysis easier when simply reading.I also replaced
const std::shared_ptr<T>&
withconst T&
in places wherestd::shared_ptr
was not being copied and thus extending the lifetime ofT
.