[clang][DeclPrinter] Fix printing for noexcept expressions

We are already building into the final result, no need to append it
again.

Fixes https://github.com/clangd/vscode-clangd/issues/290.

Differential Revision: https://reviews.llvm.org/D118245
This commit is contained in:
Kadir Cetinkaya 2022-01-26 14:50:40 +01:00
parent 268524238e
commit b777d354f6
No known key found for this signature in database
GPG Key ID: E39E36B8D2057ED6
2 changed files with 3 additions and 7 deletions

View File

@ -731,7 +731,6 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
FT->getNoexceptExpr()->printPretty(EOut, nullptr, SubPolicy,
Indentation, "\n", &Context);
EOut.flush();
Proto += EOut.str();
Proto += ")";
}
}

View File

@ -909,8 +909,7 @@ TEST(DeclPrinter, TestFunctionDecl_ExceptionSpecification5) {
" void A(int a) noexcept(true);"
"};",
"A",
"void A(int a) noexcept(trueA(int a) noexcept(true)"));
// WRONG; Should be: "void A(int a) noexcept(true);"
"void A(int a) noexcept(true)"));
}
TEST(DeclPrinter, TestFunctionDecl_ExceptionSpecification6) {
@ -919,8 +918,7 @@ TEST(DeclPrinter, TestFunctionDecl_ExceptionSpecification6) {
" void A(int a) noexcept(1 < 2);"
"};",
"A",
"void A(int a) noexcept(1 < 2A(int a) noexcept(1 < 2)"));
// WRONG; Should be: "void A(int a) noexcept(1 < 2);"
"void A(int a) noexcept(1 < 2)"));
}
TEST(DeclPrinter, TestFunctionDecl_ExceptionSpecification7) {
@ -930,8 +928,7 @@ TEST(DeclPrinter, TestFunctionDecl_ExceptionSpecification7) {
" void A(int a) noexcept(N < 2);"
"};",
"A",
"void A(int a) noexcept(N < 2A(int a) noexcept(N < 2)"));
// WRONG; Should be: "void A(int a) noexcept(N < 2);"
"void A(int a) noexcept(N < 2)"));
}
TEST(DeclPrinter, TestVarDecl1) {