]> granicus.if.org Git - clang/commitdiff
Make clang-format understand more line comments.
authorDaniel Jasper <djasper@google.com>
Fri, 22 Mar 2013 10:01:29 +0000 (10:01 +0000)
committerDaniel Jasper <djasper@google.com>
Fri, 22 Mar 2013 10:01:29 +0000 (10:01 +0000)
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:
//****************

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177720 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/Format.cpp
unittests/Format/FormatTest.cpp

index 040fb39fb9db924c330ab10a91270d39d9e7d9ef..40e980f67da01fff9736852406e8bfec0717beb6 100644 (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;
index 29988d35c48bea237b41a5b92998b7c77452969c..dc77c77e450332968d317f98bda4980eb3f85e68 100644 (file)
@@ -490,6 +490,7 @@ TEST_F(FormatTest, FormatsLabels) {
 //===----------------------------------------------------------------------===//
 
 TEST_F(FormatTest, UnderstandsSingleLineComments) {
+  verifyFormat("//* */");
   verifyFormat("// line 1\n"
                "// line 2\n"
                "void f() {}\n");