Skip to content

Commit ae008ce

Browse files
committed
[NFC][CodingStandard] Extend "Use Namespace Qualifiers" to variables
Extend the coding standard for defining out-of-line definitions of functions in namespaces to variables as well, and change the wording to use the term definition instead of implementation.
1 parent 52c2e45 commit ae008ce

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

llvm/docs/CodingStandards.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -852,23 +852,27 @@ your private interface remains private and undisturbed by outsiders.
852852
It's okay to put extra implementation methods in a public class itself. Just
853853
make them private (or protected) and all is well.
854854

855-
Use Namespace Qualifiers to Implement Previously Declared Functions
856-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
855+
Use Namespace Qualifiers to Define Previously Declared Variables & Functions
856+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
857857

858-
When providing an out of line implementation of a function in a source file, do
859-
not open namespace blocks in the source file. Instead, use namespace qualifiers
860-
to help ensure that your definition matches an existing declaration. Do this:
858+
When providing an out of line definition of a variable or a function in a source
859+
file, do not open namespace blocks in the source file. Instead, use namespace
860+
qualifiers to help ensure that your definition matches an existing declaration.
861+
Do this:
861862

862863
.. code-block:: c++
863864

864865
// Foo.h
865866
namespace llvm {
867+
cl::opt<bool> FooOption;
866868
int foo(const char *s);
867869
}
868870
869871
// Foo.cpp
870872
#include "Foo.h"
871873
using namespace llvm;
874+
875+
cl::opt<bool> llvm::FooOption(/*...*/);
872876
int llvm::foo(const char *s) {
873877
// ...
874878
}

0 commit comments

Comments
 (0)