This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd1a59eefd3a0: [Clang] Remove redundant init-parens in AST 
print (authored by lichray).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120608/new/

https://reviews.llvm.org/D120608

Files:
  clang/lib/AST/StmtPrinter.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp
  clang/test/SemaCXX/cxx2b-ast-print.cpp

Index: clang/test/SemaCXX/cxx2b-ast-print.cpp
===================================================================
--- clang/test/SemaCXX/cxx2b-ast-print.cpp
+++ clang/test/SemaCXX/cxx2b-ast-print.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -std=c++2b -fsyntax-only -ast-print %s | FileCheck %s
 
+template <template <class...> class C>
 void test_auto_expr(long long y, auto &&z) {
   int x[] = {3, 4};
 
@@ -15,16 +16,36 @@
 
   // CHECK{LITERAL}: auto(z)
   void(auto(z));
-  // CHECK{LITERAL}: auto({z})
-  void(auto{z}); // T({z}) is legal unless T = auto
+  // CHECK{LITERAL}: auto{z}
+  void(auto{z});
 
   // CHECK{LITERAL}: new int *(x)
   void(new auto(x));
   // CHECK{LITERAL}: new int *{x}
   void(new auto{x});
 
+  // CHECK{LITERAL}: new auto(z)
+  void(new auto(z));
+  // CHECK{LITERAL}: new auto{z}
+  void(new auto{z});
+
   // CHECK{LITERAL}: new long long(y)
   void(new decltype(auto)(y));
   // CHECK{LITERAL}: new long long{y}
   void(new decltype(auto){y});
+
+  // CHECK{LITERAL}: new decltype(auto)(z)
+  void(new decltype(auto)(z));
+  // CHECK{LITERAL}: new decltype(auto){z}
+  void(new decltype(auto){z});
+
+  // CHECK{LITERAL}: C(x, y, z)
+  void(C(x, y, z));
+  // CHECK{LITERAL}: C{x, y, z}
+  void(C{x, y, z});
+
+  // CHECK{LITERAL}: new C(x, y, z)
+  void(new C(x, y, z));
+  // CHECK{LITERAL}: new C{x, y, z}
+  void(new C{x, y, z});
 }
Index: clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp
===================================================================
--- clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp
+++ clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp
@@ -72,7 +72,7 @@
 };
 
 template<typename T> requires requires(T t) { typename E<T>::non_default_constructible{}; }
-// expected-note@-1 {{because 'typename E<T>::non_default_constructible({})' would be invalid: no matching constructor for initialization of 'typename E<int>::non_default_constructible'}}
+// expected-note@-1 {{because 'typename E<T>::non_default_constructible{}' would be invalid: no matching constructor for initialization of 'typename E<int>::non_default_constructible'}}
 struct r6 {};
 
 using r6i1 = r6<int>;
Index: clang/lib/AST/StmtPrinter.cpp
===================================================================
--- clang/lib/AST/StmtPrinter.cpp
+++ clang/lib/AST/StmtPrinter.cpp
@@ -2153,11 +2153,13 @@
     OS << ")";
 
   CXXNewExpr::InitializationStyle InitStyle = E->getInitializationStyle();
-  if (InitStyle) {
-    if (InitStyle == CXXNewExpr::CallInit)
+  if (InitStyle != CXXNewExpr::NoInit) {
+    bool Bare = InitStyle == CXXNewExpr::CallInit &&
+                !isa<ParenListExpr>(E->getInitializer());
+    if (Bare)
       OS << "(";
     PrintExpr(E->getInitializer());
-    if (InitStyle == CXXNewExpr::CallInit)
+    if (Bare)
       OS << ")";
   }
 }
@@ -2219,19 +2221,19 @@
   PrintExpr(E->getSubExpr());
 }
 
-void
-StmtPrinter::VisitCXXUnresolvedConstructExpr(
-                                           CXXUnresolvedConstructExpr *Node) {
+void StmtPrinter::VisitCXXUnresolvedConstructExpr(
+    CXXUnresolvedConstructExpr *Node) {
   Node->getTypeAsWritten().print(OS, Policy);
-  OS << "(";
-  for (CXXUnresolvedConstructExpr::arg_iterator Arg = Node->arg_begin(),
-                                             ArgEnd = Node->arg_end();
-       Arg != ArgEnd; ++Arg) {
+  if (!Node->isListInitialization())
+    OS << '(';
+  for (auto Arg = Node->arg_begin(), ArgEnd = Node->arg_end(); Arg != ArgEnd;
+       ++Arg) {
     if (Arg != Node->arg_begin())
       OS << ", ";
     PrintExpr(*Arg);
   }
-  OS << ")";
+  if (!Node->isListInitialization())
+    OS << ')';
 }
 
 void StmtPrinter::VisitCXXDependentScopeMemberExpr(
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to