Left.Previous &&
!Left.Previous->isOneOf(tok::l_paren, tok::coloncolon,
tok::l_square));
+ // Ensure right pointer alignement with ellipsis e.g. int *...P
+ if (Left.is(tok::ellipsis) && Left.Previous &&
+ Left.Previous->isOneOf(tok::star, tok::amp, tok::ampamp))
+ return Style.PointerAlignment != FormatStyle::PAS_Right;
+
if (Right.is(tok::star) && Left.is(tok::l_paren))
return false;
if (Left.is(tok::star) && Right.isOneOf(tok::star, tok::amp, tok::ampamp))
verifyFormat("template <class... Ts> S(Ts...) -> S<Ts...>;");
verifyFormat(
"template <class... T>\n"
- "array(T &&... t) -> array<std::common_type_t<T...>, sizeof...(T)>;");
+ "array(T &&...t) -> array<std::common_type_t<T...>, sizeof...(T)>;");
verifyFormat("template <class T> A() -> A<decltype(p->foo<3>())>;");
verifyFormat("template <class T> A() -> A<decltype(foo<traits<1>>)>;");
verifyFormat("template <class T> A() -> A<sizeof(p->foo<1>)>;");
}
TEST_F(FormatTest, UnderstandsEllipsis) {
+ FormatStyle Style = getLLVMStyle();
verifyFormat("int printf(const char *fmt, ...);");
verifyFormat("template <class... Ts> void Foo(Ts... ts) { Foo(ts...); }");
- verifyFormat("template <class... Ts> void Foo(Ts *... ts) {}");
+ verifyFormat("template <class... Ts> void Foo(Ts *...ts) {}");
+
+ verifyFormat("template <int *...PP> a;", Style);
+
+ Style.PointerAlignment = FormatStyle::PAS_Left;
+ verifyFormat("template <class... Ts> void Foo(Ts*... ts) {}", Style);
+
+ verifyFormat("template <int*... PP> a;", Style);
- FormatStyle PointersLeft = getLLVMStyle();
- PointersLeft.PointerAlignment = FormatStyle::PAS_Left;
- verifyFormat("template <class... Ts> void Foo(Ts*... ts) {}", PointersLeft);
+ Style.PointerAlignment = FormatStyle::PAS_Middle;
+ verifyFormat("template <int *... PP> a;", Style);
}
TEST_F(FormatTest, AdaptivelyFormatsPointersAndReferences) {