Replace C++ syntax check with dummy frontend#7520
Conversation
|
Thanks for your pull request, @ibuclaw! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
|
@MartinNowak - this should go in stable + 2.078, as the C++<->D visitor interface is utterly unusable without this, and breaks all downstream. |
|
Looks like I should partially revert #7005 also, as the fix is just lazy. |
Simple target |
d9ed729 to
6ba0644
Compare
|
Rebased against stable. I think the tests should pass now once I fixed up |
src/dmd/sapply.d
Outdated
| override void visit(ForwardingStatement s) | ||
| { | ||
| if (s.statement) | ||
| doCond(s.statement) || applyTo(s.statement); |
There was a problem hiding this comment.
I don't know the exact purpose of the walkPostorder visitor, but this seems fishy to me as ForwardingStatement is not supposed to have behaviour different from the wrapped statement.
There was a problem hiding this comment.
This is correct, as you want to walk over the underlying wrapped statement, not the wrapper itself.
There was a problem hiding this comment.
If I have a ForwardingStatement wrapping a LabelStatement, doCond is called with different arguments than if I have only a LabelStatement. Before your changes, the behaviour was identical for both cases. Is this change in behaviour intentional?
There was a problem hiding this comment.
Do you have code example that changes behaviour? Or is that just hypothetical?
The order that it walks the AST should be the same as the original.
Should probably add applyTo(s) if the underlying statement is null, but that does not happen in the current.
There was a problem hiding this comment.
Running the visitor on a semantically-analyzed version of the following code will result in changed behaviour:
static foreach(i;0..1) L: writeln(i);L: writeln(i) will be visited by the StoppableVisitor v twice now, even though before it was visited only once.
I don't think applyTo(s) should be called if s.statement is null.
There was a problem hiding this comment.
Only if it makes sense to Visit the ForwardingStatement by default. (I don't see why it would.)
Is this Visitor used for anything?
There was a problem hiding this comment.
It's used by comeFrom and/or blockExit for determining reachable statements.
There was a problem hiding this comment.
Visiting the ForwardingStatement will break the hasCode method in statement.d. (I.e., I think the implementation should stay the same as before.)
There was a problem hiding this comment.
Right, that sounds like what I saw last night when seeing unreachable warnings.
So just the one applyTo(s.statement then to elide double visiting.
There was a problem hiding this comment.
I think it should just be
if(s.statement)
s.statement.accept(this);
(Otherwise, e.g. bodies of while loops inside static foreach will not be visited.)
The base visitor should just forward onto the next method in the inheritance chain. Any special logic above that should go in overriding visitors. |
|
Well, then the best fix might be to add a DefaultVisitor in-between Visitor and all its subclasses. To forward to |
Having it in visitor just hid bugs. As it wasn't forwarding onto Statement in the event that the underlying wrapped statement was null. If your writing a visitor, that you should be aware of all classes is a given. If the entire point of ForwardingStatement is to not exist outside semantic then that needs to be looked at and fixed. If we can do away with ForwardingStatement in any way (I don't know what it's used for, so I'll arbitrarily suggest adding a Scope flag) then all the better. |
|
Which bugs? If it is sensible to ignore a null Statement, it is sensible to ignore a ForwardingStatement wrapping null. ForwardingStatement is used to insert wrapped symbols into a different scope than the current one. |
It seems to me that this is something that should not be leaked outside of the static foreach semantic, so yes. |
If I have a visitor with the following method. Passing this a ForwardingStatement with interior null would print nothing, which is an unexpected behaviour. |
|
I'll try to create a pull request that removes ForwardingStatements after they are no longer required. |
|
I moved the ForwardingStatement fix to #7526 |
|
Cherry-picked other PR into this one. |
|
@ZombineDev already rebased. |
Hmm, I missed that #7526 was targeting master instead of stable, unlike this PR. |
| DMD_FLAGS := -I$(ROOT) -Wuninitialized | ||
| GLUE_FLAGS := -I$(ROOT) -I$(TK) -I$(C) | ||
| DMD_FLAGS := -I$(D) -I$(ROOT) -Wuninitialized | ||
| GLUE_FLAGS := -I$(D) -I$(ROOT) -I$(TK) -I$(C) |
There was a problem hiding this comment.
The common style of this Makefile is to skip the parentheses for one letter variables, i.e. $D
There was a problem hiding this comment.
All I have to say is $(C).
| @@ -0,0 +1,199 @@ | |||
| /** | |||
There was a problem hiding this comment.
Creating the folder src/tests might lead to confusions for newcomers.
There was a problem hiding this comment.
I wasn't sure the best place for this, as the main source folder doesn't seem right.
Please avoid cherry-picking if possible to not unnecessary merge conflicts. |
|
@MartinNowak so having the source in tests is fine? |
On closer inspection the Visitor interface broken by #7397 still wasn't fixed by #7438.
The entire C++ Visitor class has been re-layed out to match the order of virtuals in the D implementation.
Have exported
Id::initializeto C++ as fundamental components don't work if you can't call it.Replaced cxxcheckheaders with cxx-unittest, a small program that links against the front-end in the same way that LDC or GDC would to test that interaction works.
I anticipate to build on this test file later.