Make clang-format understand more line comments.

Apparently one needs to set LangOptions.LineComment.

Before "//* */" got reformatted to "/ /* */" as the lexer was returning
the token sequence (slash, comment). This could also lead to weird other
stuff, e.g. for people that like to using comments like:
//****************

llvm-svn: 177720
This commit is contained in:
Daniel Jasper 2013-03-22 10:01:29 +00:00
parent 7b261db8e6
commit 5521365248
2 changed files with 2 additions and 0 deletions

View File

@ -1643,6 +1643,7 @@ LangOptions getFormattingLangOpts() {
LangOptions LangOpts;
LangOpts.CPlusPlus = 1;
LangOpts.CPlusPlus11 = 1;
LangOpts.LineComment = 1;
LangOpts.Bool = 1;
LangOpts.ObjC1 = 1;
LangOpts.ObjC2 = 1;

View File

@ -490,6 +490,7 @@ TEST_F(FormatTest, FormatsLabels) {
//===----------------------------------------------------------------------===//
TEST_F(FormatTest, UnderstandsSingleLineComments) {
verifyFormat("//* */");
verifyFormat("// line 1\n"
"// line 2\n"
"void f() {}\n");