PreviousNotConst->MatchingParen->Previous->is(tok::kw_decltype))
return true;
- return (!IsPPKeyword && PreviousNotConst->is(tok::identifier)) ||
+ return (!IsPPKeyword &&
+ PreviousNotConst->isOneOf(tok::identifier, tok::kw_auto)) ||
PreviousNotConst->is(TT_PointerOrReference) ||
PreviousNotConst->isSimpleTypeSpecifier();
}
if (Left.is(tok::l_square) && Right.is(tok::amp))
return false;
if (Right.is(TT_PointerOrReference))
- return !(Left.is(tok::r_paren) && Left.MatchingParen &&
- (Left.MatchingParen->is(TT_OverloadedOperatorLParen) ||
- (Left.MatchingParen->Previous &&
- Left.MatchingParen->Previous->is(
- TT_FunctionDeclarationName)))) &&
+ return (Left.is(tok::r_paren) && Left.MatchingParen &&
+ (Left.MatchingParen->is(TT_OverloadedOperatorLParen) ||
+ (Left.MatchingParen->Previous &&
+ Left.MatchingParen->Previous->is(TT_FunctionDeclarationName)))) ||
(Left.Tok.isLiteral() ||
(!Left.isOneOf(TT_PointerOrReference, tok::l_paren) &&
(Style.PointerAlignment != FormatStyle::PAS_Left ||
}
TEST_F(FormatTest, UnderstandsFunctionRefQualification) {
- verifyFormat("Deleted &operator=(const Deleted &)& = default;");
- verifyFormat("Deleted &operator=(const Deleted &)&& = delete;");
- verifyFormat("SomeType MemberFunction(const Deleted &)& = delete;");
- verifyFormat("SomeType MemberFunction(const Deleted &)&& = delete;");
- verifyFormat("Deleted &operator=(const Deleted &)&;");
- verifyFormat("Deleted &operator=(const Deleted &)&&;");
- verifyFormat("SomeType MemberFunction(const Deleted &)&;");
- verifyFormat("SomeType MemberFunction(const Deleted &)&&;");
- verifyFormat("SomeType MemberFunction(const Deleted &)&& {}");
- verifyFormat("SomeType MemberFunction(const Deleted &)&& final {}");
- verifyFormat("SomeType MemberFunction(const Deleted &)&& override {}");
-
- verifyGoogleFormat("Deleted& operator=(const Deleted&)& = default;");
- verifyGoogleFormat("SomeType MemberFunction(const Deleted&)& = delete;");
- verifyGoogleFormat("Deleted& operator=(const Deleted&)&;");
- verifyGoogleFormat("SomeType MemberFunction(const Deleted&)&;");
+ verifyFormat("Deleted &operator=(const Deleted &) & = default;");
+ verifyFormat("Deleted &operator=(const Deleted &) && = delete;");
+ verifyFormat("SomeType MemberFunction(const Deleted &) & = delete;");
+ verifyFormat("SomeType MemberFunction(const Deleted &) && = delete;");
+ verifyFormat("Deleted &operator=(const Deleted &) &;");
+ verifyFormat("Deleted &operator=(const Deleted &) &&;");
+ verifyFormat("SomeType MemberFunction(const Deleted &) &;");
+ verifyFormat("SomeType MemberFunction(const Deleted &) &&;");
+ verifyFormat("SomeType MemberFunction(const Deleted &) && {}");
+ verifyFormat("SomeType MemberFunction(const Deleted &) && final {}");
+ verifyFormat("SomeType MemberFunction(const Deleted &) && override {}");
+
+ FormatStyle AlignLeft = getLLVMStyle();
+ AlignLeft.PointerAlignment = FormatStyle::PAS_Left;
+ verifyFormat("Deleted& operator=(const Deleted&) & = default;", AlignLeft);
+ verifyFormat("SomeType MemberFunction(const Deleted&) & = delete;",
+ AlignLeft);
+ verifyFormat("Deleted& operator=(const Deleted&) &;", AlignLeft);
+ verifyFormat("SomeType MemberFunction(const Deleted&) &;", AlignLeft);
FormatStyle Spaces = getLLVMStyle();
Spaces.SpacesInCStyleCastParentheses = true;
- verifyFormat("Deleted &operator=(const Deleted &)& = default;", Spaces);
- verifyFormat("SomeType MemberFunction(const Deleted &)& = delete;", Spaces);
- verifyFormat("Deleted &operator=(const Deleted &)&;", Spaces);
- verifyFormat("SomeType MemberFunction(const Deleted &)&;", Spaces);
+ verifyFormat("Deleted &operator=(const Deleted &) & = default;", Spaces);
+ verifyFormat("SomeType MemberFunction(const Deleted &) & = delete;", Spaces);
+ verifyFormat("Deleted &operator=(const Deleted &) &;", Spaces);
+ verifyFormat("SomeType MemberFunction(const Deleted &) &;", Spaces);
Spaces.SpacesInCStyleCastParentheses = false;
Spaces.SpacesInParentheses = true;
- verifyFormat("Deleted &operator=( const Deleted & )& = default;", Spaces);
- verifyFormat("SomeType MemberFunction( const Deleted & )& = delete;", Spaces);
- verifyFormat("Deleted &operator=( const Deleted & )&;", Spaces);
- verifyFormat("SomeType MemberFunction( const Deleted & )&;", Spaces);
+ verifyFormat("Deleted &operator=( const Deleted & ) & = default;", Spaces);
+ verifyFormat("SomeType MemberFunction( const Deleted & ) & = delete;", Spaces);
+ verifyFormat("Deleted &operator=( const Deleted & ) &;", Spaces);
+ verifyFormat("SomeType MemberFunction( const Deleted & ) &;", Spaces);
}
TEST_F(FormatTest, UnderstandsNewAndDelete) {
// Member function reference qualifiers aren't binary operators.
verifyFormat("string // break\n"
- "operator()()& {}");
+ "operator()() & {}");
verifyFormat("string // break\n"
- "operator()()&& {}");
+ "operator()() && {}");
verifyGoogleFormat("template <typename T>\n"
- "auto x()& -> int {}");
+ "auto x() & -> int {}");
}
TEST_F(FormatTest, UnderstandsAttributes) {