This is an archive of the discontinued LLVM Phabricator instance.

[clangd] LLVM-ify codebase
AbandonedPublic

Authored by omtcyfz on Jun 26 2017, 11:43 AM.

Details

Reviewers
None
Summary

This patch introduces cosmetic changes while making ClangD code slightly more LLVM Coding Standards-compliant by

  • Convert names of struct fields in Protocol.h from camelCase to CamelCase
  • Enclose code in .cpp implementation files in appropriate namespaces instead of doing using namespace clang; using namespace clangd;
  • Putting few consts and references where appropriate

Testing:
$ ninja check-clang-tools
All ClangD-related tests are green.

Diff Detail

Event Timeline

omtcyfz created this revision.Jun 26 2017, 11:43 AM
omtcyfz removed a subscriber: cfe-commits.

I've stumbled upon your review by accident, I don't know if it's final or not, but still wanted to add a comment.

I think the original idea for camelCase identifiers was to mimic the names from LSP specification.
IMO, we should follow LLVM code style there, but nevertheless it's probably a good idea to ask original author.

clangd/ClangdServer.h
115

Why do you feel pass-by-const-ref here is better than pass-by-value?

We're storing functions inside a vector there, so we would need a copy anyway.
Using pass-by-value allows to std::move into the function, pass-by-const-ref doesn't allow that.

ilya-biryukov added inline comments.Jun 29 2017, 6:21 AM
clangd/Protocol.h
56

The idea is to follow LSP spec closely, so it's probably better to call it 'Character' (i.e. let the name be the same modulo naming conventions).
See: https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#position

@ilya-biryukov thanks for the comments!

Overall, the patch adds literally zero functionality, so I'd better focus on doing something meaningful. I removed reviewers and abandoned the efforts for now because more recent patches were submitted and thus this one should be rebased and I'd need to tweak a couple of things.

clangd/ClangdServer.h
115

Fair point. There is one copying happening anyway, though.

clangd/Protocol.h
56

Yes, I had that impression after reading protocol specification. However, I inspected the clangd codebase and found that it doesn't use exactly the same names and structures everywhere. Therefore, I thought it would be correct to use llvm-ish style anyway. I don't have any objections if the naming would be exactly like in protocol's code snippets. I just felt like this could be a readability improvement since most of the code has different naming style and it simply becomes a mix. Anyway, that's not too important.

omtcyfz abandoned this revision.Jul 20 2018, 1:47 AM

No longer relevant.