forked from OSchip/llvm-project
clang-format: Improve template parameter detection.
Before: struct A < std::enable_if<sizeof(T2) <sizeof(int32)>::type>; After: struct A<std::enable_if<sizeof(T2) < sizeof(int32)>::type>; llvm-svn: 225435
This commit is contained in:
parent
0c4d51b779
commit
b13135bc08
|
@ -470,9 +470,12 @@ private:
|
|||
return false;
|
||||
break;
|
||||
case tok::less:
|
||||
if ((!Tok->Previous || !Tok->Previous->Tok.isLiteral()) && parseAngle())
|
||||
if ((!Tok->Previous ||
|
||||
(!Tok->Previous->Tok.isLiteral() &&
|
||||
!(Tok->Previous->is(tok::r_paren) && Contexts.size() > 1))) &&
|
||||
parseAngle()) {
|
||||
Tok->Type = TT_TemplateOpener;
|
||||
else {
|
||||
} else {
|
||||
Tok->Type = TT_BinaryOperator;
|
||||
CurrentToken = Tok;
|
||||
next();
|
||||
|
|
|
@ -4939,6 +4939,7 @@ TEST_F(FormatTest, UnderstandsTemplateParameters) {
|
|||
|
||||
verifyFormat("f<int>();");
|
||||
verifyFormat("template <typename T> void f() {}");
|
||||
verifyFormat("struct A<std::enable_if<sizeof(T2) < sizeof(int32)>::type>;");
|
||||
|
||||
// Not template parameters.
|
||||
verifyFormat("return a < b && c > d;");
|
||||
|
|
Loading…
Reference in New Issue