[llvm] d401301 - [doc] Fix namespace comment style in Coding Guidelines

Carlos Galvez via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 7 05:36:58 PST 2021


Author: Carlos Galvez
Date: 2021-12-07T13:36:25Z
New Revision: d40130199f766ca8c153d1cc61fec86d523aa81a

URL: https://github.com/llvm/llvm-project/commit/d40130199f766ca8c153d1cc61fec86d523aa81a
DIFF: https://github.com/llvm/llvm-project/commit/d40130199f766ca8c153d1cc61fec86d523aa81a.diff

LOG: [doc] Fix namespace comment style in Coding Guidelines

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.

Reviewed By: jyknight

Differential Revision: https://reviews.llvm.org/D115115

Added: 
    

Modified: 
    llvm/docs/CodingStandards.rst

Removed: 
    


################################################################################
diff  --git a/llvm/docs/CodingStandards.rst b/llvm/docs/CodingStandards.rst
index 55a8bc16cf5dc..4ddeea5e111b8 100644
--- a/llvm/docs/CodingStandards.rst
+++ b/llvm/docs/CodingStandards.rst
@@ -844,7 +844,7 @@ function declared in the header:
   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 @@ being closed by a ``}``.  For example:
 
   };
 
-  } // 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 @@ as possible, and only use them for class declarations.  For example:
     StringSort(...)
     bool operator<(const char *RHS) const;
   };
-  } // end anonymous namespace
+  } // namespace
 
   static void runHelper() {
     ...
@@ -1574,7 +1574,7 @@ Avoid putting declarations other than classes into anonymous namespaces:
 
   // ... 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


        


More information about the llvm-commits mailing list