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

            Bug ID: 40910
           Summary: clang-format broken after lambda with return type
                    template with boolean literal
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangb...@nondot.org
          Reporter: nikol...@nikolaus-demmel.de
                CC: djas...@google.com, kli...@google.com,
                    llvm-bugs@lists.llvm.org

Clang format breaks on lambdas with return types that have literal booleans in
template arguments, e.g. 

    []() -> foo<true> { ; }();

The same works fine e.g. with integer literals. I tried version 7, 8, and
current version 9 from the Ubuntu Xenial apt repo and the behaviour is the same
everywhere. I narrowed it down to the following small test case:


template <bool>
using foo = void;
// works:
[]() -> foo<1> { ; }();
// broken:
[]() -> foo<true> { ; }();

namespace bar {
// broken:
auto foo{[]() -> foo<false> { ; }};
}  // namespace bar


I would expect clang-format (without additional options) to not change anything
here (which is the case if I replace 'true' / 'false' with e.g. '1', but the
actual result is as follows, which is particularly problematic in the presence
of namespaces as you can see:


template <bool>
using foo = void;
// works:
[]() -> foo<1> { ; }();
// broken:
[]() -> foo<true> { ; }
();

namespace bar {
// broken:
auto foo{[]() -> foo<false>{;
}  // namespace bar
}
;
}  // namespace bar

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to