This is an archive of the discontinued LLVM Phabricator instance.

[libc][NFC] Make all top of file comments consistent.
ClosedPublic

Authored by PaulkaToast on Apr 6 2020, 2:44 AM.

Details

Summary

Made all header files consistent based of this documentation: https://llvm.org/docs/CodingStandards.html#file-headers.
And did the same for all source files top of file comments.

Diff Detail

Event Timeline

PaulkaToast created this revision.Apr 6 2020, 2:44 AM

Added header guards where they were missing.

sivachandra accepted this revision.Apr 6 2020, 9:35 AM
This revision is now accepted and ready to land.Apr 6 2020, 9:35 AM
abrachet added inline comments.Apr 6 2020, 10:04 AM
libc/include/__llvm-libc-common.h
1

Looks like there is a - --- which we should make ---. Also should these have -*- C++ -*-?

libc/include/__posix-types.h
1

Same for the C++ tag here.

libc/include/ctype.h
1

Here as well, or at least we should remove the *

libc/utils/CPP/StringRef.h
9–11

We shouldn't remove the include

22–23

Newline

Also, although we only want header files to have the C++ tag, shouldn't we also left justify the text in our .cpp files too?

sivachandra added inline comments.Apr 6 2020, 10:44 AM
libc/include/__llvm-libc-common.h
1

We shouldn't have C++ here as these are public C headers. The rest of the comment is valid.

libc/include/__posix-types.h
1

Same with C++ here.

libc/include/ctype.h
1

I noticed this as well :)
But really this header should be removed in a separate CL.

libc/utils/CPP/StringRef.h
9–11

Thanks for catching this.

Also, although we only want header files to have the C++ tag, shouldn't we also left justify the text in our .cpp files too?

Yes, at least for consistency.

For future integrity, are there are any clang-format/clang-tidy rules which can warn us about such misses? For bad/missing headers guards, there are clang-tidy rules available for LLVM.

PaulkaToast marked 10 inline comments as done.

Also, although we only want header files to have the C++ tag, shouldn't we also left justify the text in our .cpp files too?

Yes, at least for consistency.

For future integrity, are there are any clang-format/clang-tidy rules which can warn us about such misses? For bad/missing headers guards, there are clang-tidy rules available for LLVM.

I'll look into this, I'm sure a check exists or we can make one.

libc/utils/CPP/StringRef.h
9–11

oops! thank you for catching this!

sivachandra accepted this revision.Apr 6 2020, 2:35 PM

I continue to accept this. But, I missed some obvious things previously so, wait for @abrachet to take a look as well.
One thing though, this change is now wider than the original description. So, update the description here (and also in your local git repo if you use git llvm push.)

abrachet accepted this revision.Apr 6 2020, 3:27 PM

Just some nits inline.

One thing though, this change is now wider than the original description. So, update the description here (and also in your local git repo if you use git llvm push.)

It might also be useful to add [NFC] to the name while you're at it.

Also, although we only want header files to have the C++ tag, shouldn't we also left justify the text in our .cpp files too?

Yes, at least for consistency.

For future integrity, are there are any clang-format/clang-tidy rules which can warn us about such misses? For bad/missing headers guards, there are clang-tidy rules available for LLVM.

I'll look into this, I'm sure a check exists or we can make one.

My guess although I'm not sure is it would be difficult to get this into clang-format because it's very LLVM specific. I also don't know if it would work in clang-tidy, I'm not sure if comments are expressed in the AST but @PaulkaToast would know more than me :) It would be very useful for one of these tools to do this for us for sure.

libc/config/linux/errno.h.in
1 ↗(On Diff #255432)

This has 3 leading -

libc/include/__llvm-libc-common.h
1

You're right we shouldn't have them in the public headers. libcxx does this but they also have no extension at all not just .h, also most of headers are generated so its very little use to us.

libc/src/threads/linux/thread_start_args.h.def
1 ↗(On Diff #255432)

Add an extra - at the end, the * is right next to the =

libc/utils/CPP/StringRef.h
1

Looks like two spaces between type and -

libc/utils/HdrGen/PublicAPICommand.cpp
1 ↗(On Diff #255432)

There is a * here

libc/utils/benchmarks/LibcMemoryBenchmarkMain.cpp
1 ↗(On Diff #255432)

Two trailing spaces here

libc/utils/benchmarks/LibcMemoryBenchmarkTest.cpp
1 ↗(On Diff #255432)

No space between - and `

libc/utils/testutils/ExecuteFunction.h
1

Three leading -

PaulkaToast marked 7 inline comments as done.
PaulkaToast retitled this revision from [libc] Make all header comments consistent. to [libc][NFC] Make all top of file comments consistent..
PaulkaToast edited the summary of this revision. (Show Details)

Thanks Alex!

This revision was automatically updated to reflect the committed changes.