In LLVM style, a single space should be enough. In Google style, two
spaces are required.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171725
91177308-0d34-0410-b5e6-
96231b3b80d8
/// When false, use the same indentation level as for the switch statement.
/// Switch statement body is always indented one level more than case labels.
bool IndentCaseLabels;
+
+ /// \brief The number of spaces to before trailing line comments.
+ unsigned SpacesBeforeTrailingComments;
};
/// \brief Returns a format style complying with the LLVM coding standards:
LLVMStyle.AccessModifierOffset = -2;
LLVMStyle.SplitTemplateClosingGreater = true;
LLVMStyle.IndentCaseLabels = false;
+ LLVMStyle.SpacesBeforeTrailingComments = 1;
return LLVMStyle;
}
GoogleStyle.AccessModifierOffset = -1;
GoogleStyle.SplitTemplateClosingGreater = false;
GoogleStyle.IndentCaseLabels = true;
+ GoogleStyle.SpacesBeforeTrailingComments = 2;
return GoogleStyle;
}
unsigned Spaces = Annotations[Index].SpaceRequiredBefore ? 1 : 0;
if (Annotations[Index].Type == TT_LineComment)
- Spaces = 2;
+ Spaces = Style.SpacesBeforeTrailingComments;
if (!DryRun)
replaceWhitespace(Current, 0, Spaces);
" // Doesn't do anything\n"
"}");
- verifyFormat("int i // This is a fancy variable\n"
+ verifyFormat("int i // This is a fancy variable\n"
" = 5;");
verifyFormat("enum E {\n"
" // comment\n"
- " VAL_A, // comment\n"
+ " VAL_A, // comment\n"
" VAL_B\n"
"};");
verifyFormat(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =\n"
- " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; // Trailing comment");
+ " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; // Trailing comment");
- EXPECT_EQ("int i; // single line trailing comment",
+ EXPECT_EQ("int i; // single line trailing comment",
format("int i;\\\n// single line trailing comment"));
+
+ verifyGoogleFormat("int a; // Trailing comment.");
}
TEST_F(FormatTest, UnderstandsMultiLineComments) {