Lines Matching +full:docs +full:- +full:flang +full:- +full:html
1 <!--===- docs/C++style.md
5 SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 -->
9 # Flang C++ Style Guide
12 ---
14 ---
17 This document captures the style guide rules that are followed in the Flang codebase.
20 * Use *clang-format*
24 by means of clang-format.
26 * Otherwise, where [LLVM's C++ style guide](https://llvm.org/docs/CodingStandards.html#style-issues)
29 follow it. [Google's](https://google.github.io/styleguide/cppguide.html)
71 1. C++ names that correspond to well-known interfaces from the STL, LLVM,
74 they mean the same thing -- e.g., `clear()` and `size()` member functions
75 in a class that implements an STL-ish container.
77 1. Non-public data members should be named with leading miniscule (lower-case)
82 1. Accessor member functions are named with the non-public data member's name,
101 Always run `clang-format` on your changes before committing code. LLVM
102 has a `git-clang-format` script to facilitate running clang-format only
105 Here's what you can expect to see `clang-format` do:
116 align vertically -- they are maintenance problems.
125 `{` after the formal arguments or new-style result type, not on the next
140 In multi-element initializer lists (especially `common::visitors{...}`),
141 including a comma after the last element often causes `clang-format` to do
149 1. Never use run-time type information or `dynamic_cast<>`.
163 1. Use namespaces to avoid conflicts with client code. Use one top-level
176 clear. Consider reworking any code that uses `malloc()` or a (non-placement)
184 and use non-`const` references for mutable objects, including "output" arguments
207 to a `const char *` when the result is expected to be NUL-terminated.
216 1. Don't use `this->` in (non-static) member functions, unless forced to
228 1. Make single-argument constructors (other than copy and move constructors)
232 There are many -- perhaps too many -- means of indirect addressing
236 * Bare pointers (`Foo *p`): these are obviously nullable, non-owning,
240 non-owning reference, as in a function result.
243 * References (`Foo &r`, `const Foo &r`): non-nullable, not owning,
250 * Rvalue references (`Foo &&r`): These are non-nullable references
253 * `std::reference_wrapper<>`: non-nullable, not owning, shallowly
263 easier to use with forward-referenced data types.
266 * `Indirection<>`: A non-nullable pointer with ownership and
269 (due to non-nullability and copyability).
271 Usable with forward-referenced data types with some use of `extern template`
283 | ----------- | -------- | ------------ | ------ | ------------ | -------- | ---…
315 that all desired tool-chains can compile f18.
320 default Ubuntu 18.04 g++ compiler (7.4.0-1ubuntu1~18.0.4.1):