Skip to content

Commit b75122e

Browse files
committed
[LLVM][CodingStandard] Extend namespace qualifier rule to variables
Extend CS rule to use namespace qialifiers to define previously declared functions to variables as well.
1 parent 16dfd31 commit b75122e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

llvm/docs/CodingStandards.rst

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

863-
Use Namespace Qualifiers to Implement Previously Declared Functions
864-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
863+
Use Namespace Qualifiers to Define Previously Declared Variables and Functions
864+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
865865

866-
When providing an out-of-line implementation of a function in a source file, do
867-
not open namespace blocks in the source file. Instead, use namespace qualifiers
868-
to help ensure that your definition matches an existing declaration. Do this:
866+
When providing an out-of-line definition of a variable or a function in a source
867+
file, do not open namespace blocks in the source file. Instead, use namespace
868+
qualifiers to help ensure that your definition matches an existing declaration.
869+
Do this:
869870

870871
.. code-block:: c++
871872

872873
// Foo.h
873874
namespace llvm {
875+
extern int FooVal;
874876
int foo(const char *s);
875877
}
876878
877879
// Foo.cpp
878880
#include "Foo.h"
879881
using namespace llvm;
882+
883+
int llvm::FooVal;
884+
880885
int llvm::foo(const char *s) {
881886
// ...
882887
}

0 commit comments

Comments
 (0)