forked from OSchip/llvm-project
clang-format: Support enum type template arguments.
Before: template <enum E> class A { public : E *f(); }; After: template <enum E> class A { public: E *f(); }; llvm-svn: 268878
This commit is contained in:
parent
4a9d32c5ba
commit
a7900adf41
|
@ -902,6 +902,7 @@ void UnwrappedLineParser::parseStructuralElement() {
|
|||
break;
|
||||
}
|
||||
do {
|
||||
const FormatToken *Previous = getPreviousToken();
|
||||
switch (FormatTok->Tok.getKind()) {
|
||||
case tok::at:
|
||||
nextToken();
|
||||
|
@ -909,6 +910,12 @@ void UnwrappedLineParser::parseStructuralElement() {
|
|||
parseBracedList();
|
||||
break;
|
||||
case tok::kw_enum:
|
||||
// Ignore if this is part of "template <enum ...".
|
||||
if (Previous && Previous->is(tok::less)) {
|
||||
nextToken();
|
||||
break;
|
||||
}
|
||||
|
||||
// parseEnum falls through and does not yet add an unwrapped line as an
|
||||
// enum definition can start a structural element.
|
||||
if (!parseEnum())
|
||||
|
|
|
@ -5381,6 +5381,10 @@ TEST_F(FormatTest, WrapsTemplateDeclarations) {
|
|||
verifyFormat("template <typename T> // T can be A, B or C.\n"
|
||||
"struct C {};",
|
||||
AlwaysBreak);
|
||||
verifyFormat("template <enum E> class A {\n"
|
||||
"public:\n"
|
||||
" E *f();\n"
|
||||
"};");
|
||||
}
|
||||
|
||||
TEST_F(FormatTest, WrapsAtNestedNameSpecifiers) {
|
||||
|
|
Loading…
Reference in New Issue