Author: Kadir Cetinkaya Date: 2022-01-26T16:04:24+01:00 New Revision: b777d354f6703afd58b1803fdfb6d43a607d8fd6
URL: https://github.com/llvm/llvm-project/commit/b777d354f6703afd58b1803fdfb6d43a607d8fd6 DIFF: https://github.com/llvm/llvm-project/commit/b777d354f6703afd58b1803fdfb6d43a607d8fd6.diff LOG: [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 Added: Modified: clang/lib/AST/DeclPrinter.cpp clang/unittests/AST/DeclPrinterTest.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index 698b1c3ffd348..715da7e0d90c5 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/lib/AST/DeclPrinter.cpp @@ -731,7 +731,6 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { FT->getNoexceptExpr()->printPretty(EOut, nullptr, SubPolicy, Indentation, "\n", &Context); EOut.flush(); - Proto += EOut.str(); Proto += ")"; } } diff --git a/clang/unittests/AST/DeclPrinterTest.cpp b/clang/unittests/AST/DeclPrinterTest.cpp index 0b579565f5b4a..c2d7d78738f96 100644 --- a/clang/unittests/AST/DeclPrinterTest.cpp +++ b/clang/unittests/AST/DeclPrinterTest.cpp @@ -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) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits