Getting ready to clang-format everything...

443 views
Skip to first unread message

Carlsen, Robert W

unread,
Mar 14, 2017, 11:49:42 AM3/14/17
to moose...@googlegroups.com
To all MOOSE users and developers:

We are planning to switch to a clang-format enforced code style.  In about 1 week from today, we will format all C++ code in the MOOSE repository to the new code style.

We'd prefer that you don't reformat existing code in the repository in until after we do the baseline reformat of everything.  You are, however, welcome to format changed/new lines of code you are working on.  The ".clang-format" file for the style is already in the repository along with an install script for git a pre-commit hook check.  You can also use tools like "git clang-format" that only reformat diff'd lines.

After the update, in-progress work will need to be rebased/updated.  We will provide scripts for rebasing your in-progress work across the big reformat commit.  You will probably want to get your editor ready to auto-format C/C++ code on save (although don't enable it until after we update MOOSE first).  Auto-format plugins/functionality is available for every editor/environment worth using (just google clang-format plugin [editor]).  CIVET will be updated to fail/reject PRs that don't follow the style and will print a diff of changes that need to be made to comply.

Stay tuned.

john.m...@uconn.edu

unread,
Mar 15, 2017, 12:12:06 PM3/15/17
to moose-users
is this going to affect HPC resources?

princessandsuperman

unread,
Mar 15, 2017, 6:21:45 PM3/15/17
to moose-users
This is just for the MOOSE framework repository (for now).

John Mangeri

unread,
Mar 16, 2017, 11:10:10 AM3/16/17
to moose...@googlegroups.com
OK... so will it compile on older g++? Ect? Or are clang compatible compilers going to be required?





--
You received this message because you are subscribed to a topic in the Google Groups "moose-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/moose-users/FoKtoKa9FUg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to moose-users+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/moose-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/moose-users/60fa7dfd-6cab-4566-b89f-bdcbc5a7253a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Cody Permann

unread,
Mar 16, 2017, 11:19:58 AM3/16/17
to moose...@googlegroups.com
John, This is just formatting. We happen to be using a clang tool to apply the formatting, but it's nothing more than whitespace changes. The only difficulty you will have on systems without clang is the ability to apply the formatting correctly on your own. We plan to make CIVET generate a patch for you in those cases. Say goodbye to a ton of messages from the maintainers about spacing problems in your code. It should be mostly automated moving forward.

On Thu, Mar 16, 2017 at 9:10 AM John Mangeri <john.m...@uconn.edu> wrote:
OK... so will it compile on older g++? Ect? Or are clang compatible compilers going to be required?





On Mar 15, 2017 5:21 PM, "princessandsuperman" <princessa...@gmail.com> wrote:
This is just for the MOOSE framework repository (for now).

On Wednesday, March 15, 2017 at 10:12:06 AM UTC-6, john.m...@uconn.edu wrote:
is this going to affect HPC resources?

--
You received this message because you are subscribed to a topic in the Google Groups "moose-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/moose-users/FoKtoKa9FUg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to moose-users...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moose-users...@googlegroups.com.

Andrew....@csiro.au

unread,
Mar 19, 2017, 7:43:46 PM3/19/17
to moose...@googlegroups.com

Could you please provide more explicit step-by-step details on how to get clang format working with emacs (and i guess other editors too).  I just want the C++ to be formatted correctly as i type.

 

On my Mac, with the MOOSE package provided by you, i see that there is a file /opt/moose/llvm-3.9.0/share/clang/clang-format.el, which i presume i have to load somehow in my ~/.emacs file.  When i try to do this, I get the message “File error: Cannot open load file, cl-lib”, so obviously that’s wrong.  Also, there is a file, projects/moose/.clang-format that I suppose I have to use somehow.

 

On my clusters, what do I do?  Do I have to get the admins to install clang-format (any version?), or more?

 

a

 

 

Ph: +61 7 3327 4497.  Fax: +61 7 3327 4666
Queensland Centre for Advanced Technologies
PO Box 883, Kenmore, Qld, 4069 
 

--

You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moose-users...@googlegroups.com.
Visit this group at https://groups.google.com/group/moose-users.

Andrew....@csiro.au

unread,
Mar 19, 2017, 7:45:14 PM3/19/17
to moose...@googlegroups.com
Sorry, previous email would likely be infected by spam. Here's the content of the previous email:

princessandsuperman

unread,
Mar 20, 2017, 12:24:12 PM3/20/17
to moose-users

Daniel Schwen

unread,
Mar 20, 2017, 12:49:51 PM3/20/17
to moose-users

Andrew....@csiro.au

unread,
Mar 20, 2017, 6:11:14 PM3/20/17
to moose...@googlegroups.com
​Yes, i believe i followed the instructions at the link you mention, however, i got the error "File error: Cannot open load file, cl-lib" This was using the clang-format.el in /opt/moose/llvm-3.9.0/share/clang/clang-format.el (see email below for details).

Could you please provide more explicit instructions?

a

http://clang.llvm.org/docs/ClangFormat.html#emacs-integration

a

To view this discussion on the web visit https://groups.google.com/d/msgid/moose-users/e14be989-a169-431a-95da-aa0a3e027e0b%40googlegroups.com.

princessandsuperman

unread,
Mar 20, 2017, 6:21:17 PM3/20/17
to moose-users
I'm a vim user myself.  Something like this maybe: http://stackoverflow.com/questions/20678847/cannot-load-cl-lib-at-emacs-startup? clang-format is included with the clang compiler toolchain.  So any clang (compiler) install should already include clang-format.  Note that we use 3.9 or newer for our formatting.

Cody Permann

unread,
Mar 20, 2017, 6:24:26 PM3/20/17
to moose-users
Andy, I don't know if any of us Emacs users have actually tried this step yet. I was waiting for the actual deployment so I wouldn't get spurious changes all over the place in the meantime. We'll share more lessons learned on getting your editors whipped into shape following the deployment. Looks like Robert's link is probably the fix you need here though.

Andrew....@csiro.au

unread,
Mar 20, 2017, 6:55:32 PM3/20/17
to moose...@googlegroups.com
OK, i think i’ll let you guys sort out this clang-format stuff and then tell me what to do. I downloaded Robert’s cl-lib.el, and it sort of worked, but upon loading it, emacs complained

Symbol’s function definition is void: declare-function

I don’t know if this is a big deal or not.

a

Ph: +61 7 3327 4497.  Fax: +61 7 3327 4666
Queensland Centre for Advanced Technologies
PO Box 883, Kenmore, Qld, 4069 
 
To view this discussion on the web visit https://groups.google.com/d/msgid/moose-users/CAK06EuXL%3D4mto0VPiJPEF7SiG_q%2BmRmLPCppf6HTMi%3DYVmvr7A%40mail.gmail.com.

Cody Permann

unread,
Mar 21, 2017, 3:13:46 PM3/21/17
to moose...@googlegroups.com
Andy,

I loaded the emacs plugin today on my Mac and it worked out of the box. I didn't have to load the cl-lib.el file like you did. I'm running a fairly recent version of Emacs but I'm not sure if that's why you are seeing a problem and I'm not. You said it appears to be working though?

Andrew....@csiro.au

unread,
Mar 21, 2017, 4:57:56 PM3/21/17
to moose...@googlegroups.com

Sounds promising, thanks Cody. I'll report back after giving it a try, today hopefully.

a

Andy,

a

To view this discussion on the web visit https://groups.google.com/d/msgid/moose-users/CAK06EuWSb7qELcsaoV_vmcPtfWfVmDWQJeGu5V9EMg3wF8UnSg%40mail.gmail.com.

Cody Permann

unread,
Mar 21, 2017, 5:02:39 PM3/21/17
to moose...@googlegroups.com
Also, for those emacs users out there, I've added the relevant portion of my ".emacs" configure to Robert's blog post (at the bottom). It turns on clang format so you can format files with a normal emacs key binding. I've also set it to automatically run clang format whenever you save any source file inside the MOOSE repository. It shouldn't affect source files in your own repositories.

Andrew....@csiro.au

unread,
Mar 22, 2017, 6:44:56 AM3/22/17
to moose...@googlegroups.com
​I couldn't get this to work quite perfectly. I left some notes at the bottom of the blog entry on mooseframework.org

a

a

Andy,

a

To view this discussion on the web visit https://groups.google.com/d/msgid/moose-users/CAK06EuWyT4JRd1a2ki1j5hrN5Q9uPbEmFrVE%3DR3pfq_H01JMaQ%40mail.gmail.com.

Cody Permann

unread,
Mar 22, 2017, 10:43:33 AM3/22/17
to moose...@googlegroups.com
I had a similar problem as you reported (over-aggressive formatting). I was able to fix it by re-ordering my hooks. I can now edit non-C++ files without having clang-format trying to format them.

Alex Lindsay

unread,
Apr 18, 2017, 7:05:44 PM4/18/17
to moose...@googlegroups.com
I noticed that clang-format doesn't like the opening curly brace to be on its own line, but I thought the MOOSE style was for it to have its own line. You guys aren't using a custom style for your clang-format are you? Should we move then to the clang-format default?

Slaughter, Andrew E

unread,
Apr 18, 2017, 7:22:12 PM4/18/17
to moose...@googlegroups.com
We are using a custom format, the is a ".clang-format" file in MOOSE at the top-level that sets up the "MOOSE" style.

To unsubscribe from this group and stop receiving emails from it, send an email to   moose-users+unsubscribe@googlegroups.com.

Visit this group at   https://groups.google.com/group/moose-users.
To view this discussion on the web visit   https://groups.google.com/d/msgid/moose-users/0f49e256-228f-4a4f-9bab-086cb1bd55aa%40googlegroups.com.
For more options, visit   https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to   moose-users+unsubscribe@googlegroups.com.

Visit this group at   https://groups.google.com/group/moose-users.
To view this discussion on the web visit   https://groups.google.com/d/msgid/moose-users/CAK06EuXL%3D4mto0VPiJPEF7SiG_q%2BmRmLPCppf6HTMi%3DYVmvr7A%40mail.gmail.com.
For more options, visit   https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to   moose-users+unsubscribe@googlegroups.com.

Visit this group at   https://groups.google.com/group/moose-users.
To view this discussion on the web visit   https://groups.google.com/d/msgid/moose-users/c6d241327f8c44c99a3989ecefdeba17%40exch3-cdc.nexus.csiro.au.
For more options, visit   https://groups.google.com/d/optout.

 --
You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to  moose-users+unsubscribe@googlegroups.com.

Visit this group at  https://groups.google.com/group/moose-users.
To view this discussion on the web visit   https://groups.google.com/d/msgid/moose-users/CAK06EuWSb7qELcsaoV_vmcPtfWfVmDWQJeGu5V9EMg3wF8UnSg%40mail.gmail.com.
For more options, visit  https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to  moose-users+unsubscribe@googlegroups.com.

Visit this group at  https://groups.google.com/group/moose-users.
To view this discussion on the web visit  https://groups.google.com/d/msgid/moose-users/1490129868677.99434%40csiro.au.
For more options, visit  https://groups.google.com/d/optout.

 --
You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moose-users+unsubscribe@googlegroups.com.

Visit this group at https://groups.google.com/group/moose-users.
To view this discussion on the web visit  https://groups.google.com/d/msgid/moose-users/CAK06EuWyT4JRd1a2ki1j5hrN5Q9uPbEmFrVE%3DR3pfq_H01JMaQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moose-users+unsubscribe@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moose-users+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moose-users+unsubscribe@googlegroups.com.

Alex Lindsay

unread,
Apr 19, 2017, 10:10:24 AM4/19/17
to moose...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages