[llvm] [CodingStandard] Add a rule about non-member definitions in CPP files (PR #126775)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 12 11:23:51 PST 2025
https://github.com/jurahul updated https://github.com/llvm/llvm-project/pull/126775
>From 57e03cd8e6aebe066e8391ffd862e169950e4df1 Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Tue, 11 Feb 2025 10:14:48 -0800
Subject: [PATCH] [CodingStandard] Add a rule about non-member definitions in
CPP files
- Add a rule suggesting that non-member definitions in CPP files should
be made static unless they are referenced outside that file.
---
llvm/docs/CodingStandards.rst | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/llvm/docs/CodingStandards.rst b/llvm/docs/CodingStandards.rst
index d6d6ecf759cf3..6328f09c0981d 100644
--- a/llvm/docs/CodingStandards.rst
+++ b/llvm/docs/CodingStandards.rst
@@ -1640,6 +1640,10 @@ you have no immediate way to tell if this function is local to the file. In
contrast, when the function is marked static, you don't need to cross-reference
faraway places in the file to tell that the function is local.
+Related to this issue, when non-member functions or variables are defined in a
+`.cpp`` file and need not be referenced outside that file, make them `static`.
+
+
Don't Use Braces on Simple Single-Statement Bodies of if/else/loop Statements
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
More information about the llvm-commits
mailing list