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

[DO NOT LAND] src: run clang-format on LINT_CPP_FILES #21998

Closed

Conversation

joyeecheung
Copy link
Member

This is how the clang-format file in #21997 styles the $LINT_CPP_FILES. It's just a preview, so please ignore it if you are not curious about how the styles enforced in #21997 look like.

Produced with

tools/clang-format/node_modules/.bin/clang-format -i --style=file $(LINT_CPP_FILES)
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. labels Jul 27, 2018
@addaleax addaleax added the blocked PRs that are blocked by other issues or PRs. label Jul 27, 2018
This patch adds a `make format-cpp` shortcut to the Makefile
that runs clang-format on the C++ diffs, and a
`make format-cpp-build` to install clang-format from
npm.

To format staged changes:

```
$ make format-cpp
```

To format HEAD~1...HEAD (latest commit):

```
$ CLANG_FORMAT_START=`git rev-parse HEAD~1` make format-cpp
```

To format diff between master and current branch head (master...HEAD):

```
$ CLANG_FORMAT_START=master make format-cpp
```

Most of the .clang-format file comes from running

```
$ clang-format --dump-config --style=Google
```

with clang-format built with llvm/trunk 328768 (npm version 1.2.3)

The clang-format version is fixed because different version of
clang-format may format the files differently.
@joyeecheung joyeecheung force-pushed the clang-format-diff-result branch from a6b3e3a to 8bf9df6 Compare August 1, 2018 09:37
@joyeecheung joyeecheung force-pushed the clang-format-diff-result branch from 3babcbc to 189cd50 Compare August 1, 2018 10:02
@@ -25,10 +25,7 @@ template <class NativeT, class V8T>
class AliasedBuffer {
public:
AliasedBuffer(v8::Isolate* isolate, const size_t count)
: isolate_(isolate),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i feel like this was more readable before

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ConstructorInitializerAllOnOneLineOrOnePerLine. There is apparently no option to force one per line.

@@ -135,9 +127,7 @@ class AliasedBuffer {
return *this = static_cast<NativeT>(val);
}

operator NativeT() const {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have return always on a new line?

@@ -33,46 +32,39 @@ static inline size_t base64_decoded_size_fast(size_t size) {

template <typename TypeName>
size_t base64_decoded_size(const TypeName* src, size_t size) {
if (size == 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return on new line

Boolean::New(env->isolate(), readable),
Boolean::New(env->isolate(), writable)
};
Local<Value> argv[5] = {Integer::New(env->isolate(), status),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ouch

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@devsnek Yeah I thought it looked strange but then this came from Google's style and in the documentation they argued this is more suited for C++11 (This is named Cpp11BracedListStyle)

@joyeecheung
Copy link
Member Author

I think this PR has run its course. Closing...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked PRs that are blocked by other issues or PRs. c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants