Re: [PATCH] D127863: [clang] Dont print implicit forrange initializer

2022-06-17 Thread Kadir Çetinkaya via cfe-commits
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

2022-06-17 Thread Nico Weber via Phabricator via cfe-commits
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

2022-06-17 Thread Carlos Alberto Enciso via Phabricator via cfe-commits
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

2022-06-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
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.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.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

2022-06-15 Thread Utkarsh Saxena via Phabricator via cfe-commits
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

2022-06-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
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.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.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