[clang] Respect TerseOutput when printing lambdas
Reviewers: ilya-biryukov, hokein, sammccall Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62487 llvm-svn: 361771
This commit is contained in:
parent
4a7c4069ae
commit
20c3c4fe5a
|
@ -1950,7 +1950,10 @@ void StmtPrinter::VisitLambdaExpr(LambdaExpr *Node) {
|
|||
|
||||
// Print the body.
|
||||
OS << ' ';
|
||||
PrintRawCompoundStmt(Node->getBody());
|
||||
if (Policy.TerseOutput)
|
||||
OS << "{}";
|
||||
else
|
||||
PrintRawCompoundStmt(Node->getBody());
|
||||
}
|
||||
|
||||
void StmtPrinter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *Node) {
|
||||
|
|
|
@ -231,3 +231,17 @@ class A {
|
|||
ASSERT_TRUE(PrintedStmtObjCMatches(ObjCSource, returnStmt().bind("id"),
|
||||
"return self->ivar;\n"));
|
||||
}
|
||||
|
||||
TEST(StmtPrinter, TerseOutputWithLambdas) {
|
||||
const char *CPPSource = "auto lamb = []{ return 0; };";
|
||||
|
||||
// body is printed when TerseOutput is off(default).
|
||||
ASSERT_TRUE(PrintedStmtCXXMatches(StdVer::CXX11, CPPSource,
|
||||
lambdaExpr(anything()).bind("id"),
|
||||
"[] {\n return 0;\n}"));
|
||||
|
||||
// body not printed when TerseOutput is on.
|
||||
ASSERT_TRUE(PrintedStmtCXXMatches(
|
||||
StdVer::CXX11, CPPSource, lambdaExpr(anything()).bind("id"), "[] {}",
|
||||
PolicyAdjusterType([](PrintingPolicy &PP) { PP.TerseOutput = true; })));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue