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:
Daniel Jasper 2016-05-08 18:12:22 +00:00
parent 4a9d32c5ba
commit a7900adf41
2 changed files with 11 additions and 0 deletions

View File

@ -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())

View File

@ -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) {