-
Notifications
You must be signed in to change notification settings - Fork 3
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
Dredd mutates identical source files differently in two directories with same compilation database #338
Comments
Here are some ideas:
|
I can confirm that the Dredd version is the same, and Dredd behaves deterministically within each configuration. When compiling both files with the With the
|
I suggest you try the following:
This would help to confirm whether anything different is going on in the preprocessor with the two setups. I am wondering whether we might be up against an issue where strange things happen when we apply Dredd to a project that was compiled with gcc and thus has a gcc-oriented compilation database. |
Something bad is going on with The HOST_WIDE_INT_M1U define expands to -1UL, which is represented in the AST as a unary minus operator applied to an integer literal with value 1. The integer literal with value 1 should not have a source range that occurs in the main file, because it starts part way through a macro, not at the beginning of a macro. But GetSourceRangeInMainFile is returning a valid source range, and the valid source range seems to be the whole of "HOST_WIDE_INT_M1U", hence why the mutator for the integer literal with value one is being (wrongly) applied to this. |
@afd Am I correct in understanding that there are two problems at play here?
I can easily isolate problem 1 and produce a minimal reproducible example. For problem 2, the inconsistency can occur within the same file, and I am trying to produce a minimal reproducible example that contains two instances of |
Yes, that's right about there being two problems at play - hopefully not interlinked problems! |
I will put this on hold for a while. For future reference, the dredd commit used is 0725037 |
Adjusts the logic for attempting to find the main file source range of an AST node to take account of "pasted macros", which arise when the preprocessor operator ## is used. In the presence of pasted macros, the logic for determining whether an AST node corresponding to a macro expansion has a meaningful source range in the main file was not working correctly. This change detects pasted macros and conservatively refuses to give a main file source range in their presence. Fixes #345. Related issue: #338.
I just pushed a change which resolves the issue regarding:
Perhaps you could see whether the other issue persists. I have a hunch they may have been related. |
I encountered a problem where Dredd mutates the same source file differently in two directories with the same content but different directory names. The compilation database is generated in the same way for both directories and should be identical, except for references to the directory name. Dredd is applied in default mode (not using mutant tracking) to the same source file from the two different directories, and each is supplied with its own compilation database (which should only differ in the directory name references).
The reduced program (excluding several headers) is shown below. When applying Dredd to this code:
the if-stmt is mutated differently in the two directories:
compared to
This is strange because the AST generated by Dredd when mutating the source file is identical, aside from the directory name.
compared to
Let me know if there's anything else I should try to debug the issue.
The text was updated successfully, but these errors were encountered: