Re: [PATCH] D127863: [clang] Dont print implicit forrange initializer
thanks for the revert, you beat me to it. On Fri, Jun 17, 2022 at 3:07 PM Nico Weber via Phabricator < revi...@reviews.llvm.org> wrote: > thakis added a comment. > > Before landing changes, please: > > - Run tests > - Look at the result from the presubmit checks > > After landing changes, please watch your favorite bot cycle green with it, > and pay attention for buildbot email for a while. > > > Repository: > rG LLVM Github Monorepo > > CHANGES SINCE LAST ACTION > https://reviews.llvm.org/D127863/new/ > > https://reviews.llvm.org/D127863 > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D127863: [clang] Dont print implicit forrange initializer
thakis added a comment. Before landing changes, please: - Run tests - Look at the result from the presubmit checks After landing changes, please watch your favorite bot cycle green with it, and pay attention for buildbot email for a while. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D127863/new/ https://reviews.llvm.org/D127863 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D127863: [clang] Dont print implicit forrange initializer
CarlosAlbertoEnciso added a comment. @kadircet It seems that your change broke couple of clang tests: https://lab.llvm.org/buildbot/#/builders/109/builds/40797 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D127863/new/ https://reviews.llvm.org/D127863 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D127863: [clang] Dont print implicit forrange initializer
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG32805e60c9de: [clang] Dont print implicit forrange initializer (authored by kadircet). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D127863/new/ https://reviews.llvm.org/D127863 Files: clang/lib/AST/DeclPrinter.cpp clang/unittests/AST/DeclPrinterTest.cpp Index: clang/unittests/AST/DeclPrinterTest.cpp === --- clang/unittests/AST/DeclPrinterTest.cpp +++ clang/unittests/AST/DeclPrinterTest.cpp @@ -1426,4 +1426,7 @@ ASSERT_TRUE(PrintedDeclCXX17Matches( "int a = 0x15;", namedDecl(hasName("a")).bind("id"), "int a = 0x15", [](PrintingPolicy &Policy) { Policy.ConstantsAsWritten = true; })); + ASSERT_TRUE( + PrintedDeclCXX17Matches("void foo() {int arr[42]; for(int a : arr);}", + namedDecl(hasName("a")).bind("id"), "int a")); } Index: clang/lib/AST/DeclPrinter.cpp === --- clang/lib/AST/DeclPrinter.cpp +++ clang/lib/AST/DeclPrinter.cpp @@ -895,12 +895,15 @@ Expr *Init = D->getInit(); if (!Policy.SuppressInitializers && Init) { bool ImplicitInit = false; -if (CXXConstructExpr *Construct = -dyn_cast(Init->IgnoreImplicit())) { +if (D->isCXXForRangeDecl()) { + // FIXME: We should print the range expression instead. + ImplicitInit = true; +} else if (CXXConstructExpr *Construct = + dyn_cast(Init->IgnoreImplicit())) { if (D->getInitStyle() == VarDecl::CallInit && !Construct->isListInitialization()) { ImplicitInit = Construct->getNumArgs() == 0 || - Construct->getArg(0)->isDefaultArgument(); + Construct->getArg(0)->isDefaultArgument(); } } if (!ImplicitInit) { Index: clang/unittests/AST/DeclPrinterTest.cpp === --- clang/unittests/AST/DeclPrinterTest.cpp +++ clang/unittests/AST/DeclPrinterTest.cpp @@ -1426,4 +1426,7 @@ ASSERT_TRUE(PrintedDeclCXX17Matches( "int a = 0x15;", namedDecl(hasName("a")).bind("id"), "int a = 0x15", [](PrintingPolicy &Policy) { Policy.ConstantsAsWritten = true; })); + ASSERT_TRUE( + PrintedDeclCXX17Matches("void foo() {int arr[42]; for(int a : arr);}", + namedDecl(hasName("a")).bind("id"), "int a")); } Index: clang/lib/AST/DeclPrinter.cpp === --- clang/lib/AST/DeclPrinter.cpp +++ clang/lib/AST/DeclPrinter.cpp @@ -895,12 +895,15 @@ Expr *Init = D->getInit(); if (!Policy.SuppressInitializers && Init) { bool ImplicitInit = false; -if (CXXConstructExpr *Construct = -dyn_cast(Init->IgnoreImplicit())) { +if (D->isCXXForRangeDecl()) { + // FIXME: We should print the range expression instead. + ImplicitInit = true; +} else if (CXXConstructExpr *Construct = + dyn_cast(Init->IgnoreImplicit())) { if (D->getInitStyle() == VarDecl::CallInit && !Construct->isListInitialization()) { ImplicitInit = Construct->getNumArgs() == 0 || - Construct->getArg(0)->isDefaultArgument(); + Construct->getArg(0)->isDefaultArgument(); } } if (!ImplicitInit) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D127863: [clang] Dont print implicit forrange initializer
usaxena95 accepted this revision. usaxena95 added a comment. This revision is now accepted and ready to land. Thanks! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D127863/new/ https://reviews.llvm.org/D127863 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D127863: [clang] Dont print implicit forrange initializer
kadircet created this revision. kadircet added a reviewer: usaxena95. Herald added a project: All. kadircet requested review of this revision. Herald added subscribers: cfe-commits, ilya-biryukov. Herald added a project: clang. Fixes https://github.com/clangd/clangd/issues/1158 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D127863 Files: clang/lib/AST/DeclPrinter.cpp clang/unittests/AST/DeclPrinterTest.cpp Index: clang/unittests/AST/DeclPrinterTest.cpp === --- clang/unittests/AST/DeclPrinterTest.cpp +++ clang/unittests/AST/DeclPrinterTest.cpp @@ -1426,4 +1426,7 @@ ASSERT_TRUE(PrintedDeclCXX17Matches( "int a = 0x15;", namedDecl(hasName("a")).bind("id"), "int a = 0x15", [](PrintingPolicy &Policy) { Policy.ConstantsAsWritten = true; })); + ASSERT_TRUE( + PrintedDeclCXX17Matches("void foo() {int arr[42]; for(int a : arr);}", + namedDecl(hasName("a")).bind("id"), "int a")); } Index: clang/lib/AST/DeclPrinter.cpp === --- clang/lib/AST/DeclPrinter.cpp +++ clang/lib/AST/DeclPrinter.cpp @@ -895,12 +895,15 @@ Expr *Init = D->getInit(); if (!Policy.SuppressInitializers && Init) { bool ImplicitInit = false; -if (CXXConstructExpr *Construct = -dyn_cast(Init->IgnoreImplicit())) { +if (D->isCXXForRangeDecl()) { + // FIXME: We should print the range expression instead. + ImplicitInit = true; +} else if (CXXConstructExpr *Construct = + dyn_cast(Init->IgnoreImplicit())) { if (D->getInitStyle() == VarDecl::CallInit && !Construct->isListInitialization()) { ImplicitInit = Construct->getNumArgs() == 0 || - Construct->getArg(0)->isDefaultArgument(); + Construct->getArg(0)->isDefaultArgument(); } } if (!ImplicitInit) { Index: clang/unittests/AST/DeclPrinterTest.cpp === --- clang/unittests/AST/DeclPrinterTest.cpp +++ clang/unittests/AST/DeclPrinterTest.cpp @@ -1426,4 +1426,7 @@ ASSERT_TRUE(PrintedDeclCXX17Matches( "int a = 0x15;", namedDecl(hasName("a")).bind("id"), "int a = 0x15", [](PrintingPolicy &Policy) { Policy.ConstantsAsWritten = true; })); + ASSERT_TRUE( + PrintedDeclCXX17Matches("void foo() {int arr[42]; for(int a : arr);}", + namedDecl(hasName("a")).bind("id"), "int a")); } Index: clang/lib/AST/DeclPrinter.cpp === --- clang/lib/AST/DeclPrinter.cpp +++ clang/lib/AST/DeclPrinter.cpp @@ -895,12 +895,15 @@ Expr *Init = D->getInit(); if (!Policy.SuppressInitializers && Init) { bool ImplicitInit = false; -if (CXXConstructExpr *Construct = -dyn_cast(Init->IgnoreImplicit())) { +if (D->isCXXForRangeDecl()) { + // FIXME: We should print the range expression instead. + ImplicitInit = true; +} else if (CXXConstructExpr *Construct = + dyn_cast(Init->IgnoreImplicit())) { if (D->getInitStyle() == VarDecl::CallInit && !Construct->isListInitialization()) { ImplicitInit = Construct->getNumArgs() == 0 || - Construct->getArg(0)->isDefaultArgument(); + Construct->getArg(0)->isDefaultArgument(); } } if (!ImplicitInit) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits