mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 13:50:10 +01:00
By default clang-format interprets function-like macro invocations as function calls. E.g. the argument of `CARBON_KIND(llvm::ListSeparator* sep)` is interpreted as an expression, meaning the `*` is an infix binary operator, so it inserts a space before the `*`. This change teaches clang-format that `CARBON_KIND(x)` and `CARBON_ASSIGN_OR_RETURN(x)` rewrite to `x`, which is close enough to the truth to enable it to format them correctly. See the [clang-format docs](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#macros) for details.
35 lines
1.1 KiB
YAML
35 lines
1.1 KiB
YAML
# Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
# Exceptions. See /LICENSE for license information.
|
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
---
|
|
BasedOnStyle: Google
|
|
AllowShortBlocksOnASingleLine: 'false'
|
|
AllowShortIfStatementsOnASingleLine: Never
|
|
AllowShortLoopsOnASingleLine: 'false'
|
|
DerivePointerAlignment: 'false'
|
|
ExperimentalAutoDetectBinPacking: 'false'
|
|
FixNamespaceComments: 'true'
|
|
InsertBraces: 'true'
|
|
InsertTrailingCommas: None
|
|
PointerAlignment: Left
|
|
# We abuse control macros for formatting other kinds of macros.
|
|
SpaceBeforeParens: ControlStatementsExceptControlMacros
|
|
IfMacros:
|
|
[
|
|
'CARBON_DEFINE_RAW_ENUM_CLASS',
|
|
'CARBON_DEFINE_ENUM_CLASS_NAMES',
|
|
'CARBON_DEFINE_RAW_ENUM_MASK',
|
|
'CARBON_DEFINE_ENUM_MASK_NAMES',
|
|
'CARBON_KIND_SWITCH',
|
|
]
|
|
StatementMacros: ['ABSTRACT']
|
|
QualifierAlignment: Custom
|
|
QualifierOrder:
|
|
[inline, static, friend, constexpr, const, volatile, restrict, type]
|
|
Macros:
|
|
# These macros can contain variable declarations, so clang-format needs to
|
|
# "see through" them in order to format them correctly.
|
|
- CARBON_ASSIGN_OR_RETURN(x)=x
|
|
- CARBON_KIND(x)=x
|