-
Notifications
You must be signed in to change notification settings - Fork 42
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
Apply CC fixes to existing code #700
base: dev
Are you sure you want to change the base?
Conversation
@@ -188,19 +188,17 @@ private IASTNode getMergedNode(final CLocation otherCloc) { | |||
return otherNode; | |||
} else if (otherNode == null) { | |||
return myNode; | |||
} else // we have two nodes and want to merge them; if one of both is a translation unit, we take the other |
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.
Merging else and if is a good idea in general, but it looks somehow weird, if there is a comment in between, but I don't know how to handle this.
"You selected the library mode (i.e., each procedure can be starting procedure and global " | ||
+ "variables are not initialized). This program contains a \"main\" procedure. Maybe you " | ||
+ "wanted to select the \"main\" procedure as starting procedure."; | ||
final String msg = """ |
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.
That's really a nice usage of multiline string, we were able to get rid of the quotes \"
.
result = prime * result + (mIsRestrict ? 1231 : 1237); | ||
result = prime * result + (mIsVolatile ? 1231 : 1237); | ||
return result; | ||
return Objects.hash(mIsConst, mIsExtern, mIsInline, mIsRestrict, mIsVolatile); |
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.
That's so much nicer, Boolean::hashCode
returns exactly 1231
or 1237
and Objects::hash
computes exactly this combination.
+ "if the program lost track of allocated memory. If this is set to false we are unsound (at SV-COMP) in " | ||
+ "cases where not all memory is freed but pointers to that memory are live at the end of the " | ||
+ "main procedure."; | ||
public static final String DESC_SVCOMP_MEMTRACK_COMPATIBILITY_MODE = """ |
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.
While I think these multiline Strings are generally nicer, I don't think we should change existing code, as also the line breaks are somehow strange now.
@@ -747,7 +748,7 @@ public IBacktranslatedCFG<String, CACSLLocation> translateCFG(final IBacktransla | |||
// printCFG(cfg, mLogger::info); | |||
final boolean oldValue = mGenerateBacktranslationWarnings; | |||
mGenerateBacktranslationWarnings = false; | |||
IBacktranslatedCFG<String, CACSLLocation> translated = translateCFG(cfg, (a, b, c) -> translateCFGEdge(a, b, c), | |||
IBacktranslatedCFG<String, CACSLLocation> translated = translateCFG(cfg, (IFunction<Map<IExplicitEdgesMultigraph<?, ?, String, ? extends BoogieASTNode, ?>, Multigraph<String, CACSLLocation>>, IMultigraphEdge<?, ?, String, BoogieASTNode, ?>, Multigraph<String, CACSLLocation>, Multigraph<String, CACSLLocation>>) this::translateCFGEdge, |
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 change is really bad! In general, this::translateCFGEdge
is a bit nicer than (a, b, c) -> translateCFGEdge(a, b, c)
, but the save actions introduced an unncessary cast here and for long class names C
, I actually prefer c -> f(c)
over C::f
.
// we only update the table with a declaration, if there is no entry for that name yet. | ||
// otherwise we might only keep the declaration and omit the implementation from | ||
// reachableDeclarations. | ||
if ((d instanceof IASTFunctionDeclarator) && !mFunctionTable.containsKey(rslvKey)) { |
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.
Oddly enough, Eclipse inserts unnecessary parentheses here that would be removed again, if we run the save actions afterwards again 😆
@@ -134,7 +134,7 @@ public BacktranslatedExpression translateEnsuresExpression( | |||
|
|||
private Optional<Expression> computeOldVarEqualities(final String proc, | |||
final Set<de.uni_freiburg.informatik.ultimate.boogie.ast.IdentifierExpression> modifiableGlobals) { | |||
final var modifiableNames = modifiableGlobals.stream().map(e -> e.getIdentifier()).collect(Collectors.toSet()); | |||
final var modifiableNames = modifiableGlobals.stream().map(de.uni_freiburg.informatik.ultimate.boogie.ast.IdentifierExpression::getIdentifier).collect(Collectors.toSet()); |
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.
e -> e.getIdentifier())
is definitely nicer than de.uni_freiburg.informatik.ultimate.boogie.ast.IdentifierExpression::getIdentifier
...
Also, Eclipse does not respect the maximum line length here.
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.
Maybe even without this change, we should run Clean up
twice.
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.
Up to the fixpoint :)
During the update to Java 21 (see #672), we also slightly changed our coding conventions.
This can lead to unnecessary diffs, when editing existing files (many existing file did not even follow our old coding conventions...).
In this PR I applied the new coding conventions automatically (starting with
CACSL2BoogieTranslator
) and we can discuss possible changes to the coding conventions here.Eclipse does not actually allow to apply the save actions automatically to multiple files. But I found a way 😉
Clean Up
that can be applied on a whole project under theSource
menu (Note: There is also a commandFormat
there, but it only applies the formatter).Clean Up
actions can be set up underPreferences
->Java
->Code Style
->Cleanup
and they are almost the same as the save actions, but their is no common way to set them..xml
file that can be imported under the cleanup-settings from our.epf
file.Source
->Clean up
, which should apply our save actions on multiple files automatically.