[llvm-bugs] [Bug 30220] New: clang-format with webkit style breaks code for raw strings with quote characters

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 31 06:58:55 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=30220

            Bug ID: 30220
           Summary: clang-format with webkit style breaks code for raw
                    strings with quote characters
           Product: clang
           Version: 3.8
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: sandipan.mohanty at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org
    Classification: Unclassified

Consider the minimal example code here:

auto foo()
{
    std::string s{R"(ha"ha)" };
    return s;
}

auto bar()
{
   std::string s{R"(AAAAA)"};
   return foo();
}

Formatting this with "clang-format -style=Webkit" leads to :

1. Incorrect syntax for the raw string literals, as the formatter inserts a
space between the R and the opening quote of the raw string literal in g(). The
other built in formats in clang-format do not do this.

2. Bad indentations after the first raw string in foo(). It seems the formatter
does not ignore the contents of the raw string literals, and treats the quote
inside the raw string as the closing quote of the raw string. Here is the
output I get with version 3.8.1:

sandipan at jrl:~/tmp> clang-format -style=Webkit cf_rs.cc
auto foo()
{
    std::string s
    {R"(ha"ha)" };
    return s;
    }

    auto bar()
    {
        std::string s{ R "(AAAAA)" };
        return foo();
    }

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160831/c7553efa/attachment.html>


More information about the llvm-bugs mailing list