[llvm-dev] [docs][RFC] Style for "end namespace" comments

Carlos Galvez via llvm-dev llvm-dev at lists.llvm.org
Mon Dec 6 11:16:16 PST 2021


Hi,

I was recently working on a patch and was asked during review to replace
existing:
"// end namespace clang"   Style A
with :
"// namespace clang"          Style B

After that, I got interested to understand what the preferred style is, and
found in the Coding Guidelines
<https://llvm.org/docs/CodingStandards.html#use-namespace-qualifiers-to-implement-previously-declared-functions>
that the style is actually Style A.

On the other hand, clang-format will automatically enforce Style B on new
code, via the FixNamespaceComments option, which is set to "true" for the
LLVM style. clang-format will keep the Style A if it already exists,
however. Most people using clang-format (outside LLVM) will probably be
more familiar with Style B.

Additionally, I have seen the following usage numbers in the repo:

$ git grep '//

* end' | wc -l6724$ git grep '//* namespace' | wc -l
14348

So Style B seems to be more adopted. Therefore I wanted to ask - should we
update the Coding Guidelines to reflect this, and avoid these kinds of
style discussions in code reviews? If so, what style should be preferred? I
have a patch <https://reviews.llvm.org/D115115> for review and there seems
to be a preference for keeping both styles. Regardless of the choice, I
don't think this should lead to an urgent style change of the whole
codebase.

Looking forward to your feedback!

Best regards,
Carlos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211206/7804dd2c/attachment.html>


More information about the llvm-dev mailing list