[PATCH] D115115: [doc] Fix namespace comment style in Coding Guidelines

Carlos Galvez via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 5 07:03:15 PST 2021


carlosgalvezp created this revision.
carlosgalvezp requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The Coding Guidelines specify that the ending brace of a
namespace shall have a comment like:

}  // end namespace clang

However the majority of the code uses a different style:

}  // namespace clang

Indeed:

$ git grep "// end" | wc -l
6724
$ git grep "// namespace" | wc -l
14348

Besides, this is the style enforced automatically by clang-format,
via the FixNamespaceComments option.

Having inconsistencies between the Coding Guidelines and the
code/tooling creates confusion, can lead to bikeshedding during
reviews and overall delays merging code. Therefore, update the
guidelines to reflect current usage. Updating legacy code to the
new standard should be done in a separate patch, if wanted.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115115

Files:
  llvm/docs/CodingStandards.rst


Index: llvm/docs/CodingStandards.rst
===================================================================
--- llvm/docs/CodingStandards.rst
+++ llvm/docs/CodingStandards.rst
@@ -844,7 +844,7 @@
   namespace llvm {
   int foo(char *s) { // Mismatch between "const char *" and "char *"
   }
-  } // end namespace llvm
+  } // namespace llvm
 
 This error will not be caught until the build is nearly complete, when the
 linker fails to find a definition for any uses of the original function.  If the
@@ -1508,8 +1508,8 @@
 
   };
 
-  } // end namespace knowledge
-  } // end namespace llvm
+  } // namespace knowledge
+  } // namespace llvm
 
 
 Feel free to skip the closing comment when the namespace being closed is
@@ -1550,7 +1550,7 @@
     StringSort(...)
     bool operator<(const char *RHS) const;
   };
-  } // end anonymous namespace
+  } // namespace
 
   static void runHelper() {
     ...
@@ -1574,7 +1574,7 @@
 
   // ... many declarations ...
 
-  } // end anonymous namespace
+  } // namespace
 
 When you are looking at "``runHelper``" in the middle of a large C++ file,
 you have no immediate way to tell if this function is local to the file.  In


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115115.391909.patch
Type: text/x-patch
Size: 1165 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211205/fefbdabb/attachment.bin>


More information about the llvm-commits mailing list