[cfe-dev] [clang-format] Constructor initializers
Marco F via cfe-dev
cfe-dev at lists.llvm.org
Sat Jan 2 14:06:49 PST 2016
We have a lot of code in this form:
NetworkStyle::NetworkStyle(const QString &appName, const QString &appIcon, const char *titleAddText, const QString &splashImage):
< 4 spaces >appName(appName),
< 4 spaces >appIcon(appIcon),
< 4 spaces >titleAddText(qApp->translate(SplashScreen, titleAddText)),
< 4 spaces >splashImage(splashImage)
and using our .clang-format file [1], we'd get a lot of white space (on line 2-5) due to /ColumnLimit: 0/ and /ConstructorInitializerAllOnOneLineOrOnePerLine: false/
NetworkStyle::NetworkStyle(const QString& appName, const QString& appIcon, const char* titleAddText, const QString& splashImage) : appName(appName),
< 131 spaces > appIcon(appIcon),
< 131 spaces > titleAddText(qApp->translate("SplashScreen", titleAddText)),
< 131 spaces > splashImage(splashImage)
One can get rid of the excessive white space by setting /BreakConstructorInitializersBeforeComma: true/. However, this would change our default coding style and
personally I think it's ugly.
Would it make sense to introduce new flags like /BreakConstructorInitializers*After*Comma/ or /ConstructorInitializer*Always*OnePerLine/, as this appears impossible to achieve with current
style options?
Marco
[1] <https://github.com/bitcoin/bitcoin/blob/be9a9a3d2253ceccf123572b97a890c489a5a9be/src/.clang-format>
More information about the cfe-dev
mailing list