[llvm] [LLVM][CodingStandard] Extend namespace qualifier rule to variables (PR #163588)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 15 09:38:06 PDT 2025


https://github.com/jurahul created https://github.com/llvm/llvm-project/pull/163588

Extend CS rule to use namespace qialifiers to define previously declared functions to variables as well.

>From b75122e8a543031f09d693270af5a6032e69ffd0 Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Wed, 15 Oct 2025 09:36:26 -0700
Subject: [PATCH] [LLVM][CodingStandard] Extend namespace qualifier rule to
 variables

Extend CS rule to use namespace qialifiers to define previously
declared functions to variables as well.
---
 llvm/docs/CodingStandards.rst | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/llvm/docs/CodingStandards.rst b/llvm/docs/CodingStandards.rst
index 65dd794103ac3..128892edf0772 100644
--- a/llvm/docs/CodingStandards.rst
+++ b/llvm/docs/CodingStandards.rst
@@ -860,23 +860,28 @@ your private interface remains private and undisturbed by outsiders.
     It's okay to put extra implementation methods in a public class itself. Just
     make them private (or protected) and all is well.
 
-Use Namespace Qualifiers to Implement Previously Declared Functions
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Use Namespace Qualifiers to Define Previously Declared Variables and Functions
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-When providing an out-of-line implementation of a function in a source file, do
-not open namespace blocks in the source file. Instead, use namespace qualifiers
-to help ensure that your definition matches an existing declaration. Do this:
+When providing an out-of-line definition of a variable or a function in a source
+file, do not open namespace blocks in the source file. Instead, use namespace
+qualifiers to help ensure that your definition matches an existing declaration.
+Do this:
 
 .. code-block:: c++
 
   // Foo.h
   namespace llvm {
+  extern int FooVal;
   int foo(const char *s);
   }
 
   // Foo.cpp
   #include "Foo.h"
   using namespace llvm;
+
+  int llvm::FooVal;
+
   int llvm::foo(const char *s) {
     // ...
   }



More information about the llvm-commits mailing list