dawn-cmake/docs/tint/style_guide.md
dan sinclair a9d2f636fb Update style_guide c++ version.
The CMake file states c++17, Chromium is at c++17. This CL updates the
style guide documentation to specify c++17 as required for Tint.

Change-Id: I4dd8e9aa69de6f32a59ced2c5b861c83adf2edfe
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/85320
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-03-31 14:30:46 +00:00

48 lines
1.8 KiB
Markdown

# Tint style guide
* Generally, follow the [Chromium style guide for C++](https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/c++.md)
which itself is built on the [Google C++ style guide](https://google.github.io/styleguide/cppguide.html).
* Overall try to use the same style and convention as code around your change.
* Code must be formatted. Use `clang-format` with the provided [.clang-format](../.clang-format)
file. The `tools/format` script runs the formatter.
* Code should not have linting errors.
The `tools/lint` script runs the linter. So does `git cl upload`.
* Do not use C++ exceptions
* Do not use C++ RTTI.
Instead, use `tint::Castable::As<T>()` from
[src/castable.h](../src/castable.h)
* Generally, avoid `assert`. Instead, issue a [diagnostic](../src/diagnostic.h)
and fail gracefully, possibly by returning an error sentinel value.
Code that should not be reachable should call `TINT_UNREACHABLE` macro
and other internal error conditions should call the `TINT_ICE` macro.
See [src/debug.h](../src/debug.h)
* Use `type` as part of a name only when the name refers to a type
in WGSL or another shader language processed by Tint. If the concept you are
trying to name is about distinguishing between alternatives, use `kind` instead.
## Compiler support
Tint requires C++17.
Tint uses the Chromium build system and will stay synchronized with that system.
Compiler configurations beyond that baseline is on a best-effort basis.
We strive to support recent GCC and MSVC compilers.
## Test code
We might relax the above rules rules for test code, since test code
shouldn't ship to users.
However, test code should still be readable and maintainable.
For test code, the tradeoff between readability and maintainability
and other factors is weighted even more strongly toward readability
and maintainability.