Skip to content

Fix duplicate-skipping in prototype generation #154

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

Closed

Conversation

matthijskooijman
Copy link
Collaborator

While generating prototypes, a scan is made for any function definitions
which would result in identical prototypes, and all but the first are
skipped. However, when doing so, this did not take into account function
definitions which were already marked to be skipped, which could cause
all definitions to be skipped.

This behaviour caused a particular problem when a method definition
existed with the same signature as a function definition. All method
definitions are skipped through tagIsUnhandled, but could still
make skipDuplicates skip the corresponding function definition. This
commit fixes this.

It is not entirely clear to me if this duplicate removal is actually
needed at all. If code contains multiple function definitions with the
same signature, you would expect the compiler to throw an error anyway.
If duplicate removal would be removed, only one testcase
(TestCTagsToPrototypesShouldDealFunctionWithDifferentSignatures) fails,
but that testcase uses a predefined ctags output that contains a
duplicate function definition. It is not quite clear what source files
this output was generated from (it seems to stem from
CharWithEscapedDoubleQuote.ino, which originated at
arduino/Arduino#1245, but those only contain
one version of the function definition, not two).

Still, since the ctags parsing will hopefully be replaced in the near
future, this just fixes the duplicate removal instead of removing it and
risking a regression on some corner case.

This fixes #140.

Signed-off-by: Martino Facchin [email protected]
Signed-off-by: Matthijs Kooijman [email protected]

While generating prototypes, a scan is made for any function definitions
which would result in identical prototypes, and all but the first are
skipped. However, when doing so, this did not take into account function
definitions which were already marked to be skipped, which could cause
*all* definitions to be skipped.

This behaviour caused a particular problem when a method definition
existed with the same signature as a function definition. All method
definitions are skipped through `tagIsUnhandled`, but could still
make `skipDuplicates` skip the corresponding function definition. This
commit fixes this.

It is not entirely clear to me if this duplicate removal is actually
needed at all. If code contains multiple function definitions with the
same signature, you would expect the compiler to throw an error anyway.
If duplicate removal would be removed, only one testcase
(TestCTagsToPrototypesShouldDealFunctionWithDifferentSignatures) fails,
but that testcase uses a predefined ctags output that contains a
duplicate function definition. It is not quite clear what source files
this output was generated from (it seems to stem from
CharWithEscapedDoubleQuote.ino, which originated at
arduino/Arduino#1245, but those only contain
one version of the function definition, not two).

Still, since the ctags parsing will hopefully be replaced in the near
future, this just fixes the duplicate removal instead of removing it and
risking a regression on some corner case.

This fixes arduino#140.

Signed-off-by: Martino Facchin <[email protected]>
Signed-off-by: Matthijs Kooijman <[email protected]>
@ArduinoBot
Copy link
Contributor

✅ Build completed.

⬇️ Build URL: http://downloads.arduino.cc/PR/arduino-builder/arduino-builder-154.zip

ℹ️ To test this build:

  1. Replace arduino-builder binary (you can find it where you installed the IDE) with the provided one

@matthijskooijman
Copy link
Collaborator Author

@facchinm @cmaglie, Is this something that should be merged? If there's no longer a hurry with 1.6.10, I guess getting some testing might not be bad here?

@cmaglie cmaglie added this to the 1.3.21 milestone Aug 26, 2016
@cmaglie
Copy link
Member

cmaglie commented Aug 26, 2016

Rebased and merged

@cmaglie cmaglie closed this Aug 26, 2016
@matthijskooijman matthijskooijman deleted the method-declaration branch January 31, 2017 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing prototype in Arduino 1.6.8
4 participants