- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2020-07-21T13:19:04+00:00","","")
#author("2020-07-22T04:06:35+00:00","","")
#topicpath
//////////////////////////////////////////////////////////////////////////////
* 目次 [#zf6aaa09]
#contents();
//////////////////////////////////////////////////////////////////////////////
* 書式オプション(抜粋) [#cbbe2cff]
- clang-format で使用される書式設定ファイル ''.clang-format'' に記述するオプションについて記載する。
//============================================================================
** Language: [#r652b10a]
** Language: [#Language]
|~val |~description |
|None |使用しない |
|Cpp |C, C++, Objective-C, Objective-C++ を使用する |
|Java |Java を使用する |
|JavaScript |JavaScript を使用する |
|Proto |[[Protocol Buffers>https://developers.google.com/protocol-buffers/]] |
//============================================================================
** AccessModifierOffset: [#y2363b3b]
//============================================================================
** AlignAfterOpenBracket: [#va67ab73]
//============================================================================
** AlignConsecutiveAssignments: [#j3fac10f]
** AlignConsecutiveAssignments: [#AlignConsecutiveAssignments]
- 連続する行の代入式を ''='' で整列するか否か
-- true : 整列する
int32_t var_1 = 12;
std::string var_2 = "foo";
const char* const var_3 = "bar";
-- false : 整列しない
int32_t var_1 = 12;
std::string var_2 = "foo";
const char* const var_3 = "bar";
//============================================================================
** AlignConsecutiveDeclarations: [#qff02db2]
** AlignConsecutiveDeclarations: [#AlignConsecutiveDeclarations]
- 連続する行の宣言の変数名を整列させるか否か
-- true : 整列する
int32_t var_11 = 12;
std::string var_2 = "foo";
const char* const var_3 = "bar";
-- false : 整列しない
int32_t var_11 = 12;
std::string var_2 = "foo";
const char* const var_3 = "bar";
//============================================================================
** AlignEscapedNewlinesLeft: [#h9b854e9]
** AlignEscapedNewlinesLeft: [#AlignEscapedNewlinesLeft]
- エスケープされた改行の位置を調整する
-- true : 可能な限り左に寄せる
#define LOG_PREFIX \
"[DEBUG]" \
"[MODULE_A]" \
"[MOD_SUB_2]"
-- false : column limit に配置する
// ColumnLimit: 80 の場合
#define LOG_PREFIX \
"[DEBUG]" \
"[MODULE_A]" \
"[MOD_SUB_2]"
//============================================================================
** AlignOperands: [#n00eac18]
//============================================================================
** AlignTrailingComments: [#vfbf452b]
//============================================================================
** AllowAllParametersOfDeclarationOnNextLine: [#sae7368d]
//============================================================================
** AllowShortBlocksOnASingleLine: [#p85e716f]
** AllowShortBlocksOnASingleLine: [#AllowShortBlocksOnASingleLine]
- 短いブレース文を単一の行に押し込むか否か
- true : 単一行に押し込む
if (arg > 10) { var_11 += arg; }
- false : 単一行に押し込まない
if (arg > 10) {
var_11 += arg;
}
- 但し、以下のような構造体初期化文には効力がない模様
st_aaa aaa = {
0,
};
//============================================================================
** AllowShortCaseLabelsOnASingleLine: [#z131c8bc]
//============================================================================
** AllowShortFunctionsOnASingleLine: [#dce76bfa]
//============================================================================
** AllowShortIfStatementsOnASingleLine: [#w26c3548]
//============================================================================
** AllowShortLoopsOnASingleLine: [#kff2e776]
//============================================================================
** AlwaysBreakAfterDefinitionReturnType: [#e2cf0f79]
//============================================================================
** AlwaysBreakAfterReturnType: [#u32cd482]
//============================================================================
** AlwaysBreakBeforeMultilineStrings: [#v40e1938]
//============================================================================
** AlwaysBreakTemplateDeclarations: [#y25557f4]
//============================================================================
** BinPackArguments: [#ia3d009b]
//============================================================================
** BinPackParameters: [#v9fb1dea]
//============================================================================
** BraceWrapping: [#n9ac2f6f]
//----------------------------------------------------------------------------
*** AfterClass: [#r3ca3958]
//----------------------------------------------------------------------------
*** AfterControlStatement: [#kae57280]
//----------------------------------------------------------------------------
*** AfterEnum: [#k51b89c7]
//----------------------------------------------------------------------------
*** AfterFunction: [#a31f9cf9]
//----------------------------------------------------------------------------
*** AfterNamespace: [#c3c1226f]
//----------------------------------------------------------------------------
*** AfterObjCDeclaration: [#c89d4168]
//----------------------------------------------------------------------------
*** AfterStruct: [#g2564b61]
//----------------------------------------------------------------------------
*** AfterUnion: [#haacaa46]
//----------------------------------------------------------------------------
*** BeforeCatch: [#ae2a006c]
//----------------------------------------------------------------------------
*** BeforeElse: [#m3b859c3]
//----------------------------------------------------------------------------
*** IndentBraces: [#w79f7cc5]
//============================================================================
** BreakBeforeBinaryOperators: [#eba844fb]
//============================================================================
** BreakBeforeBraces: [#r15abe94]
** BreakBeforeBraces: [#BreakBeforeBraces]
- 波括弧 ''{ }'' の改行の設定
- Attach
-- 波括弧は常に周囲のコンテキストにくっつける。
enum HOGE_EN {
EN_AAA,
EN_ABC,
EN_ZZZ,
};
struct st_aaa {
int aaa[2];
uint64_t ax;
};
void func(int arg) {
// ...
if (arg == 0) {
// ...
} else {
// ...
}
return;
}
- Linux
-- Attach に似るが、関数や名前空間、クラス定義の前は改行する。
enum HOGE_EN {
EN_AAA,
EN_ABC,
EN_ZZZ,
};
struct st_aaa {
int aaa[2];
uint64_t ax;
};
void func(int arg)
{
// ...
if (arg == 0) {
// ...
} else {
// ...
}
return;
}
- Mozilla
-- Attach と似るが、 enum、関数定義などの前には改行する。
enum HOGE_EN
{
EN_AAA,
EN_ABC,
EN_ZZZ,
};
struct st_aaa
{
int aaa[2];
uint64_t ax;
};
void func(int arg)
{
// ...
if (arg == 0) {
// ...
} else {
// ...
}
return;
}
- Stroustrup
-- Attach と似るが、catch, else などの前は改行する。
enum HOGE_EN {
EN_AAA,
EN_ABC,
EN_ZZZ,
};
struct st_aaa {
int aaa[2];
uint64_t ax;
};
void func(int arg)
{
// ...
if (arg == 0) {
// ...
}
else {
// ...
}
return;
}
- Allman
-- 波括弧の前は全て改行する。
enum HOGE_EN
{
EN_AAA,
EN_ABC,
EN_ZZZ,
};
struct st_aaa
{
int aaa[2];
uint64_t ax;
};
void func(int arg)
{
// ...
if (arg == 0)
{
// ...
}
else
{
// ...
}
return;
}
- GNU
-- 波括弧の前は全て改行するし、新たにインデントを加える。但し、クラス定義や関数定義などの場合は除く。
enum HOGE_EN
{
EN_AAA,
EN_ABC,
EN_ZZZ,
};
struct st_aaa
{
int aaa[2];
uint64_t ax;
};
void func(int arg)
{
// ...
if (arg == 0)
{
// ...
}
else
{
// ...
}
return;
}
//============================================================================
** BreakBeforeTernaryOperators: [#sffea887]
//============================================================================
** BreakConstructorInitializersBeforeComma: [#r8e30fba]
- コンストラクタの変数初期化のコンマの前で改行し、コンマとコロンを整列させるかどうか
- true
- false
//============================================================================
** ColumnLimit: [#l0533b37]
** ColumnLimit: [#ColumnLimit]
- 行の長さの上限値。
- 0 に設定した場合は、上限なしとなる。
//============================================================================
** CommentPragmas: [#u99be49b]
//============================================================================
** ConstructorInitializerAllOnOneLineOrOnePerLine: [#r75290fb]
//============================================================================
** ConstructorInitializerIndentWidth: [#ze984459]
//============================================================================
** ContinuationIndentWidth: [#aaefdf2a]
//============================================================================
** Cpp11BracedListStyle: [#iedfc19b]
//============================================================================
** DerivePointerAlignment: [#f9b31830]
//============================================================================
** DisableFormat: [#v21da5cf]
//============================================================================
** ExperimentalAutoDetectBinPacking: [#q9649d58]
//============================================================================
** ForEachMacros: [#e39475f0]
//============================================================================
** IncludeCategories: [#ucb42990]
//----------------------------------------------------------------------------
*** - [#be585d44]
//----------------------------------------------------------------------------
*** Priority: [#lc646fac]
//----------------------------------------------------------------------------
*** - [#w1262625]
//----------------------------------------------------------------------------
*** Priority: [#hde528d1]
//----------------------------------------------------------------------------
*** - [#l3196565]
//----------------------------------------------------------------------------
*** Priority: [#g1cb84bf]
//============================================================================
** IndentCaseLabels: [#x3a42b57]
//============================================================================
** IndentWidth: [#d4935225]
//============================================================================
** IndentWrappedFunctionNames: [#vb5d40c0]
//============================================================================
** KeepEmptyLinesAtTheStartOfBlocks: [#n643d905]
//============================================================================
** MacroBlockBegin: [#h7d1a026]
//============================================================================
** MacroBlockEnd: [#k77ca862]
//============================================================================
** MaxEmptyLinesToKeep: [#mf4db716]
//============================================================================
** NamespaceIndentation: [#o82a7483]
//============================================================================
** ObjCBlockIndentWidth: [#d2ad2676]
//============================================================================
** ObjCSpaceAfterProperty: [#p8f59fc2]
//============================================================================
** ObjCSpaceBeforeProtocolList: [#rc1aedf9]
//============================================================================
** PenaltyBreakBeforeFirstCallParameter: [#b8c42877]
//============================================================================
** PenaltyBreakComment: [#s63e6446]
//============================================================================
** PenaltyBreakFirstLessLess: [#v647e833]
//============================================================================
** PenaltyBreakString: [#qbd919c2]
//============================================================================
** PenaltyExcessCharacter: [#t230560c]
//============================================================================
** PenaltyReturnTypeOnItsOwnLine: [#cc33121d]
//============================================================================
** PointerAlignment: [#v30bb7ce]
//============================================================================
** ReflowComments: [#ucf9ed66]
//============================================================================
** SortIncludes: [#b6797f9d]
//============================================================================
** SpaceAfterCStyleCast: [#uebb1034]
//============================================================================
** SpaceBeforeAssignmentOperators: [#x29447e9]
//============================================================================
** SpaceBeforeParens: [#iacb23cc]
//============================================================================
** SpaceInEmptyParentheses: [#t24393b1]
//============================================================================
** SpacesBeforeTrailingComments: [#da132129]
//============================================================================
** SpacesInAngles: [#i7770e5a]
//============================================================================
** SpacesInContainerLiterals: [#k77db928]
//============================================================================
** SpacesInCStyleCastParentheses: [#w07105c2]
//============================================================================
** SpacesInParentheses: [#d281fbe1]
//============================================================================
** SpacesInSquareBrackets: [#m8113bc9]
//============================================================================
** Standard: [#z92f7f34]
//============================================================================
** TabWidth: [#pbdbd121]
//============================================================================
** UseTab: [#f5d7899e]
//////////////////////////////////////////////////////////////////////////////
* 参考リンク [#ac84b4cf]
* 参考リンク [#links]
- [[ClangFormat — Algo13 2016.12.17 ドキュメント>http://algo13.net/clang/clang-format-style-oputions.html]]
- [[clang-format を イイ感じに設定する - def yasuharu519(self):>https://yasuharu519.hatenablog.com/entry/2015/12/13/210825]]