Skip to content
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

Add braces after control statements #21478

Closed

Conversation

fwyzard
Copy link
Contributor

@fwyzard fwyzard commented Nov 28, 2017

This should add braces after control statements, e.g. change

if (something)
  do_something();

to

if (something) {
  do_something();
}

@fwyzard
Copy link
Contributor Author

fwyzard commented Nov 28, 2017

@cmsbuild, please test

@cmsbuild
Copy link
Contributor

The code-checks are being triggered in jenkins.

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/PR-21478/2222

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 28, 2017

The tests are being triggered in jenkins.
https://cmssdt.cern.ch/jenkins/job/ib-any-integration/24729/console Started: 2017/11/28 20:15

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @fwyzard (Andrea Bocci) for master.

It involves the following packages:

.clang-tidy

The following packages do not have a category, yet:

.clang-tidy
Please create a PR for https://github.com/cms-sw/cms-bot/blob/master/categories.py to assign category

@cmsbuild can you please review it and eventually sign? Thanks.
@davidlange6, @slava77 you are the release manager for this.

cms-bot commands are listed here

@cmsbuild
Copy link
Contributor

Pull request #21478 was updated. @smuzaffar, @Dr15Jones can you please check and sign again.

@Dr15Jones
Copy link
Contributor

+1

@cmsbuild
Copy link
Contributor

This pull request is fully signed and it will be integrated in one of the next master IBs after it passes the integration tests. This pull request will now be reviewed by the release team before it's merged. @davidlange6, @slava77, @smuzaffar (and backports should be raised in the release meeting by the corresponding L2)

@davidlange6
Copy link
Contributor

davidlange6 commented Nov 28, 2017 via email

@Dr15Jones
Copy link
Contributor

I'd say it was an improvement.

@fwyzard
Copy link
Contributor Author

fwyzard commented Nov 28, 2017

Maybe it expects clang-format to take care of the newlines etc. ?

@cmsbuild
Copy link
Contributor

The tests are being triggered in jenkins.
Tested with other pull request(s) #26563,cms-sw/cmsdist#4914

@smuzaffar
Copy link
Contributor

-1
@fwyzard, for some cases this check is not generating valid code. For statements which ends with }; e.g

if (condition) return {};

it generates code like

if (condition) { return {}};

In some cases it also adds extra {} for classes/struct

diff --git a/OnlineDB/EcalCondDB/interface/LMFLmrSubIOV.h b/OnlineDB/EcalCondDB/interface/LMFLmrSubIOV.h
index 78fc1a87de4..15aa2925220 100644
--- a/OnlineDB/EcalCondDB/interface/LMFLmrSubIOV.h
+++ b/OnlineDB/EcalCondDB/interface/LMFLmrSubIOV.h
@@ -10,7 +10,8 @@
 #include "OnlineDB/EcalCondDB/interface/LMFUnique.h"
 #include "OnlineDB/EcalCondDB/interface/LMFIOV.h"
 
-class LMFLmrSubIOV : public LMFUnique {
+class LMFLmrSubIOV { 
+}: public LMFUnique {
  public:
   friend class EcalCondDBInterface;
 
diff --git a/OnlineDB/EcalCondDB/interface/LMFSextuple.h b/OnlineDB/EcalCondDB/interface/LMFSextuple.h
index 6559c9f769c..1573587ec4a 100644
--- a/OnlineDB/EcalCondDB/interface/LMFSextuple.h
+++ b/OnlineDB/EcalCondDB/interface/LMFSextuple.h
@@ -10,7 +10,8 @@
 /**
  *   sextuple of t1, t2, t3, p1, p2, p3
  */
-class LMFSextuple {
+class LMFSextuple { 
+}{
  public:
   LMFSextuple() {
     for (int i = 0; i < 3; i++) {

you can reproduce it by running

scram p CMSSW_10_6_X_2019-04-29-2300
cd CMSSW_10_6_X_2019-04-29-2300/src
cmsenv
git cms-merge-topic -u 21478
git cms-addpkg OnlineDB/EcalCondDB
scram b llvm-ccdb
clang-tidy -fix -header-filter "$CMSSW_BASE/src/.*" OnlineDB/EcalCondDB/src/LMFCorrCoefDat.cc

@fwyzard
Copy link
Contributor Author

fwyzard commented Apr 30, 2019

Indeed, I can reproduce it also with a very simple, stand alone test case.

Looks like this option is not ready for prime time... can anyone check if the clang 9 nightly hhas better luck, and/or submit a but report to clang ?

@davidlange6
Copy link
Contributor

davidlange6 commented Apr 30, 2019 via email

@makortel
Copy link
Contributor

makortel commented Apr 30, 2019

if (condition) return {};

does this syntax make sense?

return {}; is a short hand for the default constructor of the return type of the function.

@fwyzard
Copy link
Contributor Author

fwyzard commented Apr 30, 2019

if (condition) return {};

does this syntax make sense?

yes, for example when returning a struct by value.

if (condition) { return {}};

not sure what else it should do? perhaps the issue is with the original code...

I think it should have become

if (condition) {
  return {};
}

@davidlange6
Copy link
Contributor

davidlange6 commented Apr 30, 2019 via email

@smuzaffar smuzaffar modified the milestones: CMSSW_10_6_X, CMSSW_11_0_X May 14, 2019
@fabiocos
Copy link
Contributor

@fwyzard @smuzaffar from the latest checks it looks like this option is not ready for production, at least until a fix is provided for the problematic cases observed. What should we do with this PR? Close it and may be open an issue to track the planned update, verifying whether there is a fix in clang?

@fwyzard
Copy link
Contributor Author

fwyzard commented May 20, 2019

We can do whatever you think makes the most sense.

@fabiocos
Copy link
Contributor

hold

pending a solution in clang-tidy for the issue above mentioned

@cmsbuild
Copy link
Contributor

Pull request has been put on hold by @fabiocos
They need to issue an unhold command to remove the hold state or L1 can unhold it for all

@cmsbuild cmsbuild added the hold label May 23, 2019
@smuzaffar
Copy link
Contributor

There are quite a few bugs opens for this check
https://bugs.llvm.org/buglist.cgi?quicksearch=clang-tidy%20braces&list_id=162527

the one I mentioned #21478 (comment) is open since DEC 2015 ( https://bugs.llvm.org/show_bug.cgi?id=25970 ).

@fabiocos
Copy link
Contributor

@smuzaffar yes, this hold risks to last quite long... :-(

@fabiocos
Copy link
Contributor

@fwyzard I have opened #27082 to keep track of this proposal, that we should reconsider when clang-tidy is updated. For the time being I believe this PR could just be closed.

@fwyzard
Copy link
Contributor Author

fwyzard commented Aug 12, 2019

Tracked by #27082 .

@fwyzard fwyzard closed this Aug 12, 2019
@fwyzard fwyzard deleted the add_braces_after_control_statements branch August 12, 2019 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants