[llvm-bugs] [Bug 43770] New: clang-format: PointerAlignment removes space within multiple lambda declarations

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Oct 23 00:25:02 PDT 2019


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

            Bug ID: 43770
           Summary: clang-format: PointerAlignment removes space within
                    multiple lambda declarations
           Product: new-bugs
           Version: 9.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: mateusz.szychowski at blackstarsoftware.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

app.cpp:
#include <functional>

int main() {
  std::function<int(int const&)> res1 = [](int const& a) { return a * 2; },
                                 res2 = [](int const& a) { return a * 2; };
  return res1(2) + res2(4);
}

$ clang-format app.cpp -style='{PointerAlignment: Left}'
#include <functional>

int main() {
  std::function<int(int const&)> res1 = [](int const&a) { return a * 2; },
                                 res2 = [](int const&a) { return a * 2; };
  return res1(2) + res2(4);
}

$ clang-format app.cpp -style='{PointerAlignment: Middle}'
#include <functional>

int main() {
  std::function<int(int const &)> res1 = [](int const &a) { return a * 2; },
                                  res2 = [](int const &a) { return a * 2; };
  return res1(2) + res2(4);
}

$ clang-format app.cpp -style='{PointerAlignment: Right}'
#include <functional>

int main() {
  std::function<int(int const &)> res1 = [](int const &a) { return a * 2; },
                                  res2 = [](int const &a) { return a * 2; };
  return res1(2) + res2(4);


As we can see, space on right side is removed, while it shouldn't always be
removed.
It behaves fine if we split res1 and rest2 type declarations.
app2.cpp:
#include <functional>

int main() {
  std::function<int(int const&)> res1 = [](int const& a) { return a * 2; };
  std::function<int(int const&)> res2 = [](int const& a) { return a * 2; };
  return res1(2) + res2(4);
}

$ clang-format app2.cpp -style='{PointerAlignment: Left}'
#include <functional>

int main() {
  std::function<int(int const&)> res1 = [](int const& a) { return a * 2; };
  std::function<int(int const&)> res2 = [](int const& a) { return a * 2; };
  return res1(2) + res2(4);
}

-- 
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/20191023/bddeea5b/attachment.html>


More information about the llvm-bugs mailing list