Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ AST Dumping Potentially Breaking Changes
----------------------------------------

- The text ast-dumper has improved printing of TemplateArguments.
- The text decl-dumper prints template parameters' trailing requires expressions now.

Clang Frontend Potentially Breaking Changes
-------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions clang/lib/AST/DeclPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,13 @@ void DeclPrinter::printTemplateParameters(const TemplateParameterList *Params,
}

Out << '>';

if (const Expr *RequiresClause = Params->getRequiresClause()) {
Out << " requires ";
RequiresClause->printPretty(Out, nullptr, Policy, Indentation, "\n",
&Context);
}

if (!OmitTemplateKW)
Out << ' ';
}
Expand Down
17 changes: 17 additions & 0 deletions clang/test/PCH/cxx2a-requires-expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,20 @@ bool f() {
requires C<typename T::val> || (C<typename T::val> || C<T>);
};
}

namespace trailing_requires_expression {

template <typename T> requires C<T> && C2<T, T>
// CHECK: template <typename T> requires C<T> && C2<T, T> void g();
void g();

template <typename T> requires C<T> || C2<T, T>
// CHECK: template <typename T> requires C<T> || C2<T, T> constexpr int h = sizeof(T);
constexpr int h = sizeof(T);

template <typename T> requires C<T>
// CHECK: template <typename T> requires C<T> class i {
// CHECK-NEXT: };
class i {};

}