llvm.org GIT mirror llvm / 5d696a9
Add some wording to the coding standards to say how to indent namespaces (and to mention namespace ending comments). This is based on a quick discussion on the developer mailing list where there was essentially no objections to a simple and consistent rule. This should avoid future debates about whether or not a namespace is "big enough" to indent. It also matches clang-format's current behavior with LLVM source code which hasn't really seen any opposition in code reviews that I spot checked. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199620 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 6 years ago
1 changed file(s) with 45 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
105105 to the paper where it is published should be included, as well as any notes or
106106 *gotchas* in the code to watch out for.
107107
108 Namespace Markers
109 """""""""""""""""
110
111 We don't indent namespaces (see below) and so feel free to add markers to the
112 end of a namespace where it helps readabilitily:
113
114 .. code-block:: c++
115
116 namespace foo {
117
118 // Lots of code here...
119
120 } // End foo namespace
121
122 This isn't required, and in many cases (such as the namespace used for an
123 entire file like the 'llvm' namespace in header files) it isn't really useful.
124 Use your judgment and add it where it helps.
125
108126 Class overviews
109127 """""""""""""""
110128
335353
336354 Okay, in your first year of programming you were told that indentation is
337355 important. If you didn't believe and internalize this then, now is the time.
338 Just do it.
356 Just do it. A few cases are called out here that have common alternatives. The
357 intent in saying which way to format things is to increase consistency across
358 the LLVM codebase.
359
360 Namespaces
361 """"""""""
362
363 A simple rule: don't indent them. Here are examples of well formatted and
364 indented namespaces:
365
366 .. code-block:: c++
367 namespace llvm {
368
369 namespace foo {
370 class A;
371 class B;
372 }
373
374 namespace {
375 /// \brief Some local class definition.
376 /// ...
377 class Widget {
378 // ... lots of code here ...
379 };
380 } // End anonymous namespace
381
382 } // End llvm namespace
339383
340384 Compiler Issues
341385 ---------------