[PATCH] D154301: Fix aggregate CTAD with string literals adding extra const

2023-07-05 Thread Yuanfang Chen 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 rG92f4bf268998: Fix aggregate CTAD with string literals adding 
extra const (authored by MitalAshok, committed by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154301

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/test/CXX/drs/dr26xx.cpp
  clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -15893,7 +15893,7 @@
 https://cplusplus.github.io/CWG/issues/2681.html;>2681
 DR
 Deducing member array type from string literal
-Unknown
+Clang 17
   
   
 https://cplusplus.github.io/CWG/issues/2682.html;>2682
Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
===
--- clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
+++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -198,22 +198,22 @@
   // CHECK: FunctionTemplateDecl {{.*}} implicit 
   // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
   // CHECK: |-NonTypeTemplateParmDecl {{.*}} 'size_t':'unsigned {{.*}}' depth 
0 index 1 N
-  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  
'auto (T (&)[N]) -> A'
-  // CHECK: | `-ParmVarDecl {{.*}} 'T (&)[N]'
-  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (const char (&)[5]) -> Array::A'
-  // CHECK:   |-TemplateArgument type 'const char'
-  // CHECK:   | `-QualType {{.*}} 'const char' const
-  // CHECK:   |   `-BuiltinType {{.*}} 'char'
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  
'auto (const T (&)[N]) -> A'
+  // CHECK: | `-ParmVarDecl {{.*}} 'const T (&)[N]'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (const char (&)[5]) -> Array::A'
+  // CHECK:   |-TemplateArgument type 'char'
+  // CHECK:   | `-BuiltinType {{.*}} 'char'
   // CHECK:   |-TemplateArgument integral 5
   // CHECK:   `-ParmVarDecl {{.*}} 'const char (&)[5]'
-  // CHECK: FunctionProtoType {{.*}} 'auto (T (&)[N]) -> A' dependent 
trailing_return cdecl
+  // CHECK: FunctionProtoType {{.*}} 'auto (const T (&)[N]) -> A' 
dependent trailing_return cdecl
   // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent
   // CHECK: | `-CXXRecord {{.*}} 'A'
-  // CHECK: `-LValueReferenceType {{.*}} 'T (&)[N]' dependent
-  // CHECK:   `-DependentSizedArrayType {{.*}} 'T[N]' dependent
-  // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
-  // CHECK: | `-TemplateTypeParm {{.*}} 'T'
-  // CHECK: `-DeclRefExpr {{.*}} 'size_t':'unsigned {{.*}}' 
NonTypeTemplateParm {{.*}} 'N' 'size_t':'unsigned {{.*}}'
+  // CHECK: `-LValueReferenceType {{.*}} 'const T (&)[N]' dependent
+  // CHECK:   `-QualType {{.*}} 'const T[N]' const
+  // CHECK: `-DependentSizedArrayType {{.*}} 'T[N]' dependent
+  // CHECK:   |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   | `-TemplateTypeParm {{.*}} 'T'
+  // CHECK:   `-DeclRefExpr {{.*}} 'size_t':'unsigned{{.*}}' 
NonTypeTemplateParm {{.*}} 'N' 'size_t':'unsigned{{.*}}'
 }
 
 namespace BraceElision {
Index: clang/test/CXX/drs/dr26xx.cpp
===
--- clang/test/CXX/drs/dr26xx.cpp
+++ clang/test/CXX/drs/dr26xx.cpp
@@ -126,3 +126,27 @@
 brachiosaur |= neck;// OK
 }
 }
+
+namespace dr2681 { // dr2681: 17
+using size_t = decltype(sizeof(int));
+
+template
+struct H {
+  T array[N];
+};
+template
+struct I {
+  volatile T array[N];
+};
+template
+struct J {  // expected-note 3{{candidate}}
+  unsigned char array[N];
+};
+
+H h = { "abc" };
+I i = { "def" };
+static_assert(__is_same(decltype(h), H));  // Not H
+static_assert(__is_same(decltype(i), I));
+
+J j = { "ghi" };  // expected-error {{no viable constructor or deduction 
guide}}
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -10714,7 +10714,8 @@
   ElementTypes[I] = 
Context.getRValueReferenceType(ElementTypes[I]);
 else if (isa(
  ListInit->getInit(I)->IgnoreParenImpCasts()))
-  ElementTypes[I] = 
Context.getLValueReferenceType(ElementTypes[I]);
+  ElementTypes[I] =
+  Context.getLValueReferenceType(ElementTypes[I].withConst());
   }
 
 llvm::FoldingSetNodeID ID;


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -15893,7 +15893,7 @@
 

[PATCH] D154301: Fix aggregate CTAD with string literals adding extra const

2023-07-02 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen accepted this revision.
ychen added a comment.
This revision is now accepted and ready to land.

LGTM. Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154301

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154301: Fix aggregate CTAD with string literals adding extra const

2023-07-02 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

`clang/test/SemaTemplate/aggregate-deduction-candidate.cpp` seems need updates.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154301

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154301: Fix aggregate CTAD with string literals adding extra const

2023-07-02 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

Thanks for catching this. The change LGTM. I think this is 
https://wg21.link/cwg2681. Could you please move the test to 
`clang/test/CXX/drs/dr26xx.cpp` and keep only these tests that are in the DR? 
Then you could run `clang/www/make_cxx_dr_status` to update 
`clang/www/cxx_dr_status.html`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154301

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-29 Thread Yuanfang Chen 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 rG632dd6a4ca00: [Clang] Implements CTAD for aggregates P1816R0 
and P2082R1 (authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -7372,7 +7372,7 @@
   cxxDeductionGuideDecl(hasParameter(0, hasType(asString("A");
   auto *ToD = Import(FromD, Lang_CXX17);
   ASSERT_TRUE(ToD);
-  EXPECT_TRUE(ToD->isCopyDeductionCandidate());
+  EXPECT_EQ(ToD->getDeductionCandidateKind(), DeductionCandidate::Copy);
   // Check that the deduced class template is also imported.
   EXPECT_TRUE(findFromTU(FromD)->Importer->GetAlreadyImportedOrNull(
   FromD->getDeducedTemplate()));
Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -0,0 +1,364 @@
+// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace
+
+namespace Basic {
+  template struct A {
+T x;
+T y;
+  };
+
+  A a1 = {3.0, 4.0};
+  A a2 = {.x = 3.0, .y = 4.0};
+
+  A a3(3.0, 4.0);
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (T, T) -> A'
+  // CHECK: | |-ParmVarDecl {{.*}} 'T'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (double, double) -> Basic::A'
+  // CHECK:   |-TemplateArgument type 'double'
+  // CHECK:   | `-BuiltinType {{.*}} 'double'
+  // CHECK:   |-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK:   `-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK: FunctionProtoType {{.*}} 'auto (T, T) -> A' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'A'
+  // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: | `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  template  struct S { // expected-note 2 {{candidate}}
+T x;
+T y;
+  };
+
+  template  struct C { // expected-note 10 {{candidate}}
+S s;
+T t;
+  };
+
+  template  struct D { // expected-note 6 {{candidate}}
+S s;
+T t;
+  };
+
+  C c1 = {1, 2}; // expected-error {{no viable}}
+  C c2 = {1, 2, 3}; // expected-error {{no viable}}
+  C c3 = {{1u, 2u}, 3};
+
+  C c4(1, 2);// expected-error {{no viable}}
+  C c5(1, 2, 3); // expected-error {{no viable}}
+  C c6({1u, 2u}, 3);
+
+  D d1 = {1, 2}; // expected-error {{no viable}}
+  D d2 = {1, 2, 3};
+
+  D d3(1, 2); // expected-error {{no viable}}
+  // CTAD succeed but brace elision is not allowed for parenthesized aggregate init. 
+  D d4(1, 2, 3); // expected-error {{no viable}}
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (S, T) -> C'
+  // CHECK: | |-ParmVarDecl {{.*}} 'S':'S'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (S, int) -> Basic::C'
+  // CHECK:   |-TemplateArgument type 'int'
+  // CHECK:   | `-BuiltinType {{.*}} 'int'
+  // CHECK:   |-ParmVarDecl {{.*}} 'S':'Basic::S'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (S, T) -> C' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'C' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'C'
+  // CHECK: |-ElaboratedType {{.*}} 'S' sugar dependent
+  // CHECK: | 

[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-29 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 535936.
ychen added a comment.

- rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -7372,7 +7372,7 @@
   cxxDeductionGuideDecl(hasParameter(0, hasType(asString("A");
   auto *ToD = Import(FromD, Lang_CXX17);
   ASSERT_TRUE(ToD);
-  EXPECT_TRUE(ToD->isCopyDeductionCandidate());
+  EXPECT_EQ(ToD->getDeductionCandidateKind(), DeductionCandidate::Copy);
   // Check that the deduced class template is also imported.
   EXPECT_TRUE(findFromTU(FromD)->Importer->GetAlreadyImportedOrNull(
   FromD->getDeducedTemplate()));
Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -0,0 +1,364 @@
+// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace
+
+namespace Basic {
+  template struct A {
+T x;
+T y;
+  };
+
+  A a1 = {3.0, 4.0};
+  A a2 = {.x = 3.0, .y = 4.0};
+
+  A a3(3.0, 4.0);
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (T, T) -> A'
+  // CHECK: | |-ParmVarDecl {{.*}} 'T'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (double, double) -> Basic::A'
+  // CHECK:   |-TemplateArgument type 'double'
+  // CHECK:   | `-BuiltinType {{.*}} 'double'
+  // CHECK:   |-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK:   `-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK: FunctionProtoType {{.*}} 'auto (T, T) -> A' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'A'
+  // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: | `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  template  struct S { // expected-note 2 {{candidate}}
+T x;
+T y;
+  };
+
+  template  struct C { // expected-note 10 {{candidate}}
+S s;
+T t;
+  };
+
+  template  struct D { // expected-note 6 {{candidate}}
+S s;
+T t;
+  };
+
+  C c1 = {1, 2}; // expected-error {{no viable}}
+  C c2 = {1, 2, 3}; // expected-error {{no viable}}
+  C c3 = {{1u, 2u}, 3};
+
+  C c4(1, 2);// expected-error {{no viable}}
+  C c5(1, 2, 3); // expected-error {{no viable}}
+  C c6({1u, 2u}, 3);
+
+  D d1 = {1, 2}; // expected-error {{no viable}}
+  D d2 = {1, 2, 3};
+
+  D d3(1, 2); // expected-error {{no viable}}
+  // CTAD succeed but brace elision is not allowed for parenthesized aggregate init. 
+  D d4(1, 2, 3); // expected-error {{no viable}}
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (S, T) -> C'
+  // CHECK: | |-ParmVarDecl {{.*}} 'S':'S'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (S, int) -> Basic::C'
+  // CHECK:   |-TemplateArgument type 'int'
+  // CHECK:   | `-BuiltinType {{.*}} 'int'
+  // CHECK:   |-ParmVarDecl {{.*}} 'S':'Basic::S'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (S, T) -> C' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'C' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'C'
+  // CHECK: |-ElaboratedType {{.*}} 'S' sugar dependent
+  // CHECK: | `-TemplateSpecializationType {{.*}} 'S' dependent S
+  // CHECK: |   `-TemplateArgument type 'T'
+  // CHECK: | `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 

[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-29 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D139837#4460664 , @cor3ntin wrote:

> Thanks a lot for working on this!
> Do you need Aaron or myself to commit this for you? If so, which name / mail 
> do you want us to use?

That's okay. I'm doing the rebase and I could commit it later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-29 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

Thanks for the review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-29 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:98
+- Implemented `P1816R0: `_ and `P2082R1: 
`_,
+  which allows CTAD for aggregates (parenthesized aggregate-initialization is 
not supported).
 

aaron.ballman wrote:
> Paren aggregate init is now supported, so this should be updated.
Thanks for catching this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-29 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 535883.
ychen marked 4 inline comments as done.
ychen added a comment.

- address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1246,7 +1246,7 @@
 
   Class template argument deduction for aggregates
   https://wg21.link/p1816r0;>P1816R0
-  No
+  Clang 17
 

 https://wg21.link/p2082r1;>P2082R1
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -7372,7 +7372,7 @@
   cxxDeductionGuideDecl(hasParameter(0, hasType(asString("A");
   auto *ToD = Import(FromD, Lang_CXX17);
   ASSERT_TRUE(ToD);
-  EXPECT_TRUE(ToD->isCopyDeductionCandidate());
+  EXPECT_EQ(ToD->getDeductionCandidateKind(), DeductionCandidate::Copy);
   // Check that the deduced class template is also imported.
   EXPECT_TRUE(findFromTU(FromD)->Importer->GetAlreadyImportedOrNull(
   FromD->getDeducedTemplate()));
Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -0,0 +1,364 @@
+// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace
+
+namespace Basic {
+  template struct A {
+T x;
+T y;
+  };
+
+  A a1 = {3.0, 4.0};
+  A a2 = {.x = 3.0, .y = 4.0};
+
+  A a3(3.0, 4.0);
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (T, T) -> A'
+  // CHECK: | |-ParmVarDecl {{.*}} 'T'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (double, double) -> Basic::A'
+  // CHECK:   |-TemplateArgument type 'double'
+  // CHECK:   | `-BuiltinType {{.*}} 'double'
+  // CHECK:   |-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK:   `-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK: FunctionProtoType {{.*}} 'auto (T, T) -> A' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'A'
+  // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: | `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  template  struct S { // expected-note 2 {{candidate}}
+T x;
+T y;
+  };
+
+  template  struct C { // expected-note 10 {{candidate}}
+S s;
+T t;
+  };
+
+  template  struct D { // expected-note 6 {{candidate}}
+S s;
+T t;
+  };
+
+  C c1 = {1, 2}; // expected-error {{no viable}}
+  C c2 = {1, 2, 3}; // expected-error {{no viable}}
+  C c3 = {{1u, 2u}, 3};
+
+  C c4(1, 2);// expected-error {{no viable}}
+  C c5(1, 2, 3); // expected-error {{no viable}}
+  C c6({1u, 2u}, 3);
+
+  D d1 = {1, 2}; // expected-error {{no viable}}
+  D d2 = {1, 2, 3};
+
+  D d3(1, 2); // expected-error {{no viable}}
+  // CTAD succeed but brace elision is not allowed for parenthesized aggregate init. 
+  D d4(1, 2, 3); // expected-error {{no viable}}
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (S, T) -> C'
+  // CHECK: | |-ParmVarDecl {{.*}} 'S':'S'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (S, int) -> Basic::C'
+  // CHECK:   |-TemplateArgument type 'int'
+  // CHECK:   | `-BuiltinType {{.*}} 'int'
+  // CHECK:   |-ParmVarDecl {{.*}} 'S':'Basic::S'
+  // CHECK:   

[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-27 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 535132.
ychen marked 3 inline comments as done.
ychen added a comment.

- address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1246,7 +1246,7 @@
 
   Class template argument deduction for aggregates
   https://wg21.link/p1816r0;>P1816R0
-  No
+  Clang 17
 

 https://wg21.link/p2082r1;>P2082R1
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -7372,7 +7372,7 @@
   cxxDeductionGuideDecl(hasParameter(0, hasType(asString("A");
   auto *ToD = Import(FromD, Lang_CXX17);
   ASSERT_TRUE(ToD);
-  EXPECT_TRUE(ToD->isCopyDeductionCandidate());
+  EXPECT_EQ(ToD->getDeductionCandidateKind(), DeductionCandidate::Copy);
   // Check that the deduced class template is also imported.
   EXPECT_TRUE(findFromTU(FromD)->Importer->GetAlreadyImportedOrNull(
   FromD->getDeducedTemplate()));
Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -0,0 +1,364 @@
+// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace
+
+namespace Basic {
+  template struct A {
+T x;
+T y;
+  };
+
+  A a1 = {3.0, 4.0};
+  A a2 = {.x = 3.0, .y = 4.0};
+
+  A a3(3.0, 4.0);
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (T, T) -> A'
+  // CHECK: | |-ParmVarDecl {{.*}} 'T'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (double, double) -> Basic::A'
+  // CHECK:   |-TemplateArgument type 'double'
+  // CHECK:   | `-BuiltinType {{.*}} 'double'
+  // CHECK:   |-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK:   `-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK: FunctionProtoType {{.*}} 'auto (T, T) -> A' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'A'
+  // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: | `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  template  struct S { // expected-note 2 {{candidate}}
+T x;
+T y;
+  };
+
+  template  struct C { // expected-note 10 {{candidate}}
+S s;
+T t;
+  };
+
+  template  struct D { // expected-note 6 {{candidate}}
+S s;
+T t;
+  };
+
+  C c1 = {1, 2}; // expected-error {{no viable}}
+  C c2 = {1, 2, 3}; // expected-error {{no viable}}
+  C c3 = {{1u, 2u}, 3};
+
+  C c4(1, 2);// expected-error {{no viable}}
+  C c5(1, 2, 3); // expected-error {{no viable}}
+  C c6({1u, 2u}, 3);
+
+  D d1 = {1, 2}; // expected-error {{no viable}}
+  D d2 = {1, 2, 3};
+
+  D d3(1, 2); // expected-error {{no viable}}
+  // CTAD succeed but brace elision is not allowed for parenthesized aggregate init. 
+  D d4(1, 2, 3); // expected-error {{no viable}}
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (S, T) -> C'
+  // CHECK: | |-ParmVarDecl {{.*}} 'S':'S'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (S, int) -> Basic::C'
+  // CHECK:   |-TemplateArgument type 'int'
+  // CHECK:   | `-BuiltinType {{.*}} 'int'
+  // CHECK:   |-ParmVarDecl {{.*}} 'S':'Basic::S'
+  // CHECK:   

[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-26 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 534778.
ychen added a comment.

- add a DeductionCandidate parameter


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1246,7 +1246,7 @@
 
   Class template argument deduction for aggregates
   https://wg21.link/p1816r0;>P1816R0
-  No
+  Clang 17
 

 https://wg21.link/p2082r1;>P2082R1
Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -0,0 +1,364 @@
+// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace
+
+namespace Basic {
+  template struct A {
+T x;
+T y;
+  };
+
+  A a1 = {3.0, 4.0};
+  A a2 = {.x = 3.0, .y = 4.0};
+
+  A a3(3.0, 4.0);
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (T, T) -> A'
+  // CHECK: | |-ParmVarDecl {{.*}} 'T'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (double, double) -> Basic::A'
+  // CHECK:   |-TemplateArgument type 'double'
+  // CHECK:   | `-BuiltinType {{.*}} 'double'
+  // CHECK:   |-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK:   `-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK: FunctionProtoType {{.*}} 'auto (T, T) -> A' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'A'
+  // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: | `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  template  struct S { // expected-note 2 {{candidate}}
+T x;
+T y;
+  };
+
+  template  struct C { // expected-note 10 {{candidate}}
+S s;
+T t;
+  };
+
+  template  struct D { // expected-note 6 {{candidate}}
+S s;
+T t;
+  };
+
+  C c1 = {1, 2}; // expected-error {{no viable}}
+  C c2 = {1, 2, 3}; // expected-error {{no viable}}
+  C c3 = {{1u, 2u}, 3};
+
+  C c4(1, 2);// expected-error {{no viable}}
+  C c5(1, 2, 3); // expected-error {{no viable}}
+  C c6({1u, 2u}, 3);
+
+  D d1 = {1, 2}; // expected-error {{no viable}}
+  D d2 = {1, 2, 3};
+
+  D d3(1, 2); // expected-error {{no viable}}
+  // CTAD succeed but brace elision is not allowed for parenthesized aggregate init. 
+  D d4(1, 2, 3); // expected-error {{no viable}}
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (S, T) -> C'
+  // CHECK: | |-ParmVarDecl {{.*}} 'S':'S'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (S, int) -> Basic::C'
+  // CHECK:   |-TemplateArgument type 'int'
+  // CHECK:   | `-BuiltinType {{.*}} 'int'
+  // CHECK:   |-ParmVarDecl {{.*}} 'S':'Basic::S'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (S, T) -> C' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'C' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'C'
+  // CHECK: |-ElaboratedType {{.*}} 'S' sugar dependent
+  // CHECK: | `-TemplateSpecializationType {{.*}} 'S' dependent S
+  // CHECK: |   `-TemplateArgument type 'T'
+  // CHECK: | `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: |   `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  

[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-26 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D139837#4449327 , @cor3ntin wrote:

> @ychen You probably want to update the description, i think it's updated (you 
> implemented ctad for parenthesized ctrs)

Thanks for the remainder, Corentin. Hopefully, this will be ready to be landed 
soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-26 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 534601.
ychen added a comment.

- remove extra headers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1246,7 +1246,7 @@
 
   Class template argument deduction for aggregates
   https://wg21.link/p1816r0;>P1816R0
-  No
+  Clang 17
 

 https://wg21.link/p2082r1;>P2082R1
Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -0,0 +1,364 @@
+// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace
+
+namespace Basic {
+  template struct A {
+T x;
+T y;
+  };
+
+  A a1 = {3.0, 4.0};
+  A a2 = {.x = 3.0, .y = 4.0};
+
+  A a3(3.0, 4.0);
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (T, T) -> A'
+  // CHECK: | |-ParmVarDecl {{.*}} 'T'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (double, double) -> Basic::A'
+  // CHECK:   |-TemplateArgument type 'double'
+  // CHECK:   | `-BuiltinType {{.*}} 'double'
+  // CHECK:   |-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK:   `-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK: FunctionProtoType {{.*}} 'auto (T, T) -> A' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'A'
+  // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: | `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  template  struct S { // expected-note 2 {{candidate}}
+T x;
+T y;
+  };
+
+  template  struct C { // expected-note 10 {{candidate}}
+S s;
+T t;
+  };
+
+  template  struct D { // expected-note 6 {{candidate}}
+S s;
+T t;
+  };
+
+  C c1 = {1, 2}; // expected-error {{no viable}}
+  C c2 = {1, 2, 3}; // expected-error {{no viable}}
+  C c3 = {{1u, 2u}, 3};
+
+  C c4(1, 2);// expected-error {{no viable}}
+  C c5(1, 2, 3); // expected-error {{no viable}}
+  C c6({1u, 2u}, 3);
+
+  D d1 = {1, 2}; // expected-error {{no viable}}
+  D d2 = {1, 2, 3};
+
+  D d3(1, 2); // expected-error {{no viable}}
+  // CTAD succeed but brace elision is not allowed for parenthesized aggregate init. 
+  D d4(1, 2, 3); // expected-error {{no viable}}
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (S, T) -> C'
+  // CHECK: | |-ParmVarDecl {{.*}} 'S':'S'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (S, int) -> Basic::C'
+  // CHECK:   |-TemplateArgument type 'int'
+  // CHECK:   | `-BuiltinType {{.*}} 'int'
+  // CHECK:   |-ParmVarDecl {{.*}} 'S':'Basic::S'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (S, T) -> C' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'C' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'C'
+  // CHECK: |-ElaboratedType {{.*}} 'S' sugar dependent
+  // CHECK: | `-TemplateSpecializationType {{.*}} 'S' dependent S
+  // CHECK: |   `-TemplateArgument type 'T'
+  // CHECK: | `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: |   `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} 

[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-22 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/include/clang/AST/DeclCXX.h:1987
+  void setDeductionCandidateKind(DeductionCandidateKind K) {
+FunctionDeclBits.DeductionCandidateKind = static_cast(K);
   }

shafik wrote:
> aaron.ballman wrote:
> > Er, seems a bit odd to cast an 8-bit type to a 64-bit type only to shove it 
> > into a 2-bit bit-field. I think `DeductionCandidateKind` should be an enum 
> > class whose underlying type is `int` and we cast to/from `int` as needed.
> It feels a bit weird that we are taking an enum w/ an underlying type of 
> `unsigned char` casting it to `int` and then placing it in an unsigned 
> bit-field. I don't have a better suggestion ATM but I wish we had something 
> better. 
I've changed it to casting to underlying type of `DeductionCandidate` so it has 
one less step of conversion.



Comment at: clang/lib/Sema/SemaInit.cpp:15
 #include "clang/AST/DeclObjC.h"
+#include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"

shafik wrote:
> I saw your adding headers. How did you figure out which ones were missing?
Added headers provide APIs for the new code. I guess many of them are included 
already indirectly (SmallVector for example). But I thought the best practice 
is not relying on that, so I added these.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-22 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 533674.
ychen marked 7 inline comments as done.
ychen added a comment.

- address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1246,7 +1246,7 @@
 
   Class template argument deduction for aggregates
   https://wg21.link/p1816r0;>P1816R0
-  No
+  Clang 17
 

 https://wg21.link/p2082r1;>P2082R1
Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -0,0 +1,364 @@
+// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace
+
+namespace Basic {
+  template struct A {
+T x;
+T y;
+  };
+
+  A a1 = {3.0, 4.0};
+  A a2 = {.x = 3.0, .y = 4.0};
+
+  A a3(3.0, 4.0);
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (T, T) -> A'
+  // CHECK: | |-ParmVarDecl {{.*}} 'T'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (double, double) -> Basic::A'
+  // CHECK:   |-TemplateArgument type 'double'
+  // CHECK:   | `-BuiltinType {{.*}} 'double'
+  // CHECK:   |-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK:   `-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK: FunctionProtoType {{.*}} 'auto (T, T) -> A' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'A'
+  // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: | `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  template  struct S { // expected-note 2 {{candidate}}
+T x;
+T y;
+  };
+
+  template  struct C { // expected-note 10 {{candidate}}
+S s;
+T t;
+  };
+
+  template  struct D { // expected-note 6 {{candidate}}
+S s;
+T t;
+  };
+
+  C c1 = {1, 2}; // expected-error {{no viable}}
+  C c2 = {1, 2, 3}; // expected-error {{no viable}}
+  C c3 = {{1u, 2u}, 3};
+
+  C c4(1, 2);// expected-error {{no viable}}
+  C c5(1, 2, 3); // expected-error {{no viable}}
+  C c6({1u, 2u}, 3);
+
+  D d1 = {1, 2}; // expected-error {{no viable}}
+  D d2 = {1, 2, 3};
+
+  D d3(1, 2); // expected-error {{no viable}}
+  // CTAD succeed but brace elision is not allowed for parenthesized aggregate init. 
+  D d4(1, 2, 3); // expected-error {{no viable}}
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (S, T) -> C'
+  // CHECK: | |-ParmVarDecl {{.*}} 'S':'S'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (S, int) -> Basic::C'
+  // CHECK:   |-TemplateArgument type 'int'
+  // CHECK:   | `-BuiltinType {{.*}} 'int'
+  // CHECK:   |-ParmVarDecl {{.*}} 'S':'Basic::S'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (S, T) -> C' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'C' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'C'
+  // CHECK: |-ElaboratedType {{.*}} 'S' sugar dependent
+  // CHECK: | `-TemplateSpecializationType {{.*}} 'S' dependent S
+  // CHECK: |   `-TemplateArgument type 'T'
+  // CHECK: | `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: |   `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // 

[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-09 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen marked an inline comment as done.
ychen added inline comments.



Comment at: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp:101
+
+  template  struct E {
+T t;

shafik wrote:
> I would also like to see this test:
> 
> ```
> template 
> struct I {
>   using type = T;
> };
> 
> template 
> struct E {
>   typename I::type i;
>   T t;
> };
> 
> E e1 = {1, 2}; // OK, E deduced
> ```
> 
> Since it is in the paper, this should cover it but it can't hurt.
Yep, just added this test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-09 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 530057.
ychen added a comment.

- add one extra test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1246,7 +1246,7 @@
 
   Class template argument deduction for aggregates
   https://wg21.link/p1816r0;>P1816R0
-  No
+  Clang 17
 

 https://wg21.link/p2082r1;>P2082R1
Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -0,0 +1,364 @@
+// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace
+
+namespace Basic {
+  template struct A {
+T x;
+T y;
+  };
+
+  A a1 = {3.0, 4.0};
+  A a2 = {.x = 3.0, .y = 4.0};
+
+  A a3(3.0, 4.0);
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (T, T) -> A'
+  // CHECK: | |-ParmVarDecl {{.*}} 'T'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (double, double) -> Basic::A'
+  // CHECK:   |-TemplateArgument type 'double'
+  // CHECK:   | `-BuiltinType {{.*}} 'double'
+  // CHECK:   |-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK:   `-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK: FunctionProtoType {{.*}} 'auto (T, T) -> A' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'A'
+  // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: | `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  template  struct S { // expected-note 2 {{candidate}}
+T x;
+T y;
+  };
+
+  template  struct C { // expected-note 10 {{candidate}}
+S s;
+T t;
+  };
+
+  template  struct D { // expected-note 6 {{candidate}}
+S s;
+T t;
+  };
+
+  C c1 = {1, 2}; // expected-error {{no viable}}
+  C c2 = {1, 2, 3}; // expected-error {{no viable}}
+  C c3 = {{1u, 2u}, 3};
+
+  C c4(1, 2);// expected-error {{no viable}}
+  C c5(1, 2, 3); // expected-error {{no viable}}
+  C c6({1u, 2u}, 3);
+
+  D d1 = {1, 2}; // expected-error {{no viable}}
+  D d2 = {1, 2, 3};
+
+  D d3(1, 2); // expected-error {{no viable}}
+  // CTAD succeed but brace elision is not allowed for parenthesized aggregate init. 
+  D d4(1, 2, 3); // expected-error {{no viable}}
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (S, T) -> C'
+  // CHECK: | |-ParmVarDecl {{.*}} 'S':'S'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (S, int) -> Basic::C'
+  // CHECK:   |-TemplateArgument type 'int'
+  // CHECK:   | `-BuiltinType {{.*}} 'int'
+  // CHECK:   |-ParmVarDecl {{.*}} 'S':'Basic::S'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (S, T) -> C' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'C' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'C'
+  // CHECK: |-ElaboratedType {{.*}} 'S' sugar dependent
+  // CHECK: | `-TemplateSpecializationType {{.*}} 'S' dependent S
+  // CHECK: |   `-TemplateArgument type 'T'
+  // CHECK: | `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: |   `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} 

[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-06 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D139837#4401134 , @cor3ntin wrote:

> I think this looks good but I'll let @aaron.ballman do the final approval.

Thanks for the review @cor3ntin.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-06 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:1059-1062
+case CodeSynthesisContext::BuildingDeductionGuides:
+  assert(
+  false &&
+  "failed building deduction guides, add meaningful diagnostics here");

cor3ntin wrote:
> ychen wrote:
> > aaron.ballman wrote:
> > > cor3ntin wrote:
> > > > This seems unfinished
> > > +1
> > I meant to keep this a future work since this path is dead until some 
> > errors could be thrown out of this context.  In the future, if errors 
> > happen during building deduction guides, this assertion failure could 
> > trigger at build time.
> In this case, maybe change the message
> assert(false && "unexpected deduction guide in instantiation stack") or 
> something along those lines.
Done. I've made it `llvm_unreachable` to catch the rare chances that users hit 
this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-06 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 528918.
ychen added a comment.

- address comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1246,7 +1246,7 @@
 
   Class template argument deduction for aggregates
   https://wg21.link/p1816r0;>P1816R0
-  No
+  Clang 17
 

 https://wg21.link/p2082r1;>P2082R1
Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -0,0 +1,333 @@
+// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace
+
+namespace Basic {
+  template struct A {
+T x;
+T y;
+  };
+
+  A a1 = {3.0, 4.0};
+  A a2 = {.x = 3.0, .y = 4.0};
+
+  A a3(3.0, 4.0);
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (T, T) -> A'
+  // CHECK: | |-ParmVarDecl {{.*}} 'T'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (double, double) -> Basic::A'
+  // CHECK:   |-TemplateArgument type 'double'
+  // CHECK:   | `-BuiltinType {{.*}} 'double'
+  // CHECK:   |-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK:   `-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK: FunctionProtoType {{.*}} 'auto (T, T) -> A' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'A'
+  // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: | `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  template  struct S { // expected-note 2 {{candidate}}
+T x;
+T y;
+  };
+
+  template  struct C { // expected-note 10 {{candidate}}
+S s;
+T t;
+  };
+
+  template  struct D { // expected-note 6 {{candidate}}
+S s;
+T t;
+  };
+
+  C c1 = {1, 2}; // expected-error {{no viable}}
+  C c2 = {1, 2, 3}; // expected-error {{no viable}}
+  C c3 = {{1u, 2u}, 3};
+
+  C c4(1, 2);// expected-error {{no viable}}
+  C c5(1, 2, 3); // expected-error {{no viable}}
+  C c6({1u, 2u}, 3);
+
+  D d1 = {1, 2}; // expected-error {{no viable}}
+  D d2 = {1, 2, 3};
+
+  D d3(1, 2); // expected-error {{no viable}}
+  // CTAD succeed but brace elision is not allowed for parenthesized aggregate init. 
+  D d4(1, 2, 3); // expected-error {{no viable}}
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (S, T) -> C'
+  // CHECK: | |-ParmVarDecl {{.*}} 'S':'S'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (S, int) -> Basic::C'
+  // CHECK:   |-TemplateArgument type 'int'
+  // CHECK:   | `-BuiltinType {{.*}} 'int'
+  // CHECK:   |-ParmVarDecl {{.*}} 'S':'Basic::S'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (S, T) -> C' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'C' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'C'
+  // CHECK: |-ElaboratedType {{.*}} 'S' sugar dependent
+  // CHECK: | `-TemplateSpecializationType {{.*}} 'S' dependent S
+  // CHECK: |   `-TemplateArgument type 'T'
+  // CHECK: | `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: |   `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} 

[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-04 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/include/clang/AST/DeclBase.h:1689
+/// (used during overload resolution).
+uint64_t DeductionCandidateKind : 2;
 

aaron.ballman wrote:
> Best not to give this the same name as a type (I don't care which one changes 
> names).
I've changed the type name and kept this as is.



Comment at: clang/include/clang/Sema/Sema.h:3992
+  OverloadCandidateParamOrder PO = {},
+  bool AggregateCandidateDeduction = false);
   void AddFunctionCandidates(const UnresolvedSetImpl ,

aaron.ballman wrote:
> We're up to 12 parameters for this function, five of which are `bool` 
> parameters... at some point, this probably needs to be refactored.
Agreed. I will keep my eye on it.



Comment at: clang/lib/Sema/SemaInit.cpp:504-510
   InitListChecker(Sema , const InitializedEntity , InitListExpr *IL,
   QualType , bool VerifyOnly, bool TreatUnavailableAsInvalid,
-  bool InOverloadResolution = false);
+  bool InOverloadResolution = false,
+  SmallVector *AggrDeductionCandidateParamTypes = 
nullptr);
+  InitListChecker(Sema , const InitializedEntity , InitListExpr *IL,
+  QualType ,
+  SmallVector )

aaron.ballman wrote:
> We shouldn't force the caller to use the same-sized SmallVector, right?
That's right.



Comment at: clang/lib/Sema/SemaInit.cpp:1036
 
+RecordDecl *InitListChecker::getRecordDecl(QualType DeclType) {
+  if (DeclType->isRecordType())

aaron.ballman wrote:
> Can we make this return a `const RecordDecl *` or does that run into viral 
> const issues?
"viral const issues". Deep somewhere else needs it non-const.



Comment at: clang/lib/Sema/SemaInit.cpp:1445-1447
+  //   brace elision is not considered for any aggregate element that has a
+  //   dependent non-array type or an array type with a value-dependent
+  //   bound

aaron.ballman wrote:
> Be sure to add test coverage for use of VLAs in C++ (we support it as an 
> extension).
`Array::a2` test case covers this.



Comment at: clang/lib/Sema/SemaTemplate.cpp:2576
+SourceLocation Loc) {
+  if (CXXRecordDecl *DefRecord =
+  cast(Template->getTemplatedDecl())->getDefinition()) {

aaron.ballman wrote:
> Something is amiss here. Either this should be using `dyn_cast` or it should 
> not be in an `if` statement (`cast` cannot fail; it asserts if it does).
It's the `getDefinition()` that may be null. I've hoist the cast out to make it 
obvious.



Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:1059-1062
+case CodeSynthesisContext::BuildingDeductionGuides:
+  assert(
+  false &&
+  "failed building deduction guides, add meaningful diagnostics here");

aaron.ballman wrote:
> cor3ntin wrote:
> > This seems unfinished
> +1
I meant to keep this a future work since this path is dead until some errors 
could be thrown out of this context.  In the future, if errors happen during 
building deduction guides, this assertion failure could trigger at build time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-04 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 528268.
ychen marked 14 inline comments as done.
ychen added a comment.

- address existing comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1246,7 +1246,7 @@
 
   Class template argument deduction for aggregates
   https://wg21.link/p1816r0;>P1816R0
-  No
+  Clang 17
 

 https://wg21.link/p2082r1;>P2082R1
Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -0,0 +1,333 @@
+// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace
+
+namespace Basic {
+  template struct A {
+T x;
+T y;
+  };
+
+  A a1 = {3.0, 4.0};
+  A a2 = {.x = 3.0, .y = 4.0};
+
+  A a3(3.0, 4.0);
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (T, T) -> A'
+  // CHECK: | |-ParmVarDecl {{.*}} 'T'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (double, double) -> Basic::A'
+  // CHECK:   |-TemplateArgument type 'double'
+  // CHECK:   | `-BuiltinType {{.*}} 'double'
+  // CHECK:   |-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK:   `-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK: FunctionProtoType {{.*}} 'auto (T, T) -> A' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'A'
+  // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: | `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  template  struct S { // expected-note 2 {{candidate}}
+T x;
+T y;
+  };
+
+  template  struct C { // expected-note 10 {{candidate}}
+S s;
+T t;
+  };
+
+  template  struct D { // expected-note 6 {{candidate}}
+S s;
+T t;
+  };
+
+  C c1 = {1, 2}; // expected-error {{no viable}}
+  C c2 = {1, 2, 3}; // expected-error {{no viable}}
+  C c3 = {{1u, 2u}, 3};
+
+  C c4(1, 2);// expected-error {{no viable}}
+  C c5(1, 2, 3); // expected-error {{no viable}}
+  C c6({1u, 2u}, 3);
+
+  D d1 = {1, 2}; // expected-error {{no viable}}
+  D d2 = {1, 2, 3};
+
+  D d3(1, 2); // expected-error {{no viable}}
+  // CTAD succeed but brace elision is not allowed for parenthesized aggregate init. 
+  D d4(1, 2, 3); // expected-error {{no viable}}
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (S, T) -> C'
+  // CHECK: | |-ParmVarDecl {{.*}} 'S':'S'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (S, int) -> Basic::C'
+  // CHECK:   |-TemplateArgument type 'int'
+  // CHECK:   | `-BuiltinType {{.*}} 'int'
+  // CHECK:   |-ParmVarDecl {{.*}} 'S':'Basic::S'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (S, T) -> C' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'C' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'C'
+  // CHECK: |-ElaboratedType {{.*}} 'S' sugar dependent
+  // CHECK: | `-TemplateSpecializationType {{.*}} 'S' dependent S
+  // CHECK: |   `-TemplateArgument type 'T'
+  // CHECK: | `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: |   `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 

[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-05-20 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 524045.
ychen added a comment.

- fix
- Address comments
- fix
- - adjust test check for Windows


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1246,7 +1246,7 @@
 
   Class template argument deduction for aggregates
   https://wg21.link/p1816r0;>P1816R0
-  No
+  Clang 17
 

 https://wg21.link/p2082r1;>P2082R1
Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -0,0 +1,332 @@
+// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace
+
+namespace Basic {
+  template struct A {
+T x;
+T y;
+  };
+
+  A a1 = {3.0, 4.0};
+  A a2 = {.x = 3.0, .y = 4.0};
+
+  A a3(3.0, 4.0);
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (T, T) -> A'
+  // CHECK: | |-ParmVarDecl {{.*}} 'T'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (double, double) -> Basic::A'
+  // CHECK:   |-TemplateArgument type 'double'
+  // CHECK:   | `-BuiltinType {{.*}} 'double'
+  // CHECK:   |-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK:   `-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK: FunctionProtoType {{.*}} 'auto (T, T) -> A' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'A'
+  // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: | `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  template  struct S { // expected-note 2 {{candidate}}
+T x;
+T y;
+  };
+
+  template  struct C { // expected-note 10 {{candidate}}
+S s;
+T t;
+  };
+
+  template  struct D { // expected-note 6 {{candidate}}
+S s;
+T t;
+  };
+
+  C c1 = {1, 2}; // expected-error {{no viable}}
+  C c2 = {1, 2, 3}; // expected-error {{no viable}}
+  C c3 = {{1u, 2u}, 3};
+
+  C c4(1, 2);// expected-error {{no viable}}
+  C c5(1, 2, 3); // expected-error {{no viable}}
+  C c6({1u, 2u}, 3);
+
+  D d1 = {1, 2}; // expected-error {{no viable}}
+  D d2 = {1, 2, 3};
+
+  D d3(1, 2); // expected-error {{no viable}}
+  // CTAD succeed but brace elision is not allowed for parenthesized aggregate init. 
+  D d4(1, 2, 3); // expected-error {{no viable}}
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (S, T) -> C'
+  // CHECK: | |-ParmVarDecl {{.*}} 'S':'S'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (S, int) -> Basic::C'
+  // CHECK:   |-TemplateArgument type 'int'
+  // CHECK:   | `-BuiltinType {{.*}} 'int'
+  // CHECK:   |-ParmVarDecl {{.*}} 'S':'Basic::S'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (S, T) -> C' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'C' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'C'
+  // CHECK: |-ElaboratedType {{.*}} 'S' sugar dependent
+  // CHECK: | `-TemplateSpecializationType {{.*}} 'S' dependent S
+  // CHECK: |   `-TemplateArgument type 'T'
+  // CHECK: | `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: |   `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  

[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-05-14 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 521978.
ychen added a comment.

- Fix bitfield on Windows


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1246,7 +1246,7 @@
 
   Class template argument deduction for aggregates
   https://wg21.link/p1816r0;>P1816R0
-  No
+  Clang 17
 

 https://wg21.link/p2082r1;>P2082R1
Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -0,0 +1,298 @@
+// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace
+
+namespace Basic {
+  template struct A {
+T x;
+T y;
+  };
+
+  A a1{3.0, 4.0};
+  A a2{.x = 3.0, .y = 4.0};
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (T, T) -> A'
+  // CHECK: | |-ParmVarDecl {{.*}} 'T'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (double, double) -> Basic::A'
+  // CHECK:   |-TemplateArgument type 'double'
+  // CHECK:   | `-BuiltinType {{.*}} 'double'
+  // CHECK:   |-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK:   `-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK: FunctionProtoType {{.*}} 'auto (T, T) -> A' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'A'
+  // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: | `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  template  struct S {
+T x;
+T y;
+  };
+
+  template  struct C { // expected-note 5 {{candidate}}
+S s;
+T t;
+  };
+
+  template  struct D { // expected-note 3 {{candidate}}
+S s;
+T t;
+  };
+
+  C c1 = {1, 2}; // expected-error {{no viable}}
+  C c2 = {1, 2, 3}; // expected-error {{no viable}}
+  C c3 = {{1u, 2u}, 3};
+
+  D d1 = {1, 2}; // expected-error {{no viable}}
+  D d2 = {1, 2, 3};
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (S, T) -> C'
+  // CHECK: | |-ParmVarDecl {{.*}} 'S':'S'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (S, int) -> Basic::C'
+  // CHECK:   |-TemplateArgument type 'int'
+  // CHECK:   | `-BuiltinType {{.*}} 'int'
+  // CHECK:   |-ParmVarDecl {{.*}} 'S':'Basic::S'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (S, T) -> C' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'C' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'C'
+  // CHECK: |-ElaboratedType {{.*}} 'S' sugar dependent
+  // CHECK: | `-TemplateSpecializationType {{.*}} 'S' dependent S
+  // CHECK: |   `-TemplateArgument type 'T'
+  // CHECK: | `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: |   `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit  'auto (int, int) -> D'
+  // CHECK:   |-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (int, int) -> D' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'D' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'D'
+  // CHECK: |-SubstTemplateTypeParmType {{.*}} 'int' sugar typename depth 0 index 0 

[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-05-13 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 521965.
ychen marked an inline comment as done.
ychen added a comment.

- add release notes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1246,7 +1246,7 @@
 
   Class template argument deduction for aggregates
   https://wg21.link/p1816r0;>P1816R0
-  No
+  Clang 17
 

 https://wg21.link/p2082r1;>P2082R1
Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -0,0 +1,298 @@
+// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace
+
+namespace Basic {
+  template struct A {
+T x;
+T y;
+  };
+
+  A a1{3.0, 4.0};
+  A a2{.x = 3.0, .y = 4.0};
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (T, T) -> A'
+  // CHECK: | |-ParmVarDecl {{.*}} 'T'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (double, double) -> Basic::A'
+  // CHECK:   |-TemplateArgument type 'double'
+  // CHECK:   | `-BuiltinType {{.*}} 'double'
+  // CHECK:   |-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK:   `-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK: FunctionProtoType {{.*}} 'auto (T, T) -> A' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'A'
+  // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: | `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  template  struct S {
+T x;
+T y;
+  };
+
+  template  struct C { // expected-note 5 {{candidate}}
+S s;
+T t;
+  };
+
+  template  struct D { // expected-note 3 {{candidate}}
+S s;
+T t;
+  };
+
+  C c1 = {1, 2}; // expected-error {{no viable}}
+  C c2 = {1, 2, 3}; // expected-error {{no viable}}
+  C c3 = {{1u, 2u}, 3};
+
+  D d1 = {1, 2}; // expected-error {{no viable}}
+  D d2 = {1, 2, 3};
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (S, T) -> C'
+  // CHECK: | |-ParmVarDecl {{.*}} 'S':'S'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (S, int) -> Basic::C'
+  // CHECK:   |-TemplateArgument type 'int'
+  // CHECK:   | `-BuiltinType {{.*}} 'int'
+  // CHECK:   |-ParmVarDecl {{.*}} 'S':'Basic::S'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (S, T) -> C' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'C' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'C'
+  // CHECK: |-ElaboratedType {{.*}} 'S' sugar dependent
+  // CHECK: | `-TemplateSpecializationType {{.*}} 'S' dependent S
+  // CHECK: |   `-TemplateArgument type 'T'
+  // CHECK: | `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: |   `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit  'auto (int, int) -> D'
+  // CHECK:   |-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (int, int) -> D' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'D' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'D'
+  // CHECK: |-SubstTemplateTypeParmType {{.*}} 

[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-05-13 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 521964.
ychen added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

Files:
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1246,7 +1246,7 @@
 
   Class template argument deduction for aggregates
   https://wg21.link/p1816r0;>P1816R0
-  No
+  Clang 17
 

 https://wg21.link/p2082r1;>P2082R1
Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -0,0 +1,298 @@
+// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace
+
+namespace Basic {
+  template struct A {
+T x;
+T y;
+  };
+
+  A a1{3.0, 4.0};
+  A a2{.x = 3.0, .y = 4.0};
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (T, T) -> A'
+  // CHECK: | |-ParmVarDecl {{.*}} 'T'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (double, double) -> Basic::A'
+  // CHECK:   |-TemplateArgument type 'double'
+  // CHECK:   | `-BuiltinType {{.*}} 'double'
+  // CHECK:   |-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK:   `-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK: FunctionProtoType {{.*}} 'auto (T, T) -> A' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'A'
+  // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: | `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  template  struct S {
+T x;
+T y;
+  };
+
+  template  struct C { // expected-note 5 {{candidate}}
+S s;
+T t;
+  };
+
+  template  struct D { // expected-note 3 {{candidate}}
+S s;
+T t;
+  };
+
+  C c1 = {1, 2}; // expected-error {{no viable}}
+  C c2 = {1, 2, 3}; // expected-error {{no viable}}
+  C c3 = {{1u, 2u}, 3};
+
+  D d1 = {1, 2}; // expected-error {{no viable}}
+  D d2 = {1, 2, 3};
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (S, T) -> C'
+  // CHECK: | |-ParmVarDecl {{.*}} 'S':'S'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (S, int) -> Basic::C'
+  // CHECK:   |-TemplateArgument type 'int'
+  // CHECK:   | `-BuiltinType {{.*}} 'int'
+  // CHECK:   |-ParmVarDecl {{.*}} 'S':'Basic::S'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (S, T) -> C' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'C' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'C'
+  // CHECK: |-ElaboratedType {{.*}} 'S' sugar dependent
+  // CHECK: | `-TemplateSpecializationType {{.*}} 'S' dependent S
+  // CHECK: |   `-TemplateArgument type 'T'
+  // CHECK: | `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: |   `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit  'auto (int, int) -> D'
+  // CHECK:   |-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (int, int) -> D' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'D' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'D'
+  // CHECK: |-SubstTemplateTypeParmType {{.*}} 'int' sugar typename depth 0 index 0 T
+  // CHECK: | |-ClassTemplateSpecialization 

[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-05-13 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 521963.
ychen marked 3 inline comments as done.
ychen added a comment.

Address all comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp

Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -358,15 +358,14 @@
 for (TemplateArgument::pack_iterator
  XA = X.pack_begin(),
  XAEnd = X.pack_end(), YA = Y.pack_begin(), YAEnd = Y.pack_end();
- XA != XAEnd; ++XA) {
+ XA != XAEnd; ++XA, ++YA) {
   if (YA != YAEnd) {
-  TemplateArgument Merged = checkDeducedTemplateArguments(
-  Context, DeducedTemplateArgument(*XA, X.wasDeducedFromArrayBound()),
-  DeducedTemplateArgument(*YA, Y.wasDeducedFromArrayBound()));
-  if (Merged.isNull() && !(XA->isNull() && YA->isNull()))
-return DeducedTemplateArgument();
-  NewPack.push_back(Merged);
-++YA;
+TemplateArgument Merged = checkDeducedTemplateArguments(
+Context, DeducedTemplateArgument(*XA, X.wasDeducedFromArrayBound()),
+DeducedTemplateArgument(*YA, Y.wasDeducedFromArrayBound()));
+if (Merged.isNull() && !(XA->isNull() && YA->isNull()))
+  return DeducedTemplateArgument();
+NewPack.push_back(Merged);
   } else {
 NewPack.push_back(*XA);
   }
@@ -993,7 +992,7 @@
   TemplateDeductionInfo 
   unsigned PackElements = 0;
   bool IsPartiallyExpanded = false;
-  bool DeducePackIfNotAlreadyDeduced;
+  bool DeducePackIfNotAlreadyDeduced = false;
   /// The number of expansions, if we have a fully-expanded pack in this scope.
   std::optional FixedNumExpansions;
 
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -2590,11 +2590,11 @@
 
   // In case we were expanding a pack when we attempted to declare deduction
   // guides, turn off pack expansion for everything we're about to do.
-  ArgumentPackSubstitutionIndexRAII SubstIndex(*this, -1);
+  ArgumentPackSubstitutionIndexRAII SubstIndex(*this,
+   /*NewSubstitutionIndex=*/-1);
   // Create a template instantiation record to track the "instantiation" of
   // constructors into deduction guides.
-  // FIXME: Add a kind for this to give more meaningful diagnostics. But can
-  // this substitution process actually fail?
+  // FIXME: Add a kind for this to give more meaningful diagnostics.
   InstantiatingTemplate BuildingDeductionGuides(*this, Loc, Template);
   if (BuildingDeductionGuides.isInvalid())
 return nullptr;
@@ -2632,8 +2632,7 @@
   ArgumentPackSubstitutionIndexRAII SubstIndex(*this, -1);
   // Create a template instantiation record to track the "instantiation" of
   // constructors into deduction guides.
-  // FIXME: Add a kind for this to give more meaningful diagnostics. But can
-  // this substitution process actually fail?
+  // FIXME: Add a kind for this to give more meaningful diagnostics.
   InstantiatingTemplate BuildingDeductionGuides(*this, Loc, Template);
   if (BuildingDeductionGuides.isInvalid())
 return;
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -7383,7 +7383,7 @@
   AddOverloadCandidate(
   Specialization, FoundDecl, Args, CandidateSet, SuppressUserConversions,
   PartialOverloading, AllowExplicit,
-  /*AllowExplicitConversions*/ false, IsADLCandidate, Conversions, PO,
+  /*AllowExplicitConversions=*/false, IsADLCandidate, Conversions, PO,
   Info.AggregateDeductionCandidateHasMismatchedArity);
 }
 
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -10,7 +10,6 @@
 //
 //===--===//
 
-#include "clang/AST/APValue.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/Expr.h"
@@ -10650,7 +10649,7 @@
   return;
 
 if (!AllowAggregateDeductionCandidate &&
-GD->isAggregateDeductionCandidate())
+GD->getDeductionCandidateKind() == DeductionCandidateKind::Aggregate)
   return;
 
 // C++ [over.match.list]p1.2: (second phase list initialization)
@@ -10674,10 +10673,10 @@
   TmpInits.push_back(DI->getInit());
 else
   TmpInits.push_back(E);
-  AddTemplateOverloadCandidate(TD, 

[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-05-13 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen marked 9 inline comments as done.
ychen added inline comments.



Comment at: clang/lib/Sema/SemaInit.cpp:10338
+Context.getRValueReferenceType(ElementTypes[i]);
+  else if (isa(ListInit->getInit(i)))
+// This deviates from the wording which is incorrect.

cor3ntin wrote:
> I think we need to support `A{("Hello")};` so we probably need to get rid of 
> parentheses (maybe other implicit nodes?)
Agreed. Fixed.



Comment at: clang/lib/Sema/SemaTemplate.cpp:2590-2591
+  // constructors into deduction guides.
+  // FIXME: Add a kind for this to give more meaningful diagnostics. But can
+  // this substitution process actually fail?
+  InstantiatingTemplate BuildingDeductionGuides(*this, Loc, Template);

cor3ntin wrote:
> Maybe we should have an asserton !isInvalid then?
Looked at this a little bit more. It can fail (D46446). So I updated the 
comments in a few places.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:368
   NewPack.push_back(Merged);
+++YA;
+  } else {

cor3ntin wrote:
> I think you can do that in the for loop as it was before
Done


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-05-11 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

Sorry for the long delay guys. I'll update the patch this weekend.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126341: Order implicitly instantiated global variable's initializer by the reverse instantiation order

2023-03-10 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen abandoned this revision.
ychen added a comment.

Superseded by  D127233 , D127259 
, rG7f8d844df5e9 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126341

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127259: [CodeGen] guarantee templated static variables are initialized in the reverse instantiation order

2023-03-03 Thread Yuanfang Chen 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 rGe423885e272c: [CodeGen] guarantee templated static variables 
are initialized in the reverse… (authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127259

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp

Index: clang/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp
===
--- clang/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp
+++ clang/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp
@@ -29,32 +29,56 @@
 // ALL: @_ZN1AIbE1aE ={{.*}} global i32 10
 template<> int A::a = 10;
 
-// ALL: @llvm.global_ctors = appending global [8 x { i32, ptr, ptr }]
+// ALL: @llvm.global_ctors = appending global [16 x { i32, ptr, ptr }]
 
-// ELF: [{ i32, ptr, ptr } { i32 65535, ptr @[[unordered1:[^,]*]], ptr @_ZN1AIsE1aE },
-// MACHO: [{ i32, ptr, ptr } { i32 65535, ptr @[[unordered1:[^,]*]], ptr null },
+// ELF:  [{ i32, ptr, ptr } { i32 65535, ptr @[[unordered:[^,]*]], ptr @_ZN1AIsE1aE },
+// MACHO: [{ i32, ptr, ptr } { i32 65535, ptr @[[unordered:[^,]*]], ptr null },
 
-// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered2:[^,]*]], ptr @_Z1xIsE },
-// MACHO:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered2:[^,]*]], ptr null },
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered7:[^,]*]], ptr @_Z1xIsE },
+// MACHO:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered7:[^,]*]], ptr null },
 
-// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered3:[^,]*]], ptr @_ZN2ns1aIiE1iE },
-// MACHO:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered3:[^,]*]], ptr null },
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered10:[^,]*]], ptr @_ZN2ns1aIiE1iE },
+// MACHO:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered10:[^,]*]], ptr null },
 
-// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered4:[^,]*]], ptr @_ZN2ns1b1iIiEE },
-// MACHO:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered4:[^,]*]], ptr null },
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered11:[^,]*]], ptr @_ZN2ns1b1iIiEE },
+// MACHO:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered11:[^,]*]], ptr null },
 
-// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered5:[^,]*]], ptr @_ZN1AIvE1aE },
-// MACHO:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered5:[^,]*]], ptr null },
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered14:[^,]*]], ptr @_ZN1AIvE1aE },
+// MACHO:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered14:[^,]*]], ptr null },
 
-// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered6:[^,]*]], ptr @_Z1xIcE },
-// MACHO:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered6:[^,]*]], ptr null },
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered15:[^,]*]], ptr @_Z1xIcE },
+// MACHO:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered15:[^,]*]], ptr null },
 
-// ALL:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered7:[^,]*]], ptr null },
+// ALL:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered16:[^,]*]], ptr null },
+
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered19:[^,]*]], ptr @_ZN3FibILi2EE1aE },
+// MACHO: { i32, ptr, ptr } { i32 65535, ptr @[[unordered19:[^,]*]], ptr null },
+
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered18:[^,]*]], ptr @_ZN3FibILi3EE1aE },
+// MACHO: { i32, ptr, ptr } { i32 65535, ptr @[[unordered18:[^,]*]], ptr null },
+
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered20:[^,]*]], ptr @_ZN3FibILi4EE1aE },
+// MACHO: { i32, ptr, ptr } { i32 65535, ptr @[[unordered20:[^,]*]], ptr null },
+
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered17:[^,]*]], ptr @_ZN3FibILi5EE1aE },
+// MACHO: { i32, ptr, ptr } { i32 65535, ptr @[[unordered17:[^,]*]], ptr null },
+
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered23:[^,]*]], ptr @_ZN4Fib2ILi2EE1aE },
+// MACHO: { i32, ptr, ptr } { i32 65535, ptr @[[unordered23:[^,]*]], ptr null },
+
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered24:[^,]*]], ptr @_ZN4Fib2ILi3EE1aE },
+// MACHO: { i32, ptr, ptr } { i32 65535, ptr @[[unordered24:[^,]*]], ptr null },
+
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered22:[^,]*]], ptr @_ZN4Fib2ILi4EE1aE },
+// MACHO: { i32, ptr, ptr } { i32 65535, ptr @[[unordered22:[^,]*]], ptr null },
+
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered21:[^,]*]], ptr @_ZN4Fib2ILi5EE1aE },
+// MACHO: { i32, ptr, ptr } { i32 65535, ptr @[[unordered21:[^,]*]], ptr null }, 
 
 // ALL:  { i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__sub_I_static_member_variable_explicit_specialization.cpp, ptr null }]
 
 /// llvm.used ensures SHT_INIT_ARRAY in a section group cannot be GCed.
-// ELF: @llvm.used = appending global [6 x ptr] [ptr 

[PATCH] D127259: [CodeGen] guarantee templated static variables are initialized in the reverse instantiation order

2023-03-03 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 502068.
ychen added a comment.
This revision is now accepted and ready to land.

- rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127259

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp

Index: clang/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp
===
--- clang/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp
+++ clang/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp
@@ -29,32 +29,56 @@
 // ALL: @_ZN1AIbE1aE ={{.*}} global i32 10
 template<> int A::a = 10;
 
-// ALL: @llvm.global_ctors = appending global [8 x { i32, ptr, ptr }]
+// ALL: @llvm.global_ctors = appending global [16 x { i32, ptr, ptr }]
 
-// ELF: [{ i32, ptr, ptr } { i32 65535, ptr @[[unordered1:[^,]*]], ptr @_ZN1AIsE1aE },
-// MACHO: [{ i32, ptr, ptr } { i32 65535, ptr @[[unordered1:[^,]*]], ptr null },
+// ELF:  [{ i32, ptr, ptr } { i32 65535, ptr @[[unordered:[^,]*]], ptr @_ZN1AIsE1aE },
+// MACHO: [{ i32, ptr, ptr } { i32 65535, ptr @[[unordered:[^,]*]], ptr null },
 
-// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered2:[^,]*]], ptr @_Z1xIsE },
-// MACHO:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered2:[^,]*]], ptr null },
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered7:[^,]*]], ptr @_Z1xIsE },
+// MACHO:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered7:[^,]*]], ptr null },
 
-// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered3:[^,]*]], ptr @_ZN2ns1aIiE1iE },
-// MACHO:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered3:[^,]*]], ptr null },
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered10:[^,]*]], ptr @_ZN2ns1aIiE1iE },
+// MACHO:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered10:[^,]*]], ptr null },
 
-// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered4:[^,]*]], ptr @_ZN2ns1b1iIiEE },
-// MACHO:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered4:[^,]*]], ptr null },
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered11:[^,]*]], ptr @_ZN2ns1b1iIiEE },
+// MACHO:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered11:[^,]*]], ptr null },
 
-// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered5:[^,]*]], ptr @_ZN1AIvE1aE },
-// MACHO:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered5:[^,]*]], ptr null },
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered14:[^,]*]], ptr @_ZN1AIvE1aE },
+// MACHO:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered14:[^,]*]], ptr null },
 
-// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered6:[^,]*]], ptr @_Z1xIcE },
-// MACHO:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered6:[^,]*]], ptr null },
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered15:[^,]*]], ptr @_Z1xIcE },
+// MACHO:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered15:[^,]*]], ptr null },
 
-// ALL:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered7:[^,]*]], ptr null },
+// ALL:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered16:[^,]*]], ptr null },
+
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered19:[^,]*]], ptr @_ZN3FibILi2EE1aE },
+// MACHO: { i32, ptr, ptr } { i32 65535, ptr @[[unordered19:[^,]*]], ptr null },
+
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered18:[^,]*]], ptr @_ZN3FibILi3EE1aE },
+// MACHO: { i32, ptr, ptr } { i32 65535, ptr @[[unordered18:[^,]*]], ptr null },
+
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered20:[^,]*]], ptr @_ZN3FibILi4EE1aE },
+// MACHO: { i32, ptr, ptr } { i32 65535, ptr @[[unordered20:[^,]*]], ptr null },
+
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered17:[^,]*]], ptr @_ZN3FibILi5EE1aE },
+// MACHO: { i32, ptr, ptr } { i32 65535, ptr @[[unordered17:[^,]*]], ptr null },
+
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered23:[^,]*]], ptr @_ZN4Fib2ILi2EE1aE },
+// MACHO: { i32, ptr, ptr } { i32 65535, ptr @[[unordered23:[^,]*]], ptr null },
+
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered24:[^,]*]], ptr @_ZN4Fib2ILi3EE1aE },
+// MACHO: { i32, ptr, ptr } { i32 65535, ptr @[[unordered24:[^,]*]], ptr null },
+
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered22:[^,]*]], ptr @_ZN4Fib2ILi4EE1aE },
+// MACHO: { i32, ptr, ptr } { i32 65535, ptr @[[unordered22:[^,]*]], ptr null },
+
+// ELF:  { i32, ptr, ptr } { i32 65535, ptr @[[unordered21:[^,]*]], ptr @_ZN4Fib2ILi5EE1aE },
+// MACHO: { i32, ptr, ptr } { i32 65535, ptr @[[unordered21:[^,]*]], ptr null }, 
 
 // ALL:  { i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__sub_I_static_member_variable_explicit_specialization.cpp, ptr null }]
 
 /// llvm.used ensures SHT_INIT_ARRAY in a section group cannot be GCed.
-// ELF: @llvm.used = appending global [6 x ptr] [ptr @_ZN1AIsE1aE, ptr @_Z1xIsE, ptr @_ZN2ns1aIiE1iE, ptr @_ZN2ns1b1iIiEE, ptr @_ZN1AIvE1aE, ptr @_Z1xIcE]
+// ELF: @llvm.used = appending global 

[PATCH] D127259: [CodeGen] guarantee templated static variables are initialized in the reverse instantiation order

2023-03-03 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D127259#4156314 , @erichkeane 
wrote:

> I don't see much compile-time concerns myself,

Indeed. 
http://llvm-compile-time-tracker.com/compare.php?from=54faf22f7b947464a070669711100211e87f3ea8=ad87d0dbd44f3a8f66c31fa9b731aea34c8fe64d=instructions:u


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127259

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-01-23 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D139837#4067208 , @ayzhao wrote:

> Thanks for your effort on this!
>
> FYI I landed parenthesized aggregate initialization in D141546 
> , so CTAD for that feature should no longer 
> be blocked.

Thanks for letting me know. Considering the existing reviews, I'll create a 
separate patch for the parenthesized expression-list support.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2022-12-17 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 483735.
ychen added a comment.

- update cxx_status.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

Files:
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1241,7 +1241,7 @@
 
   Class template argument deduction for aggregates
   https://wg21.link/p1816r0;>P1816R0
-  No
+  Clang 16
 

 https://wg21.link/p2082r1;>P2082R1
Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -0,0 +1,297 @@
+// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace
+
+namespace Basic {
+  template struct A {
+T x;
+T y;
+  };
+
+  A a1{3.0, 4.0};
+  A a2{.x = 3.0, .y = 4.0};
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (T, T) -> A'
+  // CHECK: | |-ParmVarDecl {{.*}} 'T'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (double, double) -> Basic::A'
+  // CHECK:   |-TemplateArgument type 'double'
+  // CHECK:   | `-BuiltinType {{.*}} 'double'
+  // CHECK:   |-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK:   `-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK: FunctionProtoType {{.*}} 'auto (T, T) -> A' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'A'
+  // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: | `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  template  struct S {
+T x;
+T y;
+  };
+
+  template  struct C { // expected-note 5 {{candidate}}
+S s;
+T t;
+  };
+
+  template  struct D { // expected-note 3 {{candidate}}
+S s;
+T t;
+  };
+
+  C c1 = {1, 2}; // expected-error {{no viable}}
+  C c2 = {1, 2, 3}; // expected-error {{no viable}}
+  C c3 = {{1u, 2u}, 3};
+
+  D d1 = {1, 2}; // expected-error {{no viable}}
+  D d2 = {1, 2, 3};
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (S, T) -> C'
+  // CHECK: | |-ParmVarDecl {{.*}} 'S':'S'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (S, int) -> Basic::C'
+  // CHECK:   |-TemplateArgument type 'int'
+  // CHECK:   | `-BuiltinType {{.*}} 'int'
+  // CHECK:   |-ParmVarDecl {{.*}} 'S':'Basic::S'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (S, T) -> C' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'C' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'C'
+  // CHECK: |-ElaboratedType {{.*}} 'S' sugar dependent
+  // CHECK: | `-TemplateSpecializationType {{.*}} 'S' dependent S
+  // CHECK: |   `-TemplateArgument type 'T'
+  // CHECK: | `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: |   `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit  'auto (int, int) -> D'
+  // CHECK:   |-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (int, int) -> D' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'D' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'D'
+  // CHECK: |-SubstTemplateTypeParmType {{.*}} 'int' sugar typename depth 0 index 0 T
+  // CHECK: | 

[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2022-12-12 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D139837#3989814 , @cor3ntin wrote:

> Hey. Thanks a lot for working on this.
> I did a first pass, looking at mostly style issues, looking at conformance 
> will probably take me a lot more time, but i think this looks pretty good 
> overall

Thanks for the quick fist-pass review. Appreciate it.




Comment at: clang/include/clang/AST/DeclCXX.h:1911
   setRangeEnd(EndLocation);
-setIsCopyDeductionCandidate(false);
+setDeductionCandidateKind(DeductionCandidateKind::Normal);
   }

cor3ntin wrote:
> I'm wondering if the constructor should take a `DeductionCandidateKind` 
> defaulted to normal here. All the places where it's set seem to be 
> immediately after construction.
That's true indeed. The awkward aspect is that the 
`CXXDeductionGuideDecl::Create` call is far from `setDeductionCandidateKind`; 
making `CXXDeductionGuideDecl::Create` takes a `DeductionCandidateKind` would 
several other less related functions takes `DeductionCandidateKind` also.



Comment at: clang/include/clang/AST/DeclCXX.h:1953-1959
   bool isCopyDeductionCandidate() const {
-return FunctionDeclBits.IsCopyDeductionCandidate;
+return getDeductionCandidateKind() == DeductionCandidateKind::Copy;
+  }
+
+  bool isAggregateDeductionCandidate() const {
+return getDeductionCandidateKind() == DeductionCandidateKind::Aggregate;
   }

cor3ntin wrote:
> I'm not sure how useful these things are, isAggregateDeductionCandidate is 
> only used once
I meant to make it consistent with `isCopyDeductionCandidate` which is also 
used once. Maybe remove both `isCopyDeductionCandidate` and 
`isAggregateDeductionCandidate`?



Comment at: clang/lib/Sema/SemaInit.cpp:312
   NoInitExpr *DummyExpr = nullptr;
+  SmallVector *AggrDeductionCandidateParamTypes = nullptr;
 

cor3ntin wrote:
> I think using optional here would make more sense, I guess that's why you 
> included it.
> Should it be SmallVectorImpl, such that only the caller has to bake in a size?
I meant to make `AggrDeductionCandidateParamTypes` a byref semantic like 
`FullyStructuredList`. So the  `InitListChecker` populates them as a 
side-effect. Using optional means the `InitListChecker` owes the deduced types 
which should work too but seems weird to me. 



Comment at: clang/lib/Sema/SemaInit.cpp:1098-1099
 maxElements = T->castAs()->getNumElements();
+  else if (T->isDependentType())
+maxElements = 1;
   else

cor3ntin wrote:
> Can you had a comment about that case? I'm not sure i understand what 
> scenario we are handling
Good point. On second thought, I think this is not needed. This function 
shouldn't accept dependent types.



Comment at: clang/lib/Sema/SemaInit.cpp:2167-2168
   // If we have any base classes, they are initialized prior to the fields.
-  for (auto  : Bases) {
+  for (auto I = Bases.begin(), E = Bases.end(); I != E; ++I) {
+auto  = *I;
 Expr *Init = Index < IList->getNumInits() ? IList->getInit(Index) : 
nullptr;

cor3ntin wrote:
> Maybe using `enumerate` + a range for loop here would be cleaner?
Using the iterator to test for the last element is easier. The index produced 
by `enumerate` would need to produce an iterator nevertheless.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2022-12-12 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 482331.
ychen marked 2 inline comments as done.
ychen added a comment.

- Address Corentin's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

Files:
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaTemplate/aggregate-deduction-candidate.cpp

Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -0,0 +1,297 @@
+// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace
+
+namespace Basic {
+  template struct A {
+T x;
+T y;
+  };
+
+  A a1{3.0, 4.0};
+  A a2{.x = 3.0, .y = 4.0};
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (T, T) -> A'
+  // CHECK: | |-ParmVarDecl {{.*}} 'T'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (double, double) -> Basic::A'
+  // CHECK:   |-TemplateArgument type 'double'
+  // CHECK:   | `-BuiltinType {{.*}} 'double'
+  // CHECK:   |-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK:   `-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK: FunctionProtoType {{.*}} 'auto (T, T) -> A' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'A'
+  // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: | `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  template  struct S {
+T x;
+T y;
+  };
+
+  template  struct C { // expected-note 5 {{candidate}}
+S s;
+T t;
+  };
+
+  template  struct D { // expected-note 3 {{candidate}}
+S s;
+T t;
+  };
+
+  C c1 = {1, 2}; // expected-error {{no viable}}
+  C c2 = {1, 2, 3}; // expected-error {{no viable}}
+  C c3 = {{1u, 2u}, 3};
+
+  D d1 = {1, 2}; // expected-error {{no viable}}
+  D d2 = {1, 2, 3};
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (S, T) -> C'
+  // CHECK: | |-ParmVarDecl {{.*}} 'S':'S'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (S, int) -> Basic::C'
+  // CHECK:   |-TemplateArgument type 'int'
+  // CHECK:   | `-BuiltinType {{.*}} 'int'
+  // CHECK:   |-ParmVarDecl {{.*}} 'S':'Basic::S'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (S, T) -> C' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'C' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'C'
+  // CHECK: |-ElaboratedType {{.*}} 'S' sugar dependent
+  // CHECK: | `-TemplateSpecializationType {{.*}} 'S' dependent S
+  // CHECK: |   `-TemplateArgument type 'T'
+  // CHECK: | `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: |   `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit  'auto (int, int) -> D'
+  // CHECK:   |-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (int, int) -> D' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'D' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'D'
+  // CHECK: |-SubstTemplateTypeParmType {{.*}} 'int' sugar typename depth 0 index 0 T
+  // CHECK: | |-ClassTemplateSpecialization {{.*}} 'S'
+  // CHECK: | `-BuiltinType {{.*}} 'int'
+  // CHECK: `-SubstTemplateTypeParmType {{.*}} 'int' sugar typename depth 0 index 0 T
+  // CHECK:   |-ClassTemplateSpecialization {{.*}} 'S'
+  // CHECK:   `-BuiltinType {{.*}} 'int'
+
+  template  struct E {
+T t;
+decltype(t) t2;
+  };
+
+  E e1 = {1, 2};
+
+  // 

[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2022-12-12 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 482088.
ychen added a comment.

format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

Files:
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaTemplate/aggregate-deduction-candidate.cpp

Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -0,0 +1,297 @@
+// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace
+
+namespace Basic {
+  template struct A {
+T x;
+T y;
+  };
+
+  A a1{3.0, 4.0};
+  A a2{.x = 3.0, .y = 4.0};
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (T, T) -> A'
+  // CHECK: | |-ParmVarDecl {{.*}} 'T'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (double, double) -> Basic::A'
+  // CHECK:   |-TemplateArgument type 'double'
+  // CHECK:   | `-BuiltinType {{.*}} 'double'
+  // CHECK:   |-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK:   `-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK: FunctionProtoType {{.*}} 'auto (T, T) -> A' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'A'
+  // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: | `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  template  struct S {
+T x;
+T y;
+  };
+
+  template  struct C { // expected-note 5 {{candidate}}
+S s;
+T t;
+  };
+
+  template  struct D { // expected-note 3 {{candidate}}
+S s;
+T t;
+  };
+
+  C c1 = {1, 2}; // expected-error {{no viable}}
+  C c2 = {1, 2, 3}; // expected-error {{no viable}}
+  C c3 = {{1u, 2u}, 3};
+
+  D d1 = {1, 2}; // expected-error {{no viable}}
+  D d2 = {1, 2, 3};
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (S, T) -> C'
+  // CHECK: | |-ParmVarDecl {{.*}} 'S':'S'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (S, int) -> Basic::C'
+  // CHECK:   |-TemplateArgument type 'int'
+  // CHECK:   | `-BuiltinType {{.*}} 'int'
+  // CHECK:   |-ParmVarDecl {{.*}} 'S':'Basic::S'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (S, T) -> C' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'C' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'C'
+  // CHECK: |-ElaboratedType {{.*}} 'S' sugar dependent
+  // CHECK: | `-TemplateSpecializationType {{.*}} 'S' dependent S
+  // CHECK: |   `-TemplateArgument type 'T'
+  // CHECK: | `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: |   `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit  'auto (int, int) -> D'
+  // CHECK:   |-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (int, int) -> D' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'D' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'D'
+  // CHECK: |-SubstTemplateTypeParmType {{.*}} 'int' sugar typename depth 0 index 0 T
+  // CHECK: | |-ClassTemplateSpecialization {{.*}} 'S'
+  // CHECK: | `-BuiltinType {{.*}} 'int'
+  // CHECK: `-SubstTemplateTypeParmType {{.*}} 'int' sugar typename depth 0 index 0 T
+  // CHECK:   |-ClassTemplateSpecialization {{.*}} 'S'
+  // CHECK:   `-BuiltinType {{.*}} 'int'
+
+  template  struct E {
+T t;
+decltype(t) t2;
+  };
+
+  E e1 = {1, 2};
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} 

[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2022-12-12 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added reviewers: aaron.ballman, erichkeane, rsmith.
Herald added a subscriber: martong.
Herald added a reviewer: shafik.
Herald added a project: All.
ychen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

except that parenthesized expression-list support is left as TODO since
it depends on D129531 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139837

Files:
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaTemplate/aggregate-deduction-candidate.cpp

Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp
@@ -0,0 +1,297 @@
+// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace
+
+namespace Basic {
+  template struct A {
+T x;
+T y;
+  };
+
+  A a1{3.0, 4.0};
+  A a2{.x = 3.0, .y = 4.0};
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (T, T) -> A'
+  // CHECK: | |-ParmVarDecl {{.*}} 'T'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (double, double) -> Basic::A'
+  // CHECK:   |-TemplateArgument type 'double'
+  // CHECK:   | `-BuiltinType {{.*}} 'double'
+  // CHECK:   |-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK:   `-ParmVarDecl {{.*}} 'double':'double'
+  // CHECK: FunctionProtoType {{.*}} 'auto (T, T) -> A' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'A'
+  // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: | `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  template  struct S {
+T x;
+T y;
+  };
+
+  template  struct C { // expected-note 5 {{candidate}}
+S s;
+T t;
+  };
+
+  template  struct D { // expected-note 3 {{candidate}}
+S s;
+T t;
+  };
+
+  C c1 = {1, 2}; // expected-error {{no viable}}
+  C c2 = {1, 2, 3}; // expected-error {{no viable}}
+  C c3 = {{1u, 2u}, 3};
+
+  D d1 = {1, 2}; // expected-error {{no viable}}
+  D d2 = {1, 2, 3};
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit  'auto (S, T) -> C'
+  // CHECK: | |-ParmVarDecl {{.*}} 'S':'S'
+  // CHECK: | `-ParmVarDecl {{.*}} 'T'
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used  'auto (S, int) -> Basic::C'
+  // CHECK:   |-TemplateArgument type 'int'
+  // CHECK:   | `-BuiltinType {{.*}} 'int'
+  // CHECK:   |-ParmVarDecl {{.*}} 'S':'Basic::S'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (S, T) -> C' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'C' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'C'
+  // CHECK: |-ElaboratedType {{.*}} 'S' sugar dependent
+  // CHECK: | `-TemplateSpecializationType {{.*}} 'S' dependent S
+  // CHECK: |   `-TemplateArgument type 'T'
+  // CHECK: | `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK: |   `-TemplateTypeParm {{.*}} 'T'
+  // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0
+  // CHECK:   `-TemplateTypeParm {{.*}} 'T'
+
+  // CHECK-LABEL: Dumping Basic:::
+  // CHECK: FunctionTemplateDecl {{.*}} implicit 
+  // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T
+  // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit  'auto (int, int) -> D'
+  // CHECK:   |-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK:   `-ParmVarDecl {{.*}} 'int':'int'
+  // CHECK: FunctionProtoType {{.*}} 'auto (int, int) -> D' dependent trailing_return cdecl
+  // CHECK: |-InjectedClassNameType {{.*}} 'D' dependent
+  // CHECK: | `-CXXRecord {{.*}} 'D'
+  // CHECK: |-SubstTemplateTypeParmType {{.*}} 'int' sugar typename depth 0 index 0 T
+  // CHECK: | |-ClassTemplateSpecialization {{.*}} 'S'
+  // CHECK: | `-BuiltinType {{.*}} 'int'
+  // CHECK: `-SubstTemplateTypeParmType {{.*}} 'int' sugar 

[PATCH] D136120: [Clang] follow-up D128745, remove ClangABICompat checks

2022-11-02 Thread Yuanfang Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG40e99473170f: [Clang] follow-up D128745, remove 
ClangABICompat checks (authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136120

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CodeGen/partial-order-variadic.cpp
  clang/test/SemaCXX/pre-dr692.cpp

Index: clang/test/SemaCXX/pre-dr692.cpp
===
--- clang/test/SemaCXX/pre-dr692.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: %clang_cc1 %s -std=c++11 -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -fclang-abi-compat=15
-
-template  struct A1 {};
-template  struct A2 {};
-template  void e1(A1);  // expected-note {{candidate}}
-template  void e1(A1);  // expected-note {{candidate}}
-template  void e2(A2);  // expected-note {{candidate}}
-template  void e2(A2);  // expected-note {{candidate}}
-void h() {
-  A1 b1;
-  e1(b1); // expected-error{{call to 'e1' is ambiguous}}
-  A2 b2;
-  e2(b2); // expected-error{{call to 'e2' is ambiguous}}
-}
Index: clang/test/CodeGen/partial-order-variadic.cpp
===
--- clang/test/CodeGen/partial-order-variadic.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15 %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s --check-prefixes=CHECK,AFTER-15
-
-// CHECK: %struct.S = type { i8 }
-// CHECK: @_Z2ggiRi
-// CHECK: @_Z1gIiJEERiPT_DpT0_
-template  int (T *, U...);
-template  void g(T);
-template  struct S;
-template  struct S {};
-void gg(int i, int ) {
-  r = g();
-  S a;
-}
-
-// CHECK: @_Z1hIJiEEvDpPT_
-template void h(T*...) {}
-templatevoid h(const T&) {}
-template void h(int*);
-
-#if !defined(CLANG_ABI_COMPAT)
-
-// AFTER-15: @_Z1fIiJEEvPT_DpT0_
-template void f(T*, U...){}
-template void f(T){}
-template void f(int*);
-
-template struct A;
-template struct A {};
-template struct A;
-template struct A;
-
-#endif
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -1128,9 +1128,7 @@
   // During partial ordering, if Ai was originally a function parameter pack:
   // - if P does not contain a function parameter type corresponding to Ai then
   //   Ai is ignored;
-  bool ClangABICompat15 = S.Context.getLangOpts().getClangABICompat() <=
-  LangOptions::ClangABI::Ver15;
-  if (!ClangABICompat15 && PartialOrdering && ArgIdx + 1 == NumArgs &&
+  if (PartialOrdering && ArgIdx + 1 == NumArgs &&
   isa(Args[ArgIdx]))
 return Sema::TDK_Success;
 
@@ -2466,9 +2464,6 @@
   if (X.getKind() != Y.getKind())
 return false;
 
-  bool ClangABICompat15 =
-  Context.getLangOpts().getClangABICompat() <= LangOptions::ClangABI::Ver15;
-
   switch (X.getKind()) {
 case TemplateArgument::Null:
   llvm_unreachable("Comparing NULL template argument");
@@ -2500,45 +2495,33 @@
   return XID == YID;
 }
 
-case TemplateArgument::Pack:
-  if (ClangABICompat15) {
-if (X.pack_size() != Y.pack_size())
+case TemplateArgument::Pack: {
+  unsigned PackIterationSize = X.pack_size();
+  if (X.pack_size() != Y.pack_size()) {
+if (!PartialOrdering)
   return false;
 
-for (TemplateArgument::pack_iterator XP = X.pack_begin(),
- XPEnd = X.pack_end(),
- YP = Y.pack_begin();
- XP != XPEnd; ++XP, ++YP)
-  if (!isSameTemplateArg(Context, *XP, *YP, PartialOrdering,
- PackExpansionMatchesPack))
-return false;
-  } else {
-unsigned PackIterationSize = X.pack_size();
-if (X.pack_size() != Y.pack_size()) {
-  if (!PartialOrdering)
-return false;
-
-  // C++0x [temp.deduct.type]p9:
-  // During partial ordering, if Ai was originally a pack expansion:
-  // - if P does not contain a template argument corresponding to Ai
-  //   then Ai is ignored;
-  bool XHasMoreArg = X.pack_size() > Y.pack_size();
-  if (!(XHasMoreArg && X.pack_elements().back().isPackExpansion()) &&
-  !(!XHasMoreArg && Y.pack_elements().back().isPackExpansion()))
-return false;
-
-  if (XHasMoreArg)
-PackIterationSize = Y.pack_size();
-}
+// C++0x [temp.deduct.type]p9:
+// During partial ordering, if Ai was originally a pack expansion:
+// - if P does not contain a 

[PATCH] D136120: [Clang] follow-up D128745, remove ClangABICompat checks

2022-11-02 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 472727.
ychen added a comment.

- rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136120

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CodeGen/partial-order-variadic.cpp
  clang/test/SemaCXX/pre-dr692.cpp

Index: clang/test/SemaCXX/pre-dr692.cpp
===
--- clang/test/SemaCXX/pre-dr692.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: %clang_cc1 %s -std=c++11 -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -fclang-abi-compat=15
-
-template  struct A1 {};
-template  struct A2 {};
-template  void e1(A1);  // expected-note {{candidate}}
-template  void e1(A1);  // expected-note {{candidate}}
-template  void e2(A2);  // expected-note {{candidate}}
-template  void e2(A2);  // expected-note {{candidate}}
-void h() {
-  A1 b1;
-  e1(b1); // expected-error{{call to 'e1' is ambiguous}}
-  A2 b2;
-  e2(b2); // expected-error{{call to 'e2' is ambiguous}}
-}
Index: clang/test/CodeGen/partial-order-variadic.cpp
===
--- clang/test/CodeGen/partial-order-variadic.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15 %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s --check-prefixes=CHECK,AFTER-15
-
-// CHECK: %struct.S = type { i8 }
-// CHECK: @_Z2ggiRi
-// CHECK: @_Z1gIiJEERiPT_DpT0_
-template  int (T *, U...);
-template  void g(T);
-template  struct S;
-template  struct S {};
-void gg(int i, int ) {
-  r = g();
-  S a;
-}
-
-// CHECK: @_Z1hIJiEEvDpPT_
-template void h(T*...) {}
-templatevoid h(const T&) {}
-template void h(int*);
-
-#if !defined(CLANG_ABI_COMPAT)
-
-// AFTER-15: @_Z1fIiJEEvPT_DpT0_
-template void f(T*, U...){}
-template void f(T){}
-template void f(int*);
-
-template struct A;
-template struct A {};
-template struct A;
-template struct A;
-
-#endif
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -1128,9 +1128,7 @@
   // During partial ordering, if Ai was originally a function parameter pack:
   // - if P does not contain a function parameter type corresponding to Ai then
   //   Ai is ignored;
-  bool ClangABICompat15 = S.Context.getLangOpts().getClangABICompat() <=
-  LangOptions::ClangABI::Ver15;
-  if (!ClangABICompat15 && PartialOrdering && ArgIdx + 1 == NumArgs &&
+  if (PartialOrdering && ArgIdx + 1 == NumArgs &&
   isa(Args[ArgIdx]))
 return Sema::TDK_Success;
 
@@ -2466,9 +2464,6 @@
   if (X.getKind() != Y.getKind())
 return false;
 
-  bool ClangABICompat15 =
-  Context.getLangOpts().getClangABICompat() <= LangOptions::ClangABI::Ver15;
-
   switch (X.getKind()) {
 case TemplateArgument::Null:
   llvm_unreachable("Comparing NULL template argument");
@@ -2500,45 +2495,33 @@
   return XID == YID;
 }
 
-case TemplateArgument::Pack:
-  if (ClangABICompat15) {
-if (X.pack_size() != Y.pack_size())
+case TemplateArgument::Pack: {
+  unsigned PackIterationSize = X.pack_size();
+  if (X.pack_size() != Y.pack_size()) {
+if (!PartialOrdering)
   return false;
 
-for (TemplateArgument::pack_iterator XP = X.pack_begin(),
- XPEnd = X.pack_end(),
- YP = Y.pack_begin();
- XP != XPEnd; ++XP, ++YP)
-  if (!isSameTemplateArg(Context, *XP, *YP, PartialOrdering,
- PackExpansionMatchesPack))
-return false;
-  } else {
-unsigned PackIterationSize = X.pack_size();
-if (X.pack_size() != Y.pack_size()) {
-  if (!PartialOrdering)
-return false;
-
-  // C++0x [temp.deduct.type]p9:
-  // During partial ordering, if Ai was originally a pack expansion:
-  // - if P does not contain a template argument corresponding to Ai
-  //   then Ai is ignored;
-  bool XHasMoreArg = X.pack_size() > Y.pack_size();
-  if (!(XHasMoreArg && X.pack_elements().back().isPackExpansion()) &&
-  !(!XHasMoreArg && Y.pack_elements().back().isPackExpansion()))
-return false;
-
-  if (XHasMoreArg)
-PackIterationSize = Y.pack_size();
-}
+// C++0x [temp.deduct.type]p9:
+// During partial ordering, if Ai was originally a pack expansion:
+// - if P does not contain a template argument corresponding to Ai
+//   then Ai is ignored;
+bool XHasMoreArg = X.pack_size() 

[PATCH] D136975: [Concepts] Correctly handle failure when checking concepts recursively

2022-11-01 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen accepted this revision as: ychen.
ychen added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D136975

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136975: [Concepts] Correctly handle failure when checking concepts recursively

2022-11-01 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D136975#3899717 , @erichkeane 
wrote:

> In D136975#3899703 , @ychen wrote:
>
>> Thanks for the patch. It looks good to me.
>>
>> About
>>
>>> Note that we DO need to be careful to make sure we still check
>>> constraints properly that are caused by a previous constraint, but not
>>> derived from (such as when a check causes us to check special member
>>> function generation), so we cannot use the existing logic to see if this
>>> is being instantiated.
>>
>> For the `derived from` case, I think we also end up getting the infinite 
>> recursion? Why do we disable the check for the `derived from` case?
>
> Can you clarify what you mean?  I'm not sure which test case you're speaking 
> of.

I was confused about the reason for resetting SatisfactionStack. Never mind 
:-). I think I understand it now.


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

https://reviews.llvm.org/D136975

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136975: [Concepts] Correctly handle failure when checking concepts recursively

2022-11-01 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

Thanks for the patch. It looks good to me.

About

> Note that we DO need to be careful to make sure we still check
> constraints properly that are caused by a previous constraint, but not
> derived from (such as when a check causes us to check special member
> function generation), so we cannot use the existing logic to see if this
> is being instantiated.

For the `derived from` case, I think we also end up getting the infinite 
recursion? Why do we disable the check for the `derived from` case?


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

https://reviews.llvm.org/D136975

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136545: [Clang] use non-instantiated function declaration for constraints partial ordering

2022-10-30 Thread Yuanfang Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe18c2c5548f6: [Clang] use non-instantiated function 
declaration for constraints partial… (authored by ychen).

Changed prior to commit:
  https://reviews.llvm.org/D136545?vs=470546=471902#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136545

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/over/over.match/over.match.best/p2.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.order/non-template-functions.cpp

Index: clang/test/CXX/temp/temp.constr/temp.constr.order/non-template-functions.cpp
===
--- /dev/null
+++ clang/test/CXX/temp/temp.constr/temp.constr.order/non-template-functions.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++2a -x c++ -verify %s
+// expected-no-diagnostics
+
+template
+constexpr static bool is_same_v = false;
+
+template
+constexpr static bool is_same_v = true;
+
+namespace PR56154 {
+  template  concept C0 = (N == 0);
+  template  concept C0x = C0;
+  template  concept C00 = C0x && C0;
+
+  template
+  struct A {
+void f() requires C00;
+void f() requires C0x = delete;
+
+static short g() requires C00;
+static int g() requires C0x;
+  };
+  void h(A<0, 0> a) {
+a.f();
+static_assert(is_same_v::g), short(*)()>);
+  }
+}
Index: clang/test/CXX/over/over.match/over.match.best/p2.cpp
===
--- clang/test/CXX/over/over.match/over.match.best/p2.cpp
+++ clang/test/CXX/over/over.match/over.match.best/p2.cpp
@@ -7,7 +7,11 @@
 bool operator<(const A&) const & requires X; // #1
 int operator<=>(const A&) const & requires X && X = delete; // #2
   };
-  bool k1 = A() < A(); // not ordered by constraints: prefer non-rewritten form
+  bool k1 = A() < A(); // prefer more-constrained 'operator<=>'
+  // expected-error@-1 {{deleted}}
+  // expected-note@#1 {{candidate}}
+  // expected-note@#2 {{candidate function has been explicitly deleted}}
+  // expected-note@#2 {{candidate function (with reversed parameter order) has been explicitly deleted}}
   bool k2 = A() < A(); // prefer more-constrained 'operator<=>'
   // expected-error@-1 {{deleted}}
   // expected-note@#1 {{candidate}}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -10039,13 +10039,20 @@
   //  parameter-type-lists, and F1 is more constrained than F2 [...],
   if (!Cand1IsSpecialization && !Cand2IsSpecialization &&
   sameFunctionParameterTypeLists(S, Cand1, Cand2)) {
-const Expr *RC1 = Cand1.Function->getTrailingRequiresClause();
-const Expr *RC2 = Cand2.Function->getTrailingRequiresClause();
+FunctionDecl *Function1 = Cand1.Function;
+FunctionDecl *Function2 = Cand2.Function;
+if (FunctionDecl *MF = Function1->getInstantiatedFromMemberFunction())
+  Function1 = MF;
+if (FunctionDecl *MF = Function2->getInstantiatedFromMemberFunction())
+  Function2 = MF;
+
+const Expr *RC1 = Function1->getTrailingRequiresClause();
+const Expr *RC2 = Function2->getTrailingRequiresClause();
 if (RC1 && RC2) {
   bool AtLeastAsConstrained1, AtLeastAsConstrained2;
-  if (S.IsAtLeastAsConstrained(Cand1.Function, RC1, Cand2.Function, RC2,
+  if (S.IsAtLeastAsConstrained(Function1, RC1, Function2, RC2,
AtLeastAsConstrained1) ||
-  S.IsAtLeastAsConstrained(Cand2.Function, RC2, Cand1.Function, RC1,
+  S.IsAtLeastAsConstrained(Function2, RC2, Function1, RC1,
AtLeastAsConstrained2))
 return false;
   if (AtLeastAsConstrained1 != AtLeastAsConstrained2)
@@ -12630,20 +12637,24 @@
   DeclAccessPair DAP;
   SmallVector AmbiguousDecls;
 
-  auto CheckMoreConstrained =
-  [&] (FunctionDecl *FD1, FunctionDecl *FD2) -> Optional {
-SmallVector AC1, AC2;
-FD1->getAssociatedConstraints(AC1);
-FD2->getAssociatedConstraints(AC2);
-bool AtLeastAsConstrained1, AtLeastAsConstrained2;
-if (IsAtLeastAsConstrained(FD1, AC1, FD2, AC2, AtLeastAsConstrained1))
-  return None;
-if (IsAtLeastAsConstrained(FD2, AC2, FD1, AC1, AtLeastAsConstrained2))
-  return None;
-if (AtLeastAsConstrained1 == AtLeastAsConstrained2)
-  return None;
-return AtLeastAsConstrained1;
-  };
+  auto CheckMoreConstrained = [&](FunctionDecl *FD1,
+  FunctionDecl *FD2) -> Optional {
+if (FunctionDecl *MF = FD1->getInstantiatedFromMemberFunction())
+  FD1 = MF;
+if (FunctionDecl *MF = FD2->getInstantiatedFromMemberFunction())
+  FD2 = MF;
+

[PATCH] D136744: [Clang] perform "maximum TLS alignment" check for template instantiation

2022-10-30 Thread Yuanfang Chen 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 rG5d086cce8b92: [Clang] perform maximum TLS 
alignment check for template instantiation (authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136744

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/Sema/tls_alignment.cpp

Index: clang/test/Sema/tls_alignment.cpp
===
--- clang/test/Sema/tls_alignment.cpp
+++ clang/test/Sema/tls_alignment.cpp
@@ -58,27 +58,34 @@
bar5.some_data[5];
 }
 
-
-// Verify alignment check where a dependent type is involved.
-// The check is (correctly) not performed on "t", but the check still is
-// performed on the structure as a whole once it has been instantiated.
-
 template struct templated_tls {
 static __thread T t;
 T other_t __attribute__(( aligned(64) ));
 };
-__thread templated_tls blah; // expected-error{{alignment (64) of thread-local variable}}
-
-int blag() {
-return blah.other_t * 2;
-}
+ __thread templated_tls blah; // expected-error{{alignment (64) of thread-local variable}}
 
-
-// Verify alignment check where the alignment is a template parameter.
-// The check is only performed during instantiation.
 template 
 struct S {
+  struct alignas(64) B {};
+  struct alignas(N) C {};
+  static inline void f() {
+thread_local B b; // expected-error{{alignment (64) of thread-local variable}}
+thread_local C c; // expected-error{{alignment (64) of thread-local variable}}
+  }
+  template static inline thread_local int b alignas(J) = J; // expected-error{{alignment (64) of thread-local variable}}
   static int __thread __attribute__((aligned(N))) x; // expected-error{{alignment (64) of thread-local variable}}
 };
 
-S<64> s_instance; // expected-note{{in instantiation of template class 'S<64>' requested here}}
+int blag() {
+// Verify alignment check where the alignment is a template parameter.
+// The check is only performed during instantiation.
+S<64> s_instance; // expected-note{{in instantiation of template class 'S<64>' requested here}}
+
+// Verify alignment for dependent local variables.
+S<64>::f(); // expected-note{{in instantiation of member function 'S<64>::f' requested here}}
+
+// Verify alignment check where a dependent type is involved.
+// The check is (correctly) not performed on "t", but the check still is
+// performed on the structure as a whole once it has been instantiated.
+return blah.other_t * 2 + S<64>::b<64>; // expected-note{{in instantiation of static data member 'S<64>::b' requested here}}
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1179,6 +1179,9 @@
   if (Var->isStaticLocal())
 SemaRef.CheckStaticLocalForDllExport(Var);
 
+  if (Var->getTLSKind())
+SemaRef.CheckThreadLocalForLargeAlignment(Var);
+
   return Var;
 }
 
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -4341,7 +4341,7 @@
   }
 
   const auto *VD = dyn_cast(D);
-  if (VD && Context.getTargetInfo().isTLSSupported()) {
+  if (VD) {
 unsigned MaxTLSAlign =
 Context.toCharUnitsFromBits(Context.getTargetInfo().getMaxTLSAlign())
 .getQuantity();
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -14032,6 +14032,26 @@
   }
 }
 
+void Sema::CheckThreadLocalForLargeAlignment(VarDecl *VD) {
+  assert(VD->getTLSKind());
+
+  // Perform TLS alignment check here after attributes attached to the variable
+  // which may affect the alignment have been processed. Only perform the check
+  // if the target has a maximum TLS alignment (zero means no constraints).
+  if (unsigned MaxAlign = Context.getTargetInfo().getMaxTLSAlign()) {
+// Protect the check so that it's not performed on dependent types and
+// dependent alignments (we can't determine the alignment in that case).
+if (!VD->hasDependentAlignment()) {
+  CharUnits MaxAlignChars = Context.toCharUnitsFromBits(MaxAlign);
+  if (Context.getDeclAlign(VD) > MaxAlignChars) {
+Diag(VD->getLocation(), diag::err_tls_var_aligned_over_maximum)
+<< (unsigned)Context.getDeclAlign(VD).getQuantity() << VD
+<< (unsigned)MaxAlignChars.getQuantity();
+  }
+}
+  }
+}
+
 /// FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to 

[PATCH] D136744: [Clang] perform "maximum TLS alignment" check for template instantiation

2022-10-26 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:14038-14039
+
+  if (!Context.getTargetInfo().isTLSSupported())
+return;
+

mizvekov wrote:
> Is this needed? It seems `getMaxTLSAlign()` will return 0 in that case anyway.
It is checked in the other place where `err_tls_var_aligned_over_maximum` is 
used so I put it here. I'll remove the check here and there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136744

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136744: [Clang] perform "maximum TLS alignment" check for template instantiation

2022-10-26 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 470858.
ychen added a comment.
Herald added a reviewer: aaron.ballman.

- remove unnecessary check


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136744

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/Sema/tls_alignment.cpp

Index: clang/test/Sema/tls_alignment.cpp
===
--- clang/test/Sema/tls_alignment.cpp
+++ clang/test/Sema/tls_alignment.cpp
@@ -58,27 +58,34 @@
bar5.some_data[5];
 }
 
-
-// Verify alignment check where a dependent type is involved.
-// The check is (correctly) not performed on "t", but the check still is
-// performed on the structure as a whole once it has been instantiated.
-
 template struct templated_tls {
 static __thread T t;
 T other_t __attribute__(( aligned(64) ));
 };
-__thread templated_tls blah; // expected-error{{alignment (64) of thread-local variable}}
-
-int blag() {
-return blah.other_t * 2;
-}
+ __thread templated_tls blah; // expected-error{{alignment (64) of thread-local variable}}
 
-
-// Verify alignment check where the alignment is a template parameter.
-// The check is only performed during instantiation.
 template 
 struct S {
+  struct alignas(64) B {};
+  struct alignas(N) C {};
+  static inline void f() {
+thread_local B b; // expected-error{{alignment (64) of thread-local variable}}
+thread_local C c; // expected-error{{alignment (64) of thread-local variable}}
+  }
+  template static inline thread_local int b alignas(J) = J; // expected-error{{alignment (64) of thread-local variable}}
   static int __thread __attribute__((aligned(N))) x; // expected-error{{alignment (64) of thread-local variable}}
 };
 
-S<64> s_instance; // expected-note{{in instantiation of template class 'S<64>' requested here}}
+int blag() {
+// Verify alignment check where the alignment is a template parameter.
+// The check is only performed during instantiation.
+S<64> s_instance; // expected-note{{in instantiation of template class 'S<64>' requested here}}
+
+// Verify alignment for dependent local variables.
+S<64>::f(); // expected-note{{in instantiation of member function 'S<64>::f' requested here}}
+
+// Verify alignment check where a dependent type is involved.
+// The check is (correctly) not performed on "t", but the check still is
+// performed on the structure as a whole once it has been instantiated.
+return blah.other_t * 2 + S<64>::b<64>; // expected-note{{in instantiation of static data member 'S<64>::b' requested here}}
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1179,6 +1179,9 @@
   if (Var->isStaticLocal())
 SemaRef.CheckStaticLocalForDllExport(Var);
 
+  if (Var->getTLSKind())
+SemaRef.CheckThreadLocalForLargeAlignment(Var);
+
   return Var;
 }
 
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -4341,7 +4341,7 @@
   }
 
   const auto *VD = dyn_cast(D);
-  if (VD && Context.getTargetInfo().isTLSSupported()) {
+  if (VD) {
 unsigned MaxTLSAlign =
 Context.toCharUnitsFromBits(Context.getTargetInfo().getMaxTLSAlign())
 .getQuantity();
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -14032,6 +14032,26 @@
   }
 }
 
+void Sema::CheckThreadLocalForLargeAlignment(VarDecl *VD) {
+  assert(VD->getTLSKind());
+
+  // Perform TLS alignment check here after attributes attached to the variable
+  // which may affect the alignment have been processed. Only perform the check
+  // if the target has a maximum TLS alignment (zero means no constraints).
+  if (unsigned MaxAlign = Context.getTargetInfo().getMaxTLSAlign()) {
+// Protect the check so that it's not performed on dependent types and
+// dependent alignments (we can't determine the alignment in that case).
+if (!VD->hasDependentAlignment()) {
+  CharUnits MaxAlignChars = Context.toCharUnitsFromBits(MaxAlign);
+  if (Context.getDeclAlign(VD) > MaxAlignChars) {
+Diag(VD->getLocation(), diag::err_tls_var_aligned_over_maximum)
+<< (unsigned)Context.getDeclAlign(VD).getQuantity() << VD
+<< (unsigned)MaxAlignChars.getQuantity();
+  }
+}
+  }
+}
+
 /// FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform
 /// any semantic actions necessary after any initializer has been attached.
 void Sema::FinalizeDeclaration(Decl 

[PATCH] D136744: [Clang] perform "maximum TLS alignment" check for template instantiation

2022-10-26 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added reviewers: probinson, mizvekov.
Herald added a project: All.
ychen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

follow up d30e2eefc3cf8dfd2210aefd62f13a6e7c011b43


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136744

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/Sema/tls_alignment.cpp

Index: clang/test/Sema/tls_alignment.cpp
===
--- clang/test/Sema/tls_alignment.cpp
+++ clang/test/Sema/tls_alignment.cpp
@@ -58,27 +58,34 @@
bar5.some_data[5];
 }
 
-
-// Verify alignment check where a dependent type is involved.
-// The check is (correctly) not performed on "t", but the check still is
-// performed on the structure as a whole once it has been instantiated.
-
 template struct templated_tls {
 static __thread T t;
 T other_t __attribute__(( aligned(64) ));
 };
-__thread templated_tls blah; // expected-error{{alignment (64) of thread-local variable}}
-
-int blag() {
-return blah.other_t * 2;
-}
+ __thread templated_tls blah; // expected-error{{alignment (64) of thread-local variable}}
 
-
-// Verify alignment check where the alignment is a template parameter.
-// The check is only performed during instantiation.
 template 
 struct S {
+  struct alignas(64) B {};
+  struct alignas(N) C {};
+  static inline void f() {
+thread_local B b; // expected-error{{alignment (64) of thread-local variable}}
+thread_local C c; // expected-error{{alignment (64) of thread-local variable}}
+  }
+  template static inline thread_local int b alignas(J) = J; // expected-error{{alignment (64) of thread-local variable}}
   static int __thread __attribute__((aligned(N))) x; // expected-error{{alignment (64) of thread-local variable}}
 };
 
-S<64> s_instance; // expected-note{{in instantiation of template class 'S<64>' requested here}}
+int blag() {
+// Verify alignment check where the alignment is a template parameter.
+// The check is only performed during instantiation.
+S<64> s_instance; // expected-note{{in instantiation of template class 'S<64>' requested here}}
+
+// Verify alignment for dependent local variables.
+S<64>::f(); // expected-note{{in instantiation of member function 'S<64>::f' requested here}}
+
+// Verify alignment check where a dependent type is involved.
+// The check is (correctly) not performed on "t", but the check still is
+// performed on the structure as a whole once it has been instantiated.
+return blah.other_t * 2 + S<64>::b<64>; // expected-note{{in instantiation of static data member 'S<64>::b' requested here}}
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1179,6 +1179,9 @@
   if (Var->isStaticLocal())
 SemaRef.CheckStaticLocalForDllExport(Var);
 
+  if (Var->getTLSKind())
+SemaRef.CheckThreadLocalForLargeAlignment(Var);
+
   return Var;
 }
 
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -14032,6 +14032,29 @@
   }
 }
 
+void Sema::CheckThreadLocalForLargeAlignment(VarDecl *VD) {
+  assert(VD->getTLSKind());
+
+  if (!Context.getTargetInfo().isTLSSupported())
+return;
+
+  // Perform TLS alignment check here after attributes attached to the variable
+  // which may affect the alignment have been processed. Only perform the check
+  // if the target has a maximum TLS alignment (zero means no constraints).
+  if (unsigned MaxAlign = Context.getTargetInfo().getMaxTLSAlign()) {
+// Protect the check so that it's not performed on dependent types and
+// dependent alignments (we can't determine the alignment in that case).
+if (!VD->hasDependentAlignment()) {
+  CharUnits MaxAlignChars = Context.toCharUnitsFromBits(MaxAlign);
+  if (Context.getDeclAlign(VD) > MaxAlignChars) {
+Diag(VD->getLocation(), diag::err_tls_var_aligned_over_maximum)
+<< (unsigned)Context.getDeclAlign(VD).getQuantity() << VD
+<< (unsigned)MaxAlignChars.getQuantity();
+  }
+}
+  }
+}
+
 /// FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform
 /// any semantic actions necessary after any initializer has been attached.
 void Sema::FinalizeDeclaration(Decl *ThisDecl) {
@@ -14075,25 +14098,12 @@
 
   checkAttributesAfterMerging(*this, *VD);
 
-  // Perform TLS alignment check here after attributes attached to the variable
-  // which may affect the alignment have been processed. Only perform the check
-  // if the target has a maximum TLS alignment (zero means no constraints).
-  if (unsigned MaxAlign = 

[PATCH] D136545: [Clang] use non-instantiated function declaration for constraints partial ordering

2022-10-25 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 470546.
ychen added a comment.

- rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136545

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/over/over.match/over.match.best/p2.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.order/non-template-functions.cpp

Index: clang/test/CXX/temp/temp.constr/temp.constr.order/non-template-functions.cpp
===
--- /dev/null
+++ clang/test/CXX/temp/temp.constr/temp.constr.order/non-template-functions.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++2a -x c++ -verify %s
+// expected-no-diagnostics
+
+template
+constexpr static bool is_same_v = false;
+
+template
+constexpr static bool is_same_v = true;
+
+namespace PR56154 {
+  template  concept C0 = (N == 0);
+  template  concept C0x = C0;
+  template  concept C00 = C0x && C0;
+
+  template
+  struct A {
+void f() requires C00;
+void f() requires C0x = delete;
+
+static short g() requires C00;
+static int g() requires C0x;
+  };
+  void h(A<0, 0> a) {
+a.f();
+static_assert(is_same_v::g), short(*)()>);
+  }
+}
Index: clang/test/CXX/over/over.match/over.match.best/p2.cpp
===
--- clang/test/CXX/over/over.match/over.match.best/p2.cpp
+++ clang/test/CXX/over/over.match/over.match.best/p2.cpp
@@ -7,7 +7,11 @@
 bool operator<(const A&) const & requires X; // #1
 int operator<=>(const A&) const & requires X && X = delete; // #2
   };
-  bool k1 = A() < A(); // not ordered by constraints: prefer non-rewritten form
+  bool k1 = A() < A(); // prefer more-constrained 'operator<=>'
+  // expected-error@-1 {{deleted}}
+  // expected-note@#1 {{candidate}}
+  // expected-note@#2 {{candidate function has been explicitly deleted}}
+  // expected-note@#2 {{candidate function (with reversed parameter order) has been explicitly deleted}}
   bool k2 = A() < A(); // prefer more-constrained 'operator<=>'
   // expected-error@-1 {{deleted}}
   // expected-note@#1 {{candidate}}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -10033,13 +10033,20 @@
   //  parameter-type-lists, and F1 is more constrained than F2 [...],
   if (!Cand1IsSpecialization && !Cand2IsSpecialization &&
   sameFunctionParameterTypeLists(S, Cand1, Cand2)) {
-Expr *RC1 = Cand1.Function->getTrailingRequiresClause();
-Expr *RC2 = Cand2.Function->getTrailingRequiresClause();
+FunctionDecl *Function1 = Cand1.Function;
+FunctionDecl *Function2 = Cand2.Function;
+if (FunctionDecl *MF = Function1->getInstantiatedFromMemberFunction())
+  Function1 = MF;
+if (FunctionDecl *MF = Function2->getInstantiatedFromMemberFunction())
+  Function2 = MF;
+
+Expr *RC1 = Function1->getTrailingRequiresClause();
+Expr *RC2 = Function2->getTrailingRequiresClause();
 if (RC1 && RC2) {
   bool AtLeastAsConstrained1, AtLeastAsConstrained2;
-  if (S.IsAtLeastAsConstrained(Cand1.Function, {RC1}, Cand2.Function, {RC2},
+  if (S.IsAtLeastAsConstrained(Function1, {RC1}, Function2, {RC2},
AtLeastAsConstrained1) ||
-  S.IsAtLeastAsConstrained(Cand2.Function, {RC2}, Cand1.Function, {RC1},
+  S.IsAtLeastAsConstrained(Function2, {RC2}, Function1, {RC1},
AtLeastAsConstrained2))
 return false;
   if (AtLeastAsConstrained1 != AtLeastAsConstrained2)
@@ -12624,20 +12631,24 @@
   DeclAccessPair DAP;
   SmallVector AmbiguousDecls;
 
-  auto CheckMoreConstrained =
-  [&] (FunctionDecl *FD1, FunctionDecl *FD2) -> Optional {
-SmallVector AC1, AC2;
-FD1->getAssociatedConstraints(AC1);
-FD2->getAssociatedConstraints(AC2);
-bool AtLeastAsConstrained1, AtLeastAsConstrained2;
-if (IsAtLeastAsConstrained(FD1, AC1, FD2, AC2, AtLeastAsConstrained1))
-  return None;
-if (IsAtLeastAsConstrained(FD2, AC2, FD1, AC1, AtLeastAsConstrained2))
-  return None;
-if (AtLeastAsConstrained1 == AtLeastAsConstrained2)
-  return None;
-return AtLeastAsConstrained1;
-  };
+  auto CheckMoreConstrained = [&](FunctionDecl *FD1,
+  FunctionDecl *FD2) -> Optional {
+if (FunctionDecl *MF = FD1->getInstantiatedFromMemberFunction())
+  FD1 = MF;
+if (FunctionDecl *MF = FD2->getInstantiatedFromMemberFunction())
+  FD2 = MF;
+SmallVector AC1, AC2;
+FD1->getAssociatedConstraints(AC1);
+FD2->getAssociatedConstraints(AC2);
+bool AtLeastAsConstrained1, AtLeastAsConstrained2;
+if (IsAtLeastAsConstrained(FD1, AC1, FD2, AC2, 

[PATCH] D136545: [Clang] use non-instantiated function declaration for constraints partial ordering

2022-10-24 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/test/CXX/over/over.match/over.match.best/p2.cpp:10
   };
-  bool k1 = A() < A(); // not ordered by constraints: prefer 
non-rewritten form
-  bool k2 = A() < A(); // prefer more-constrained 'operator<=>'

erichkeane wrote:
> ychen wrote:
> > Remove this case because it compiles by accident. 
> > https://eel.is/c++draft/over.match#best.general-2.6 take precedence over 
> > https://eel.is/c++draft/over.match#best.general-2.8.
> Could you instead replace it with a better comment + a 'fixme' or something 
> if we need to fix it in the future?  I don't want to lose the test.
Sure. I restored the test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136545

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136545: [Clang] use non-template function declaration for constraints partial ordering

2022-10-24 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D136545#3877899 , @royjacobson 
wrote:

> LGTM, thanks for picking it up! I wonder how much effect this has on 
> compilation times given that `SubsumptionCache` caches subsumption by the 
> `Decl *` pair...

It seems neutral 
https://llvm-compile-time-tracker.com/compare.php?from=0ec6373e29f4c129490abef9d38015e9ec0b10ce=060fafdcf819578b89505c73d3235e44f56caa60=instructions

> One Q - do you think that adding an assert to IsAtLeastAsConstrained to not 
> accept 'instantiated' functions/structs again is possible somehow?

Great idea. For sure. I added the assertion and found two more places needing 
updates.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136545

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136545: [Clang] use non-template function declaration for constraints partial ordering

2022-10-24 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 470374.
ychen marked an inline comment as done.
ychen added a comment.

- do the same when 1. taking the address of a non-template function 2. 
computing SMF eligibility.
- restore removed test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136545

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/over/over.match/over.match.best/p2.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.order/non-template-functions.cpp

Index: clang/test/CXX/temp/temp.constr/temp.constr.order/non-template-functions.cpp
===
--- /dev/null
+++ clang/test/CXX/temp/temp.constr/temp.constr.order/non-template-functions.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++2a -x c++ -verify %s
+// expected-no-diagnostics
+
+template
+constexpr static bool is_same_v = false;
+
+template
+constexpr static bool is_same_v = true;
+
+namespace PR56154 {
+  template  concept C0 = (N == 0);
+  template  concept C0x = C0;
+  template  concept C00 = C0x && C0;
+
+  template
+  struct A {
+void f() requires C00;
+void f() requires C0x = delete;
+
+static short g() requires C00;
+static int g() requires C0x;
+  };
+  void h(A<0, 0> a) {
+a.f();
+static_assert(is_same_v::g), short(*)()>);
+  }
+}
Index: clang/test/CXX/over/over.match/over.match.best/p2.cpp
===
--- clang/test/CXX/over/over.match/over.match.best/p2.cpp
+++ clang/test/CXX/over/over.match/over.match.best/p2.cpp
@@ -7,7 +7,7 @@
 bool operator<(const A&) const & requires X; // #1
 int operator<=>(const A&) const & requires X && X = delete; // #2
   };
-  bool k1 = A() < A(); // not ordered by constraints: prefer non-rewritten form
+  bool k1 = A() < A(); // prefer more-constrained 'operator<=>'
   bool k2 = A() < A(); // prefer more-constrained 'operator<=>'
   // expected-error@-1 {{deleted}}
   // expected-note@#1 {{candidate}}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -10033,13 +10033,20 @@
   //  parameter-type-lists, and F1 is more constrained than F2 [...],
   if (!Cand1IsSpecialization && !Cand2IsSpecialization &&
   sameFunctionParameterTypeLists(S, Cand1, Cand2)) {
-Expr *RC1 = Cand1.Function->getTrailingRequiresClause();
-Expr *RC2 = Cand2.Function->getTrailingRequiresClause();
+FunctionDecl *Function1 = Cand1.Function;
+FunctionDecl *Function2 = Cand2.Function;
+if (FunctionDecl *MF = Function1->getInstantiatedFromMemberFunction())
+  Function1 = MF;
+if (FunctionDecl *MF = Function2->getInstantiatedFromMemberFunction())
+  Function2 = MF;
+
+Expr *RC1 = Function1->getTrailingRequiresClause();
+Expr *RC2 = Function2->getTrailingRequiresClause();
 if (RC1 && RC2) {
   bool AtLeastAsConstrained1, AtLeastAsConstrained2;
-  if (S.IsAtLeastAsConstrained(Cand1.Function, {RC1}, Cand2.Function, {RC2},
+  if (S.IsAtLeastAsConstrained(Function1, {RC1}, Function2, {RC2},
AtLeastAsConstrained1) ||
-  S.IsAtLeastAsConstrained(Cand2.Function, {RC2}, Cand1.Function, {RC1},
+  S.IsAtLeastAsConstrained(Function2, {RC2}, Function1, {RC1},
AtLeastAsConstrained2))
 return false;
   if (AtLeastAsConstrained1 != AtLeastAsConstrained2)
@@ -12624,20 +12631,24 @@
   DeclAccessPair DAP;
   SmallVector AmbiguousDecls;
 
-  auto CheckMoreConstrained =
-  [&] (FunctionDecl *FD1, FunctionDecl *FD2) -> Optional {
-SmallVector AC1, AC2;
-FD1->getAssociatedConstraints(AC1);
-FD2->getAssociatedConstraints(AC2);
-bool AtLeastAsConstrained1, AtLeastAsConstrained2;
-if (IsAtLeastAsConstrained(FD1, AC1, FD2, AC2, AtLeastAsConstrained1))
-  return None;
-if (IsAtLeastAsConstrained(FD2, AC2, FD1, AC1, AtLeastAsConstrained2))
-  return None;
-if (AtLeastAsConstrained1 == AtLeastAsConstrained2)
-  return None;
-return AtLeastAsConstrained1;
-  };
+  auto CheckMoreConstrained = [&](FunctionDecl *FD1,
+  FunctionDecl *FD2) -> Optional {
+if (FunctionDecl *MF = FD1->getInstantiatedFromMemberFunction())
+  FD1 = MF;
+if (FunctionDecl *MF = FD2->getInstantiatedFromMemberFunction())
+  FD2 = MF;
+SmallVector AC1, AC2;
+FD1->getAssociatedConstraints(AC1);
+FD2->getAssociatedConstraints(AC2);
+bool AtLeastAsConstrained1, AtLeastAsConstrained2;
+if (IsAtLeastAsConstrained(FD1, AC1, FD2, AC2, AtLeastAsConstrained1))
+  return None;
+if (IsAtLeastAsConstrained(FD2, AC2, FD1, AC1, 

[PATCH] D136533: [clang] Fix missing diagnostic of declaration use when accessing TypeDecls through typename access

2022-10-24 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:2569
 
+  enum class TypeAccessKind { Explicit, Implicit, Typename };
+  QualType getTypeDeclType(DeclContext *LookupCtx, TypeAccessKind AK,

mizvekov wrote:
> ychen wrote:
> > I find it hard to understand this enum since it does not correlate with 
> > wordings well and need to read code in other places to understand what it 
> > is used for. How about using two parameters: `bool DiagCtor` (replace `AK 
> > != TypeAccessKind::Explicit`) and `bool IsImplicitTypename` (replace `AK == 
> > TypeAccessKind::Typename`) ? 
> Hmm, enums are more en vogue :)
> 
> How about we:
> * Rename `TypeAccessKind` -> `DiagCtorKind`
> * Rename `Explicit` -> `None`
> 
> ?
Yep. That works for me. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136533

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136120: [Clang] follow-up D128745, remove ClangABICompat checks

2022-10-24 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136120

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136533: Fix missing diagnostic of declaration use when accessing TypeDecls through typename access

2022-10-23 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

Looks straightforward to me with one suggestion.

Is the CI fail related?




Comment at: clang/include/clang/Sema/Sema.h:2569
 
+  enum class TypeAccessKind { Explicit, Implicit, Typename };
+  QualType getTypeDeclType(DeclContext *LookupCtx, TypeAccessKind AK,

I find it hard to understand this enum since it does not correlate with 
wordings well and need to read code in other places to understand what it is 
used for. How about using two parameters: `bool DiagCtor` (replace `AK != 
TypeAccessKind::Explicit`) and `bool IsImplicitTypename` (replace `AK == 
TypeAccessKind::Typename`) ? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136533

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136545: [Clang] use non-template function declaration for constraints partial ordering

2022-10-22 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 469963.
ychen added a comment.

- add a release note.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136545

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/over/over.match/over.match.best/p2.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.order/non-template-functions.cpp


Index: 
clang/test/CXX/temp/temp.constr/temp.constr.order/non-template-functions.cpp
===
--- /dev/null
+++ clang/test/CXX/temp/temp.constr/temp.constr.order/non-template-functions.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -std=c++2a -x c++ -verify %s
+// expected-no-diagnostics
+
+namespace PR56154 {
+  template  concept C0 = (N == 0);
+  template  concept C0x = C0;
+  template  concept C00 = C0x && C0;
+
+  template
+  struct A {
+ void f() requires C00;
+ void f() requires C0x;
+  };
+  void h(A<0, 0> a) {
+   a.f();
+  }
+}
Index: clang/test/CXX/over/over.match/over.match.best/p2.cpp
===
--- clang/test/CXX/over/over.match/over.match.best/p2.cpp
+++ clang/test/CXX/over/over.match/over.match.best/p2.cpp
@@ -7,8 +7,7 @@
 bool operator<(const A&) const & requires X; // #1
 int operator<=>(const A&) const & requires X && X = delete; // #2
   };
-  bool k1 = A() < A(); // not ordered by constraints: prefer 
non-rewritten form
-  bool k2 = A() < A(); // prefer more-constrained 'operator<=>'
+  bool k = A() < A(); // prefer more-constrained 'operator<=>'
   // expected-error@-1 {{deleted}}
   // expected-note@#1 {{candidate}}
   // expected-note@#2 {{candidate function has been explicitly deleted}}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -10033,13 +10033,20 @@
   //  parameter-type-lists, and F1 is more constrained than F2 [...],
   if (!Cand1IsSpecialization && !Cand2IsSpecialization &&
   sameFunctionParameterTypeLists(S, Cand1, Cand2)) {
-Expr *RC1 = Cand1.Function->getTrailingRequiresClause();
-Expr *RC2 = Cand2.Function->getTrailingRequiresClause();
+FunctionDecl *Function1 = Cand1.Function;
+FunctionDecl *Function2 = Cand2.Function;
+if (FunctionDecl *MF = Function1->getInstantiatedFromMemberFunction())
+  Function1 = MF;
+if (FunctionDecl *MF = Function2->getInstantiatedFromMemberFunction())
+  Function2 = MF;
+
+Expr *RC1 = Function1->getTrailingRequiresClause();
+Expr *RC2 = Function2->getTrailingRequiresClause();
 if (RC1 && RC2) {
   bool AtLeastAsConstrained1, AtLeastAsConstrained2;
-  if (S.IsAtLeastAsConstrained(Cand1.Function, {RC1}, Cand2.Function, 
{RC2},
+  if (S.IsAtLeastAsConstrained(Function1, {RC1}, Function2, {RC2},
AtLeastAsConstrained1) ||
-  S.IsAtLeastAsConstrained(Cand2.Function, {RC2}, Cand1.Function, 
{RC1},
+  S.IsAtLeastAsConstrained(Function2, {RC2}, Function1, {RC1},
AtLeastAsConstrained2))
 return false;
   if (AtLeastAsConstrained1 != AtLeastAsConstrained2)
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -255,6 +255,8 @@
 - Reject non-type template arguments formed by casting a non-zero integer
   to a pointer in pre-C++17 modes, instead of treating them as null
   pointers.
+- Fix an issue when performing constraints partial ordering on non-template
+  functions.  `Issue 56154 
`_
 
 Improvements to Clang's diagnostics
 ^^^


Index: clang/test/CXX/temp/temp.constr/temp.constr.order/non-template-functions.cpp
===
--- /dev/null
+++ clang/test/CXX/temp/temp.constr/temp.constr.order/non-template-functions.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -std=c++2a -x c++ -verify %s
+// expected-no-diagnostics
+
+namespace PR56154 {
+  template  concept C0 = (N == 0);
+  template  concept C0x = C0;
+  template  concept C00 = C0x && C0;
+
+  template
+  struct A {
+ void f() requires C00;
+ void f() requires C0x;
+  };
+  void h(A<0, 0> a) {
+   a.f();
+  }
+}
Index: clang/test/CXX/over/over.match/over.match.best/p2.cpp
===
--- clang/test/CXX/over/over.match/over.match.best/p2.cpp
+++ clang/test/CXX/over/over.match/over.match.best/p2.cpp
@@ -7,8 +7,7 @@
 bool operator<(const A&) const & requires X; // #1
 int operator<=>(const A&) const & requires X && X = delete; // #2
   };
-  bool k1 = A() < A(); // not ordered by constraints: prefer non-rewritten form
-  bool k2 = A() < 

[PATCH] D136545: [Clang] use non-template function declaration for constraints partial ordering

2022-10-22 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/test/CXX/over/over.match/over.match.best/p2.cpp:10
   };
-  bool k1 = A() < A(); // not ordered by constraints: prefer 
non-rewritten form
-  bool k2 = A() < A(); // prefer more-constrained 'operator<=>'

Remove this case because it compiles by accident. 
https://eel.is/c++draft/over.match#best.general-2.6 take precedence over 
https://eel.is/c++draft/over.match#best.general-2.8.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136545

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136545: [Clang] use non-template function declaration for constraints partial ordering

2022-10-22 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added reviewers: erichkeane, royjacobson, mizvekov.
Herald added a project: All.
ychen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Per wordings in

- https://eel.is/c++draft/over.match#best.general-2.6
- https://eel.is/c++draft/temp.constr.order
- https://eel.is/c++draft/temp.constr#atomic-1

constraints partial ordering should use the unsubstituted template
parameters of the constrained entity, not the instantiated entity.

Fix #56154


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136545

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/over/over.match/over.match.best/p2.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.order/non-template-functions.cpp


Index: 
clang/test/CXX/temp/temp.constr/temp.constr.order/non-template-functions.cpp
===
--- /dev/null
+++ clang/test/CXX/temp/temp.constr/temp.constr.order/non-template-functions.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -std=c++2a -x c++ -verify %s
+// expected-no-diagnostics
+
+namespace PR56154 {
+  template  concept C0 = (N == 0);
+  template  concept C0x = C0;
+  template  concept C00 = C0x && C0;
+
+  template
+  struct A {
+ void f() requires C00;
+ void f() requires C0x;
+  };
+  void h(A<0, 0> a) {
+   a.f();
+  }
+}
Index: clang/test/CXX/over/over.match/over.match.best/p2.cpp
===
--- clang/test/CXX/over/over.match/over.match.best/p2.cpp
+++ clang/test/CXX/over/over.match/over.match.best/p2.cpp
@@ -7,8 +7,7 @@
 bool operator<(const A&) const & requires X; // #1
 int operator<=>(const A&) const & requires X && X = delete; // #2
   };
-  bool k1 = A() < A(); // not ordered by constraints: prefer 
non-rewritten form
-  bool k2 = A() < A(); // prefer more-constrained 'operator<=>'
+  bool k = A() < A(); // prefer more-constrained 'operator<=>'
   // expected-error@-1 {{deleted}}
   // expected-note@#1 {{candidate}}
   // expected-note@#2 {{candidate function has been explicitly deleted}}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -10033,13 +10033,20 @@
   //  parameter-type-lists, and F1 is more constrained than F2 [...],
   if (!Cand1IsSpecialization && !Cand2IsSpecialization &&
   sameFunctionParameterTypeLists(S, Cand1, Cand2)) {
-Expr *RC1 = Cand1.Function->getTrailingRequiresClause();
-Expr *RC2 = Cand2.Function->getTrailingRequiresClause();
+FunctionDecl *Function1 = Cand1.Function;
+FunctionDecl *Function2 = Cand2.Function;
+if (FunctionDecl *MF = Function1->getInstantiatedFromMemberFunction())
+  Function1 = MF;
+if (FunctionDecl *MF = Function2->getInstantiatedFromMemberFunction())
+  Function2 = MF;
+
+Expr *RC1 = Function1->getTrailingRequiresClause();
+Expr *RC2 = Function2->getTrailingRequiresClause();
 if (RC1 && RC2) {
   bool AtLeastAsConstrained1, AtLeastAsConstrained2;
-  if (S.IsAtLeastAsConstrained(Cand1.Function, {RC1}, Cand2.Function, 
{RC2},
+  if (S.IsAtLeastAsConstrained(Function1, {RC1}, Function2, {RC2},
AtLeastAsConstrained1) ||
-  S.IsAtLeastAsConstrained(Cand2.Function, {RC2}, Cand1.Function, 
{RC1},
+  S.IsAtLeastAsConstrained(Function2, {RC2}, Function1, {RC1},
AtLeastAsConstrained2))
 return false;
   if (AtLeastAsConstrained1 != AtLeastAsConstrained2)


Index: clang/test/CXX/temp/temp.constr/temp.constr.order/non-template-functions.cpp
===
--- /dev/null
+++ clang/test/CXX/temp/temp.constr/temp.constr.order/non-template-functions.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -std=c++2a -x c++ -verify %s
+// expected-no-diagnostics
+
+namespace PR56154 {
+  template  concept C0 = (N == 0);
+  template  concept C0x = C0;
+  template  concept C00 = C0x && C0;
+
+  template
+  struct A {
+ void f() requires C00;
+ void f() requires C0x;
+  };
+  void h(A<0, 0> a) {
+   a.f();
+  }
+}
Index: clang/test/CXX/over/over.match/over.match.best/p2.cpp
===
--- clang/test/CXX/over/over.match/over.match.best/p2.cpp
+++ clang/test/CXX/over/over.match/over.match.best/p2.cpp
@@ -7,8 +7,7 @@
 bool operator<(const A&) const & requires X; // #1
 int operator<=>(const A&) const & requires X && X = delete; // #2
   };
-  bool k1 = A() < A(); // not ordered by constraints: prefer non-rewritten form
-  bool k2 = A() < A(); // prefer more-constrained 'operator<=>'
+  bool k = A() < A(); // prefer more-constrained 'operator<=>'
   // expected-error@-1 {{deleted}}
   // expected-note@#1 {{candidate}}
   // expected-note@#2 {{candidate function 

[PATCH] D128750: [C++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-10-18 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp:106
   template
-  constexpr int goo(const int b) requires AtLeast2 {
+  constexpr int goo(const int b) requires AtLeast2 { // expected-note 
{{candidate function}}
 return 2;

usaxena95 wrote:
> Thanks for working on this.
> 
> I wanted to bring up related: 
> https://github.com/llvm/llvm-project/issues/56154
> Eg.: Removing this `const` still removes the ambiguity but it shouldn't.
> Since you have more context, does this look related to you ?
Removing `const` makes the partial ordering compare constraints where 
`AtLeast2 && true` subsumes `AtLeast2` so it is not ambiguous 
anymore. Similar reasoning could be made for the original test case of 
https://github.com/llvm/llvm-project/issues/56154. 56154 exposes an issue in 
constraints partial ordering which is not related to this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128750: [C++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-10-18 Thread Yuanfang Chen 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 rG340eac01f7da: [C++20] Implement P2113R0: Changes to the 
Partial Ordering of Constrained… (authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclTemplate.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
  clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -963,7 +963,7 @@
   
   
 https://wg21.link/p2113r0;>P2113R0
-No
+Clang 16
   
 
 
Index: clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
+++ clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
@@ -1,10 +1,18 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
 
-struct A;
-struct B;
-
 template  constexpr bool True = true;
 template  concept C = True;
+template  concept D = C && sizeof(T) > 2;
+template  concept E = D && alignof(T) > 1;
+
+struct A {};
+template  struct S {};
+template  struct S2 {};
+template  struct X {};
+
+namespace p6 {
+
+struct B;
 
 void f(C auto &, auto &) = delete;
 template  void f(Q &, C auto &);
@@ -13,14 +21,125 @@
   f(*ap, *bp);
 }
 
-template  struct X {};
-
+#if 0
+// FIXME: [temp.func.order]p6.2.1 is not implemented, matching GCC.
 template  bool operator==(X, V) = delete;
 templatebool operator==(T, X);
 
 bool h() {
   return X{} == 0;
 }
+#endif
+
+template class U,
+ typename... Z>
+void foo(T, U) = delete;
+template class U,
+ typename... Z>
+void foo(T, U) = delete;
+template class U,
+ typename... Z>
+void foo(T, U);
+
+// check auto template parameter pack.
+template class U,
+ C auto... Z>
+void foo2(T, U) = delete;
+template class U,
+ D auto... Z>
+void foo2(T, U) = delete;
+template class U,
+ E auto... Z>
+void foo2(T, U);
+
+void bar(S s, S2 s2) {
+  foo(0, s);
+  foo2(0, s2);
+}
+
+template void bar2();
+template void bar2() = delete;
+
+} // namespace p6
+
+namespace TestConversionFunction {
+struct Y {
+  template operator X(); // expected-note {{candidate function [with T = int, U = int]}}
+  template operator X(); // expected-note {{candidate function [with T = int, U = int]}}
+};
+
+X f() {
+  return Y{}; // expected-error {{conversion from 'Y' to 'X' is ambiguous}}
+}
+}
+
+namespace ClassPartialSpecPartialOrdering {
+template struct Y { Y()=delete; }; // expected-note {{template is declared here}}
+template struct Y {}; // expected-error {{class template partial specialization is not more specialized than the primary template}}
+
+template struct Y1 { Y1()=delete; };
+template struct Y1  { Y1()=delete; };
+template struct Y1 {};
+
+template struct Y2 {};
+template struct Y2 {}; // expected-note {{partial specialization matches}}
+template struct Y2 {}; // expected-note {{partial specialization matches}}
+
+template class U, typename... Z>
+struct Y3 { Y3()=delete; };
+template class U, typename... Z>
+struct Y3 { Y3()=delete; };
+template class U, typename... Z>
+struct Y3 {};
+
+void f() {
+  Y1 a;
+  Y2 b; // expected-error {{ambiguous partial specializations}}
+  Y3 c;
+}
+
+template struct Y4; // expected-note {{template is declared here}}
+template struct Y4; // expected-error {{class template partial specialization is not more specialized than the primary template}}
+
+template struct W1;
+template struct W1 {};
+
+template struct W2;
+template struct W2 {};
+
+template
+concept C1 = C && C;
+template
+concept D1 = D && C;
+
+template auto T> struct W3;
+template auto T> struct W3 {};
+
+template auto... T> struct W4;
+template auto... T> struct W4 {};
+
+// FIXME: enable once Clang support non-trivial auto on NTTP.
+// template struct W5;
+// template struct W5 {};
+
+// FIXME: enable once Clang support non-trivial auto on NTTP.
+// template struct W6;
+// template struct W6 {};
+
+struct W1<0> w1;
+struct W2<0> w2;
+struct W3<0> w3;
+struct W4<0> w4;
+// FIXME: enable once Clang support non-trivial auto on NTTP.
+// struct W5<(int*)nullptr> w5;
+// struct W6 w6;
+}
 
 namespace PR53640 {
 
Index: clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
===
--- clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp

[PATCH] D128750: [C++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-10-18 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

@mizvekov Thanks for the review and provided valuable feedback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136133: [Clang] update cxx_dr_status.html by running make_cxx_dr_status

2022-10-18 Thread Yuanfang Chen 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 rG6bca52be0349: [Clang] update cxx_dr_status.html by running 
make_cxx_dr_status (authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136133

Files:
  clang/test/CXX/drs/dr25xx.cpp
  clang/test/CXX/drs/dr2xx.cpp
  clang/www/cxx_dr_status.html
  clang/www/make_cxx_dr_status

Index: clang/www/make_cxx_dr_status
===
--- clang/www/make_cxx_dr_status
+++ clang/www/make_cxx_dr_status
@@ -91,7 +91,7 @@
 Available in Clang?
   ''')
 
-latest_release = 13
+latest_release = 15
 
 def availability(issue):
   status = status_map.get(issue, 'unknown')
@@ -158,7 +158,10 @@
 # This refers to the old ("C++0x") concepts feature, which was not part
 # of any C++ International Standard or Technical Specification.
 continue
-  if dr.status in ('open', 'concurrency', 'drafting', 'review', 'extension'):
+  if dr.issue in (1432,2565):
+row_style = ' class="open"'
+avail, avail_style = availability(dr.issue)
+  elif dr.status in ('open', 'concurrency', 'drafting', 'review', 'extension'):
 # We may have to deal with these some day, but not yet.
 row_style = ' class="open"'
 if dr.status == 'extension':
@@ -182,7 +185,7 @@
   ''' % (row_style, dr.issue, dr.issue, dr.issue, dr.status, dr.title, avail_style, avail))
 
 for status, num in sorted(count.items()):
-  print("%s: %s" % (status, num))
+  print("%s: %s" % (status, num), file=sys.stderr)
 
 out_file.write('''\
 
Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -1383,7 +1383,7 @@
 https://wg21.link/cwg224;>224
 CD1
 Definition of dependent names
-No
+Clang 16
   
   
 https://wg21.link/cwg225;>225
@@ -7650,7 +7650,7 @@
 https://wg21.link/cwg1307;>1307
 C++14
 Overload resolution based on size of array initializer-list
-Clang 14
+Clang 14
   
   
 https://wg21.link/cwg1308;>1308
@@ -8172,7 +8172,7 @@
 https://wg21.link/cwg1394;>1394
 CD3
 Incomplete types as parameters of deleted functions
-Clang 15
+Clang 15
   
   
 https://wg21.link/cwg1395;>1395
@@ -8400,7 +8400,7 @@
 https://wg21.link/cwg1432;>1432
 open
 Newly-ambiguous variadic template expansions
-Not resolved
+Clang 16
   
   
 https://wg21.link/cwg1433;>1433
@@ -10380,7 +10380,7 @@
 https://wg21.link/cwg1762;>1762
 C++14
 Reserved identifier used in literal-operator-id example
-Clang 14
+Clang 14
   
   
 https://wg21.link/cwg1763;>1763
@@ -10440,7 +10440,7 @@
 https://wg21.link/cwg1772;>1772
 C++14
 __func__ in a lambda body
-Clang 14
+Clang 14
   
   
 https://wg21.link/cwg1773;>1773
@@ -10482,7 +10482,7 @@
 https://wg21.link/cwg1779;>1779
 CD4
 Type dependency of __func__
-Clang 14
+Clang 14
   
   
 https://wg21.link/cwg1780;>1780
@@ -12834,7 +12834,7 @@
 https://wg21.link/cwg2171;>2171
 CD4
 Triviality of copy constructor with less-qualified parameter
-Clang 15
+Clang 15
   
   
 https://wg21.link/cwg2172;>2172
@@ -13932,7 +13932,7 @@
 https://wg21.link/cwg2354;>2354
 CD5
 Extended alignment and object representation
-Clang 15
+Clang 15
   
   
 https://wg21.link/cwg2355;>2355
@@ -14172,7 +14172,7 @@
 https://wg21.link/cwg2394;>2394
 CD5
 Const-default-constructible for members
-Clang 15
+Clang 15
   
   
 https://wg21.link/cwg2395;>2395
@@ -15198,7 +15198,7 @@
 https://wg21.link/cwg2565;>2565
 open
 Invalid types in the parameter-declaration-clause of a requires-expression
-Clang 16
+Clang 16
   
   
 https://wg21.link/cwg2566;>2566
Index: clang/test/CXX/drs/dr2xx.cpp
===
--- clang/test/CXX/drs/dr2xx.cpp
+++ clang/test/CXX/drs/dr2xx.cpp
@@ -243,7 +243,7 @@
 
 // dr223: na
 
-namespace dr224 { // dr224: yes
+namespace dr224 { // dr224: 16
   namespace example1 {
 template  class A {
   typedef int type;
Index: clang/test/CXX/drs/dr25xx.cpp
===
--- clang/test/CXX/drs/dr25xx.cpp
+++ clang/test/CXX/drs/dr25xx.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify
 
-namespace dr2565 { // dr252: 16
+namespace dr2565 { // dr2565: 16
   template
 concept C = requires (typename T::type x) {
   x + 1;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136133: [Clang] update cxx_dr_status.html by running make_cxx_dr_status

2022-10-18 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 468631.
ychen added a comment.

- DR2565 is fully implemented.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136133

Files:
  clang/test/CXX/drs/dr25xx.cpp
  clang/test/CXX/drs/dr2xx.cpp
  clang/www/cxx_dr_status.html
  clang/www/make_cxx_dr_status

Index: clang/www/make_cxx_dr_status
===
--- clang/www/make_cxx_dr_status
+++ clang/www/make_cxx_dr_status
@@ -91,7 +91,7 @@
 Available in Clang?
   ''')
 
-latest_release = 13
+latest_release = 15
 
 def availability(issue):
   status = status_map.get(issue, 'unknown')
@@ -158,7 +158,10 @@
 # This refers to the old ("C++0x") concepts feature, which was not part
 # of any C++ International Standard or Technical Specification.
 continue
-  if dr.status in ('open', 'concurrency', 'drafting', 'review', 'extension'):
+  if dr.issue in (1432,2565):
+row_style = ' class="open"'
+avail, avail_style = availability(dr.issue)
+  elif dr.status in ('open', 'concurrency', 'drafting', 'review', 'extension'):
 # We may have to deal with these some day, but not yet.
 row_style = ' class="open"'
 if dr.status == 'extension':
@@ -182,7 +185,7 @@
   ''' % (row_style, dr.issue, dr.issue, dr.issue, dr.status, dr.title, avail_style, avail))
 
 for status, num in sorted(count.items()):
-  print("%s: %s" % (status, num))
+  print("%s: %s" % (status, num), file=sys.stderr)
 
 out_file.write('''\
 
Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -1383,7 +1383,7 @@
 https://wg21.link/cwg224;>224
 CD1
 Definition of dependent names
-No
+Clang 16
   
   
 https://wg21.link/cwg225;>225
@@ -7650,7 +7650,7 @@
 https://wg21.link/cwg1307;>1307
 C++14
 Overload resolution based on size of array initializer-list
-Clang 14
+Clang 14
   
   
 https://wg21.link/cwg1308;>1308
@@ -8172,7 +8172,7 @@
 https://wg21.link/cwg1394;>1394
 CD3
 Incomplete types as parameters of deleted functions
-Clang 15
+Clang 15
   
   
 https://wg21.link/cwg1395;>1395
@@ -8400,7 +8400,7 @@
 https://wg21.link/cwg1432;>1432
 open
 Newly-ambiguous variadic template expansions
-Not resolved
+Clang 16
   
   
 https://wg21.link/cwg1433;>1433
@@ -10380,7 +10380,7 @@
 https://wg21.link/cwg1762;>1762
 C++14
 Reserved identifier used in literal-operator-id example
-Clang 14
+Clang 14
   
   
 https://wg21.link/cwg1763;>1763
@@ -10440,7 +10440,7 @@
 https://wg21.link/cwg1772;>1772
 C++14
 __func__ in a lambda body
-Clang 14
+Clang 14
   
   
 https://wg21.link/cwg1773;>1773
@@ -10482,7 +10482,7 @@
 https://wg21.link/cwg1779;>1779
 CD4
 Type dependency of __func__
-Clang 14
+Clang 14
   
   
 https://wg21.link/cwg1780;>1780
@@ -12834,7 +12834,7 @@
 https://wg21.link/cwg2171;>2171
 CD4
 Triviality of copy constructor with less-qualified parameter
-Clang 15
+Clang 15
   
   
 https://wg21.link/cwg2172;>2172
@@ -13932,7 +13932,7 @@
 https://wg21.link/cwg2354;>2354
 CD5
 Extended alignment and object representation
-Clang 15
+Clang 15
   
   
 https://wg21.link/cwg2355;>2355
@@ -14172,7 +14172,7 @@
 https://wg21.link/cwg2394;>2394
 CD5
 Const-default-constructible for members
-Clang 15
+Clang 15
   
   
 https://wg21.link/cwg2395;>2395
@@ -15198,7 +15198,7 @@
 https://wg21.link/cwg2565;>2565
 open
 Invalid types in the parameter-declaration-clause of a requires-expression
-Clang 16
+Clang 16
   
   
 https://wg21.link/cwg2566;>2566
Index: clang/test/CXX/drs/dr2xx.cpp
===
--- clang/test/CXX/drs/dr2xx.cpp
+++ clang/test/CXX/drs/dr2xx.cpp
@@ -243,7 +243,7 @@
 
 // dr223: na
 
-namespace dr224 { // dr224: yes
+namespace dr224 { // dr224: 16
   namespace example1 {
 template  class A {
   typedef int type;
Index: clang/test/CXX/drs/dr25xx.cpp
===
--- clang/test/CXX/drs/dr25xx.cpp
+++ clang/test/CXX/drs/dr25xx.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify
 
-namespace dr2565 { // dr252: 16
+namespace dr2565 { // dr2565: 16
   template
 concept C = requires (typename T::type x) {
   x + 1;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136120: [Clang] follow-up D128745, remove ClangABICompat checks

2022-10-18 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 468630.
ychen added a comment.

- update Release notes
- remove obsolete CodeGen tests which was used to test ClangABICompat checks, 
similar Sema tests are already in place.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136120

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CodeGen/partial-order-variadic.cpp
  clang/test/SemaCXX/pre-dr692.cpp

Index: clang/test/SemaCXX/pre-dr692.cpp
===
--- clang/test/SemaCXX/pre-dr692.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: %clang_cc1 %s -std=c++11 -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -fclang-abi-compat=15
-
-template  struct A1 {};
-template  struct A2 {};
-template  void e1(A1);  // expected-note {{candidate}}
-template  void e1(A1);  // expected-note {{candidate}}
-template  void e2(A2);  // expected-note {{candidate}}
-template  void e2(A2);  // expected-note {{candidate}}
-void h() {
-  A1 b1;
-  e1(b1); // expected-error{{call to 'e1' is ambiguous}}
-  A2 b2;
-  e2(b2); // expected-error{{call to 'e2' is ambiguous}}
-}
Index: clang/test/CodeGen/partial-order-variadic.cpp
===
--- clang/test/CodeGen/partial-order-variadic.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15 %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s --check-prefixes=CHECK,AFTER-15
-
-// CHECK: %struct.S = type { i8 }
-// CHECK: @_Z2ggiRi
-// CHECK: @_Z1gIiJEERiPT_DpT0_
-template  int (T *, U...);
-template  void g(T);
-template  struct S;
-template  struct S {};
-void gg(int i, int ) {
-  r = g();
-  S a;
-}
-
-// CHECK: @_Z1hIJiEEvDpPT_
-template void h(T*...) {}
-templatevoid h(const T&) {}
-template void h(int*);
-
-#if !defined(CLANG_ABI_COMPAT)
-
-// AFTER-15: @_Z1fIiJEEvPT_DpT0_
-template void f(T*, U...){}
-template void f(T){}
-template void f(int*);
-
-template struct A;
-template struct A {};
-template struct A;
-template struct A;
-
-#endif
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -1128,9 +1128,7 @@
   // During partial ordering, if Ai was originally a function parameter pack:
   // - if P does not contain a function parameter type corresponding to Ai then
   //   Ai is ignored;
-  bool ClangABICompat15 = S.Context.getLangOpts().getClangABICompat() <=
-  LangOptions::ClangABI::Ver15;
-  if (!ClangABICompat15 && PartialOrdering && ArgIdx + 1 == NumArgs &&
+  if (PartialOrdering && ArgIdx + 1 == NumArgs &&
   isa(Args[ArgIdx]))
 return Sema::TDK_Success;
 
@@ -2466,9 +2464,6 @@
   if (X.getKind() != Y.getKind())
 return false;
 
-  bool ClangABICompat15 =
-  Context.getLangOpts().getClangABICompat() <= LangOptions::ClangABI::Ver15;
-
   switch (X.getKind()) {
 case TemplateArgument::Null:
   llvm_unreachable("Comparing NULL template argument");
@@ -2500,45 +2495,33 @@
   return XID == YID;
 }
 
-case TemplateArgument::Pack:
-  if (ClangABICompat15) {
-if (X.pack_size() != Y.pack_size())
+case TemplateArgument::Pack: {
+  unsigned PackIterationSize = X.pack_size();
+  if (X.pack_size() != Y.pack_size()) {
+if (!PartialOrdering)
   return false;
 
-for (TemplateArgument::pack_iterator XP = X.pack_begin(),
- XPEnd = X.pack_end(),
- YP = Y.pack_begin();
- XP != XPEnd; ++XP, ++YP)
-  if (!isSameTemplateArg(Context, *XP, *YP, PartialOrdering,
- PackExpansionMatchesPack))
-return false;
-  } else {
-unsigned PackIterationSize = X.pack_size();
-if (X.pack_size() != Y.pack_size()) {
-  if (!PartialOrdering)
-return false;
-
-  // C++0x [temp.deduct.type]p9:
-  // During partial ordering, if Ai was originally a pack expansion:
-  // - if P does not contain a template argument corresponding to Ai
-  //   then Ai is ignored;
-  bool XHasMoreArg = X.pack_size() > Y.pack_size();
-  if (!(XHasMoreArg && X.pack_elements().back().isPackExpansion()) &&
-  !(!XHasMoreArg && Y.pack_elements().back().isPackExpansion()))
-return false;
-
-  if (XHasMoreArg)
-PackIterationSize = Y.pack_size();
-}
+// C++0x [temp.deduct.type]p9:
+// During partial ordering, if Ai was originally a pack expansion:
+// - if 

[PATCH] D136133: [Clang] update cxx_dr_status.html by running make_cxx_dr_status

2022-10-18 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/test/CXX/drs/dr25xx.cpp:3
 
-namespace dr2565 { // dr252: 16
+namespace dr2565 { // dr2565: partial
   template

erichkeane wrote:
> If you could add a comment explaining this status for me, I would be grateful:
> 
> // We've implemented DR2565 as proposed (that is, a substitution failure in a 
> requires parameter list causes the requires clause to evaluate as false) as 
> it seems to make the most sense, and fit best into our implementation. If 
> this issue gets accepted as-is, this can be marked as complete.
You said `we were in a position where we had 1/2 of it implemented`. So I put 
it as partial. I must've misunderstood you. Will change it back.



Comment at: clang/www/make_cxx_dr_status:161
 continue
-  if dr.status in ('open', 'concurrency', 'drafting', 'review', 'extension'):
+  if dr.issue in (1432,2565):
+row_style = ' class="open"'

erichkeane wrote:
> I guess this is OK, its a shame we have to custom-tag these, but I guess I'm 
> 1/2 responsible here :/
Yeah, it looks hacky. If the list gets larger, we could do something like 
`namespace dr1432 { // dr1432: open 16` to make it more general.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136133

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128750: [C++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-10-18 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D128750#3864612 , @mizvekov wrote:

> Is the pre-commit CI failure here related to the patch?

Seems not. It should've been fixed by 606245ad542491400a5475c796df86a99f5c8c12 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128750: [C++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-10-18 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 468602.
ychen added a comment.

- rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclTemplate.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
  clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -963,7 +963,7 @@
   
   
 https://wg21.link/p2113r0;>P2113R0
-No
+Clang 16
   
 
 
Index: clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
+++ clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
@@ -1,10 +1,18 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
 
-struct A;
-struct B;
-
 template  constexpr bool True = true;
 template  concept C = True;
+template  concept D = C && sizeof(T) > 2;
+template  concept E = D && alignof(T) > 1;
+
+struct A {};
+template  struct S {};
+template  struct S2 {};
+template  struct X {};
+
+namespace p6 {
+
+struct B;
 
 void f(C auto &, auto &) = delete;
 template  void f(Q &, C auto &);
@@ -13,14 +21,125 @@
   f(*ap, *bp);
 }
 
-template  struct X {};
-
+#if 0
+// FIXME: [temp.func.order]p6.2.1 is not implemented, matching GCC.
 template  bool operator==(X, V) = delete;
 templatebool operator==(T, X);
 
 bool h() {
   return X{} == 0;
 }
+#endif
+
+template class U,
+ typename... Z>
+void foo(T, U) = delete;
+template class U,
+ typename... Z>
+void foo(T, U) = delete;
+template class U,
+ typename... Z>
+void foo(T, U);
+
+// check auto template parameter pack.
+template class U,
+ C auto... Z>
+void foo2(T, U) = delete;
+template class U,
+ D auto... Z>
+void foo2(T, U) = delete;
+template class U,
+ E auto... Z>
+void foo2(T, U);
+
+void bar(S s, S2 s2) {
+  foo(0, s);
+  foo2(0, s2);
+}
+
+template void bar2();
+template void bar2() = delete;
+
+} // namespace p6
+
+namespace TestConversionFunction {
+struct Y {
+  template operator X(); // expected-note {{candidate function [with T = int, U = int]}}
+  template operator X(); // expected-note {{candidate function [with T = int, U = int]}}
+};
+
+X f() {
+  return Y{}; // expected-error {{conversion from 'Y' to 'X' is ambiguous}}
+}
+}
+
+namespace ClassPartialSpecPartialOrdering {
+template struct Y { Y()=delete; }; // expected-note {{template is declared here}}
+template struct Y {}; // expected-error {{class template partial specialization is not more specialized than the primary template}}
+
+template struct Y1 { Y1()=delete; };
+template struct Y1  { Y1()=delete; };
+template struct Y1 {};
+
+template struct Y2 {};
+template struct Y2 {}; // expected-note {{partial specialization matches}}
+template struct Y2 {}; // expected-note {{partial specialization matches}}
+
+template class U, typename... Z>
+struct Y3 { Y3()=delete; };
+template class U, typename... Z>
+struct Y3 { Y3()=delete; };
+template class U, typename... Z>
+struct Y3 {};
+
+void f() {
+  Y1 a;
+  Y2 b; // expected-error {{ambiguous partial specializations}}
+  Y3 c;
+}
+
+template struct Y4; // expected-note {{template is declared here}}
+template struct Y4; // expected-error {{class template partial specialization is not more specialized than the primary template}}
+
+template struct W1;
+template struct W1 {};
+
+template struct W2;
+template struct W2 {};
+
+template
+concept C1 = C && C;
+template
+concept D1 = D && C;
+
+template auto T> struct W3;
+template auto T> struct W3 {};
+
+template auto... T> struct W4;
+template auto... T> struct W4 {};
+
+// FIXME: enable once Clang support non-trivial auto on NTTP.
+// template struct W5;
+// template struct W5 {};
+
+// FIXME: enable once Clang support non-trivial auto on NTTP.
+// template struct W6;
+// template struct W6 {};
+
+struct W1<0> w1;
+struct W2<0> w2;
+struct W3<0> w3;
+struct W4<0> w4;
+// FIXME: enable once Clang support non-trivial auto on NTTP.
+// struct W5<(int*)nullptr> w5;
+// struct W6 w6;
+}
 
 namespace PR53640 {
 
Index: clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
===
--- clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
+++ clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
@@ -98,26 +98,31 @@
   static_assert(is_same_v()), void>); // expected-error {{call to 'bar' is ambiguous}}
 
   template
- 

[PATCH] D136133: [Clang] update cxx_dr_status.html by running make_cxx_dr_status

2022-10-18 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 468430.
ychen added a comment.

- rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136133

Files:
  clang/test/CXX/drs/dr25xx.cpp
  clang/test/CXX/drs/dr2xx.cpp
  clang/www/cxx_dr_status.html
  clang/www/make_cxx_dr_status

Index: clang/www/make_cxx_dr_status
===
--- clang/www/make_cxx_dr_status
+++ clang/www/make_cxx_dr_status
@@ -91,7 +91,7 @@
 Available in Clang?
   ''')
 
-latest_release = 13
+latest_release = 15
 
 def availability(issue):
   status = status_map.get(issue, 'unknown')
@@ -158,7 +158,10 @@
 # This refers to the old ("C++0x") concepts feature, which was not part
 # of any C++ International Standard or Technical Specification.
 continue
-  if dr.status in ('open', 'concurrency', 'drafting', 'review', 'extension'):
+  if dr.issue in (1432,2565):
+row_style = ' class="open"'
+avail, avail_style = availability(dr.issue)
+  elif dr.status in ('open', 'concurrency', 'drafting', 'review', 'extension'):
 # We may have to deal with these some day, but not yet.
 row_style = ' class="open"'
 if dr.status == 'extension':
@@ -182,7 +185,7 @@
   ''' % (row_style, dr.issue, dr.issue, dr.issue, dr.status, dr.title, avail_style, avail))
 
 for status, num in sorted(count.items()):
-  print("%s: %s" % (status, num))
+  print("%s: %s" % (status, num), file=sys.stderr)
 
 out_file.write('''\
 
Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -1383,7 +1383,7 @@
 https://wg21.link/cwg224;>224
 CD1
 Definition of dependent names
-No
+Clang 16
   
   
 https://wg21.link/cwg225;>225
@@ -7650,7 +7650,7 @@
 https://wg21.link/cwg1307;>1307
 C++14
 Overload resolution based on size of array initializer-list
-Clang 14
+Clang 14
   
   
 https://wg21.link/cwg1308;>1308
@@ -8172,7 +8172,7 @@
 https://wg21.link/cwg1394;>1394
 CD3
 Incomplete types as parameters of deleted functions
-Clang 15
+Clang 15
   
   
 https://wg21.link/cwg1395;>1395
@@ -8400,7 +8400,7 @@
 https://wg21.link/cwg1432;>1432
 open
 Newly-ambiguous variadic template expansions
-Not resolved
+Clang 16
   
   
 https://wg21.link/cwg1433;>1433
@@ -10380,7 +10380,7 @@
 https://wg21.link/cwg1762;>1762
 C++14
 Reserved identifier used in literal-operator-id example
-Clang 14
+Clang 14
   
   
 https://wg21.link/cwg1763;>1763
@@ -10440,7 +10440,7 @@
 https://wg21.link/cwg1772;>1772
 C++14
 __func__ in a lambda body
-Clang 14
+Clang 14
   
   
 https://wg21.link/cwg1773;>1773
@@ -10482,7 +10482,7 @@
 https://wg21.link/cwg1779;>1779
 CD4
 Type dependency of __func__
-Clang 14
+Clang 14
   
   
 https://wg21.link/cwg1780;>1780
@@ -12834,7 +12834,7 @@
 https://wg21.link/cwg2171;>2171
 CD4
 Triviality of copy constructor with less-qualified parameter
-Clang 15
+Clang 15
   
   
 https://wg21.link/cwg2172;>2172
@@ -13932,7 +13932,7 @@
 https://wg21.link/cwg2354;>2354
 CD5
 Extended alignment and object representation
-Clang 15
+Clang 15
   
   
 https://wg21.link/cwg2355;>2355
@@ -14172,7 +14172,7 @@
 https://wg21.link/cwg2394;>2394
 CD5
 Const-default-constructible for members
-Clang 15
+Clang 15
   
   
 https://wg21.link/cwg2395;>2395
@@ -15198,7 +15198,7 @@
 https://wg21.link/cwg2565;>2565
 open
 Invalid types in the parameter-declaration-clause of a requires-expression
-Clang 16
+Partial
   
   
 https://wg21.link/cwg2566;>2566
Index: clang/test/CXX/drs/dr2xx.cpp
===
--- clang/test/CXX/drs/dr2xx.cpp
+++ clang/test/CXX/drs/dr2xx.cpp
@@ -243,7 +243,7 @@
 
 // dr223: na
 
-namespace dr224 { // dr224: yes
+namespace dr224 { // dr224: 16
   namespace example1 {
 template  class A {
   typedef int type;
Index: clang/test/CXX/drs/dr25xx.cpp
===
--- clang/test/CXX/drs/dr25xx.cpp
+++ clang/test/CXX/drs/dr25xx.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify
 
-namespace dr2565 { // dr252: 16
+namespace dr2565 { // dr2565: partial
   template
 concept C = requires (typename T::type x) {
   x + 1;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136133: [Clang] update cxx_dr_status.html by running make_cxx_dr_status

2022-10-18 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added reviewers: royjacobson, erichkeane.
Herald added a project: All.
ychen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

For https://github.com/llvm/llvm-project/issues/58382


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136133

Files:
  clang/test/CXX/drs/dr25xx.cpp
  clang/test/CXX/drs/dr2xx.cpp
  clang/www/cxx_dr_status.html
  clang/www/make_cxx_dr_status

Index: clang/www/make_cxx_dr_status
===
--- clang/www/make_cxx_dr_status
+++ clang/www/make_cxx_dr_status
@@ -91,7 +91,7 @@
 Available in Clang?
   ''')
 
-latest_release = 13
+latest_release = 15
 
 def availability(issue):
   status = status_map.get(issue, 'unknown')
@@ -158,7 +158,10 @@
 # This refers to the old ("C++0x") concepts feature, which was not part
 # of any C++ International Standard or Technical Specification.
 continue
-  if dr.status in ('open', 'concurrency', 'drafting', 'review', 'extension'):
+  if dr.issue in (1432,2565):
+row_style = ' class="open"'
+avail, avail_style = availability(dr.issue)
+  elif dr.status in ('open', 'concurrency', 'drafting', 'review', 'extension'):
 # We may have to deal with these some day, but not yet.
 row_style = ' class="open"'
 if dr.status == 'extension':
@@ -182,7 +185,7 @@
   ''' % (row_style, dr.issue, dr.issue, dr.issue, dr.status, dr.title, avail_style, avail))
 
 for status, num in sorted(count.items()):
-  print("%s: %s" % (status, num))
+  print("%s: %s" % (status, num), file=sys.stderr)
 
 out_file.write('''\
 
Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -1383,7 +1383,7 @@
 https://wg21.link/cwg224;>224
 CD1
 Definition of dependent names
-No
+Clang 16
   
   
 https://wg21.link/cwg225;>225
@@ -7650,7 +7650,7 @@
 https://wg21.link/cwg1307;>1307
 C++14
 Overload resolution based on size of array initializer-list
-Clang 14
+Clang 14
   
   
 https://wg21.link/cwg1308;>1308
@@ -8172,7 +8172,7 @@
 https://wg21.link/cwg1394;>1394
 CD3
 Incomplete types as parameters of deleted functions
-Clang 15
+Clang 15
   
   
 https://wg21.link/cwg1395;>1395
@@ -8400,7 +8400,7 @@
 https://wg21.link/cwg1432;>1432
 open
 Newly-ambiguous variadic template expansions
-Not resolved
+Clang 16
   
   
 https://wg21.link/cwg1433;>1433
@@ -10380,7 +10380,7 @@
 https://wg21.link/cwg1762;>1762
 C++14
 Reserved identifier used in literal-operator-id example
-Clang 14
+Clang 14
   
   
 https://wg21.link/cwg1763;>1763
@@ -10440,7 +10440,7 @@
 https://wg21.link/cwg1772;>1772
 C++14
 __func__ in a lambda body
-Clang 14
+Clang 14
   
   
 https://wg21.link/cwg1773;>1773
@@ -10482,7 +10482,7 @@
 https://wg21.link/cwg1779;>1779
 CD4
 Type dependency of __func__
-Clang 14
+Clang 14
   
   
 https://wg21.link/cwg1780;>1780
@@ -12834,7 +12834,7 @@
 https://wg21.link/cwg2171;>2171
 CD4
 Triviality of copy constructor with less-qualified parameter
-Clang 15
+Clang 15
   
   
 https://wg21.link/cwg2172;>2172
@@ -13836,7 +13836,7 @@
 https://wg21.link/cwg2338;>2338
 CD5
 Undefined behavior converting to short enums with fixed underlying types
-Clang 16
+Clang 12
   
   
 https://wg21.link/cwg2339;>2339
@@ -13932,7 +13932,7 @@
 https://wg21.link/cwg2354;>2354
 CD5
 Extended alignment and object representation
-Clang 15
+Clang 15
   
   
 https://wg21.link/cwg2355;>2355
@@ -14172,7 +14172,7 @@
 https://wg21.link/cwg2394;>2394
 CD5
 Const-default-constructible for members
-Clang 15
+Clang 15
   
   
 https://wg21.link/cwg2395;>2395
@@ -15198,7 +15198,7 @@
 https://wg21.link/cwg2565;>2565
 open
 Invalid types in the parameter-declaration-clause of a requires-expression
-Clang 16
+Partial
   
   
 https://wg21.link/cwg2566;>2566
Index: clang/test/CXX/drs/dr2xx.cpp
===
--- clang/test/CXX/drs/dr2xx.cpp
+++ clang/test/CXX/drs/dr2xx.cpp
@@ -243,7 +243,7 @@
 
 // dr223: na
 
-namespace dr224 { // dr224: yes
+namespace dr224 { // dr224: 16
   namespace example1 {
 template  class A {
   typedef int type;
Index: clang/test/CXX/drs/dr25xx.cpp
===
--- clang/test/CXX/drs/dr25xx.cpp
+++ clang/test/CXX/drs/dr25xx.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify
 
-namespace dr2565 { // dr252: 16
+namespace dr2565 { // dr2565: partial
   template
 concept C = requires (typename T::type x) {
   x + 1;

[PATCH] D136120: [Clang] follow-up D128745, remove all ClangABICompat checks

2022-10-17 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added reviewers: aaron.ballman, erichkeane, hubert.reinterpretcast.
Herald added a project: All.
ychen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Per discussions in D128745 , remove 
ClangABICompat checks for implementations
of DR692/DR1395/DR1432. This is a potentially breaking changes, so the release
note is updated accordingly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136120

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateDeduction.cpp

Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -1128,9 +1128,7 @@
   // During partial ordering, if Ai was originally a function parameter pack:
   // - if P does not contain a function parameter type corresponding to Ai then
   //   Ai is ignored;
-  bool ClangABICompat15 = S.Context.getLangOpts().getClangABICompat() <=
-  LangOptions::ClangABI::Ver15;
-  if (!ClangABICompat15 && PartialOrdering && ArgIdx + 1 == NumArgs &&
+  if (PartialOrdering && ArgIdx + 1 == NumArgs &&
   isa(Args[ArgIdx]))
 return Sema::TDK_Success;
 
@@ -2466,9 +2464,6 @@
   if (X.getKind() != Y.getKind())
 return false;
 
-  bool ClangABICompat15 =
-  Context.getLangOpts().getClangABICompat() <= LangOptions::ClangABI::Ver15;
-
   switch (X.getKind()) {
 case TemplateArgument::Null:
   llvm_unreachable("Comparing NULL template argument");
@@ -2500,45 +2495,33 @@
   return XID == YID;
 }
 
-case TemplateArgument::Pack:
-  if (ClangABICompat15) {
-if (X.pack_size() != Y.pack_size())
+case TemplateArgument::Pack: {
+  unsigned PackIterationSize = X.pack_size();
+  if (X.pack_size() != Y.pack_size()) {
+if (!PartialOrdering)
   return false;
 
-for (TemplateArgument::pack_iterator XP = X.pack_begin(),
- XPEnd = X.pack_end(),
- YP = Y.pack_begin();
- XP != XPEnd; ++XP, ++YP)
-  if (!isSameTemplateArg(Context, *XP, *YP, PartialOrdering,
- PackExpansionMatchesPack))
-return false;
-  } else {
-unsigned PackIterationSize = X.pack_size();
-if (X.pack_size() != Y.pack_size()) {
-  if (!PartialOrdering)
-return false;
-
-  // C++0x [temp.deduct.type]p9:
-  // During partial ordering, if Ai was originally a pack expansion:
-  // - if P does not contain a template argument corresponding to Ai
-  //   then Ai is ignored;
-  bool XHasMoreArg = X.pack_size() > Y.pack_size();
-  if (!(XHasMoreArg && X.pack_elements().back().isPackExpansion()) &&
-  !(!XHasMoreArg && Y.pack_elements().back().isPackExpansion()))
-return false;
-
-  if (XHasMoreArg)
-PackIterationSize = Y.pack_size();
-}
+// C++0x [temp.deduct.type]p9:
+// During partial ordering, if Ai was originally a pack expansion:
+// - if P does not contain a template argument corresponding to Ai
+//   then Ai is ignored;
+bool XHasMoreArg = X.pack_size() > Y.pack_size();
+if (!(XHasMoreArg && X.pack_elements().back().isPackExpansion()) &&
+!(!XHasMoreArg && Y.pack_elements().back().isPackExpansion()))
+  return false;
 
-ArrayRef XP = X.pack_elements();
-ArrayRef YP = Y.pack_elements();
-for (unsigned i = 0; i < PackIterationSize; ++i)
-  if (!isSameTemplateArg(Context, XP[i], YP[i], PartialOrdering,
- PackExpansionMatchesPack))
-return false;
+if (XHasMoreArg)
+  PackIterationSize = Y.pack_size();
   }
+
+  ArrayRef XP = X.pack_elements();
+  ArrayRef YP = Y.pack_elements();
+  for (unsigned i = 0; i < PackIterationSize; ++i)
+if (!isSameTemplateArg(Context, XP[i], YP[i], PartialOrdering,
+   PackExpansionMatchesPack))
+  return false;
   return true;
+}
   }
 
   llvm_unreachable("Invalid TemplateArgument Kind!");
@@ -5229,33 +5212,29 @@
 
   // This a speculative fix for CWG1432 (Similar to the fix for CWG1395) that
   // there is no wording or even resolution for this issue.
-  bool ClangABICompat15 =
-  Context.getLangOpts().getClangABICompat() <= LangOptions::ClangABI::Ver15;
-  if (!ClangABICompat15) {
-for (int i = 0, e = std::min(NumParams1, NumParams2); i < e; ++i) {
-  QualType T1 = FD1->getParamDecl(i)->getType().getCanonicalType();
-  QualType T2 = FD2->getParamDecl(i)->getType().getCanonicalType();
-  auto *TST1 = dyn_cast(T1);
-  auto *TST2 = dyn_cast(T2);
-  if 

[PATCH] D134507: [Clang] add missing ClangABICompat check

2022-10-17 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D134507#3856956 , @tahonermann 
wrote:

>> Per further discussions in D128745 , this 
>> is not needed.
>
> I agree that the code change is not needed. I think it is worth keeping the 
> test though (modified to verify the expected ambiguity).

Agreed. It turns out the ambiguous case is already in place. 
(https://github.com/llvm/llvm-project/blob/d8af31ecede0c54ec667ab687784149e806c9e4c/clang/test/CXX/drs/dr6xx.cpp#L1104)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134507

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128750: [C++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-10-17 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:5511-5539
+  template ::value, bool> = true>
+  bool operator()(T1 *PS1, T2 *PS2) {
+return hasEqualTemplateArgumentList(
+PS1->getTemplateArgsAsWritten()->arguments(),
+PS2->getTemplateArgsAsWritten()->arguments());
+  }

mizvekov wrote:
> mizvekov wrote:
> > mizvekov wrote:
> > > mizvekov wrote:
> > > > ychen wrote:
> > > > > mizvekov wrote:
> > > > > > I think you are not supposed to use the `TemplateArgsAsWritten` 
> > > > > > here.
> > > > > > 
> > > > > > The injected arguments are 'Converted' arguments, and the 
> > > > > > transformation above, by unpacking the arguments, is reversing just 
> > > > > > a tiny part of the conversion process.
> > > > > > 
> > > > > > It's not very meaningful to canonicalize the arguments as written 
> > > > > > to perform a semantic comparison, as that works well just for some 
> > > > > > kinds of template arguments, like types and templates, but not for 
> > > > > > other kinds in which the conversion process is not trivial.
> > > > > > 
> > > > > > For example, I think this may fail to compare the same integers 
> > > > > > written in different ways, like `2` vs `1 + 1`.
> > > > > Indeed. It can happen only when comparing one partial specialization 
> > > > > with another. I think the standard does not require an implementation 
> > > > > to deal with this but we could use the best effort without much 
> > > > > overhead. For `2` vs `1+1` or similar template arguments that are not 
> > > > > dependent, we could assume the equivalence because they wouldn't be 
> > > > > in the partial ordering stage if they're not equivalent. For more 
> > > > > complicated cases like `J+2` vs `J+1+1` where J is NTTP, let's stop 
> > > > > trying (match GCC) because the overhead is a little bit high. 
> > > > But I think the 'TemplateArgs', which are the specialization arguments 
> > > > and are available through `getTemplateArgs()`, are the converted 
> > > > arguments you want here, ie the AsWritten arguments converted against 
> > > > the template.
> > > > 
> > > > I don't see why you can't just use that.
> > > > 
> > > > How about we change:
> > > > ```
> > > >   if (!TemplateArgumentListAreEqual(S.getASTContext())(P1, P2))
> > > > return nullptr;
> > > > ```
> > > > 
> > > > Into:
> > > > 
> > > > ```
> > > >   {
> > > > ArrayRef Args1 = P1->getTemplateArgs().asArray(), 
> > > > Args2;
> > > > if constexpr (IsMoreSpecialThanPrimaryCheck)
> > > >   Args2 = P2->getInjectedTemplateArgs();
> > > > else
> > > >   Args2 = P2->getTemplateArgs().asArray();
> > > > 
> > > > if (Args1.size() != Args2.size())
> > > >   return nullptr;
> > > > 
> > > > for (unsigned I = 0, E = Args1.size(); I < E; ++I) {
> > > >   TemplateArgument Arg2 = Args2[I];
> > > >   // Unlike the specialization arguments, the injected arguments 
> > > > are not
> > > >   // always canonical.
> > > >   if constexpr (IsMoreSpecialThanPrimaryCheck)
> > > > Arg2 = S.Context.getCanonicalTemplateArgument(Arg2);
> > > > 
> > > >   // We use profile, instead of structural comparison of the 
> > > > arguments,
> > > >   // because canonicalization can't do the right thing for dependent
> > > >   // expressions.
> > > >   llvm::FoldingSetNodeID IDA, IDB;
> > > >   Args1[I].Profile(IDA, S.Context);
> > > >   Arg2.Profile(IDB, S.Context);
> > > >   if (IDA != IDB)
> > > > return nullptr;
> > > > }
> > > >   }
> > > > ```
> > > > 
> > > > That should work, right?
> > > Actually, you can even further simplify this.
> > > 
> > > You can't have two different specializations with the same specialization 
> > > arguments. These arguments are used as the key to unique them anyway.
> > > 
> > > So simplify my above suggestion to:
> > > ```
> > >   if constexpr (IsMoreSpecialThanPrimaryCheck) {
> > > ArrayRef Args1 = P1->getTemplateArgs().asArray(),
> > >Args2 = P2->getInjectedTemplateArgs();
> > > if (Args1.size() != Args2.size())
> > >   return nullptr;
> > > 
> > > for (unsigned I = 0, E = Args1.size(); I < E; ++I) {
> > >   // We use profile, instead of structural comparison of the 
> > > arguments,
> > >   // because canonicalization can't do the right thing for dependent
> > >   // expressions.
> > >   llvm::FoldingSetNodeID IDA, IDB;
> > >   Args1[I].Profile(IDA, S.Context);
> > >   // Unlike the specialization arguments, the injected arguments are 
> > > not
> > >   // always canonical.
> > >   S.Context.getCanonicalTemplateArgument(Args2[I]).Profile(IDB, 
> > > S.Context);
> > >   if (IDA != IDB)
> > > return nullptr;
> > > }
> > >   }
> > > ```
> > Yet another improvement here is that you can do this check once, when we 
> > create the specialization, and then simply store a 
> > 

[PATCH] D128750: [C++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-10-17 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 468286.
ychen added a comment.

- use getTemplateArgs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclTemplate.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
  clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -963,7 +963,7 @@
   
   
 https://wg21.link/p2113r0;>P2113R0
-No
+Clang 16
   
 
 
Index: clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
+++ clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
@@ -1,10 +1,18 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
 
-struct A;
-struct B;
-
 template  constexpr bool True = true;
 template  concept C = True;
+template  concept D = C && sizeof(T) > 2;
+template  concept E = D && alignof(T) > 1;
+
+struct A {};
+template  struct S {};
+template  struct S2 {};
+template  struct X {};
+
+namespace p6 {
+
+struct B;
 
 void f(C auto &, auto &) = delete;
 template  void f(Q &, C auto &);
@@ -13,14 +21,125 @@
   f(*ap, *bp);
 }
 
-template  struct X {};
-
+#if 0
+// FIXME: [temp.func.order]p6.2.1 is not implemented, matching GCC.
 template  bool operator==(X, V) = delete;
 templatebool operator==(T, X);
 
 bool h() {
   return X{} == 0;
 }
+#endif
+
+template class U,
+ typename... Z>
+void foo(T, U) = delete;
+template class U,
+ typename... Z>
+void foo(T, U) = delete;
+template class U,
+ typename... Z>
+void foo(T, U);
+
+// check auto template parameter pack.
+template class U,
+ C auto... Z>
+void foo2(T, U) = delete;
+template class U,
+ D auto... Z>
+void foo2(T, U) = delete;
+template class U,
+ E auto... Z>
+void foo2(T, U);
+
+void bar(S s, S2 s2) {
+  foo(0, s);
+  foo2(0, s2);
+}
+
+template void bar2();
+template void bar2() = delete;
+
+} // namespace p6
+
+namespace TestConversionFunction {
+struct Y {
+  template operator X(); // expected-note {{candidate function [with T = int, U = int]}}
+  template operator X(); // expected-note {{candidate function [with T = int, U = int]}}
+};
+
+X f() {
+  return Y{}; // expected-error {{conversion from 'Y' to 'X' is ambiguous}}
+}
+}
+
+namespace ClassPartialSpecPartialOrdering {
+template struct Y { Y()=delete; }; // expected-note {{template is declared here}}
+template struct Y {}; // expected-error {{class template partial specialization is not more specialized than the primary template}}
+
+template struct Y1 { Y1()=delete; };
+template struct Y1  { Y1()=delete; };
+template struct Y1 {};
+
+template struct Y2 {};
+template struct Y2 {}; // expected-note {{partial specialization matches}}
+template struct Y2 {}; // expected-note {{partial specialization matches}}
+
+template class U, typename... Z>
+struct Y3 { Y3()=delete; };
+template class U, typename... Z>
+struct Y3 { Y3()=delete; };
+template class U, typename... Z>
+struct Y3 {};
+
+void f() {
+  Y1 a;
+  Y2 b; // expected-error {{ambiguous partial specializations}}
+  Y3 c;
+}
+
+template struct Y4; // expected-note {{template is declared here}}
+template struct Y4; // expected-error {{class template partial specialization is not more specialized than the primary template}}
+
+template struct W1;
+template struct W1 {};
+
+template struct W2;
+template struct W2 {};
+
+template
+concept C1 = C && C;
+template
+concept D1 = D && C;
+
+template auto T> struct W3;
+template auto T> struct W3 {};
+
+template auto... T> struct W4;
+template auto... T> struct W4 {};
+
+// FIXME: enable once Clang support non-trivial auto on NTTP.
+// template struct W5;
+// template struct W5 {};
+
+// FIXME: enable once Clang support non-trivial auto on NTTP.
+// template struct W6;
+// template struct W6 {};
+
+struct W1<0> w1;
+struct W2<0> w2;
+struct W3<0> w3;
+struct W4<0> w4;
+// FIXME: enable once Clang support non-trivial auto on NTTP.
+// struct W5<(int*)nullptr> w5;
+// struct W6 w6;
+}
 
 namespace PR53640 {
 
Index: clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
===
--- clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
+++ clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
@@ -98,26 +98,31 @@
   static_assert(is_same_v()), void>); // expected-error {{call to 'bar' is ambiguous}}
 
 

[PATCH] D128750: [C++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-10-14 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:5511-5539
+  template ::value, bool> = true>
+  bool operator()(T1 *PS1, T2 *PS2) {
+return hasEqualTemplateArgumentList(
+PS1->getTemplateArgsAsWritten()->arguments(),
+PS2->getTemplateArgsAsWritten()->arguments());
+  }

mizvekov wrote:
> I think you are not supposed to use the `TemplateArgsAsWritten` here.
> 
> The injected arguments are 'Converted' arguments, and the transformation 
> above, by unpacking the arguments, is reversing just a tiny part of the 
> conversion process.
> 
> It's not very meaningful to canonicalize the arguments as written to perform 
> a semantic comparison, as that works well just for some kinds of template 
> arguments, like types and templates, but not for other kinds in which the 
> conversion process is not trivial.
> 
> For example, I think this may fail to compare the same integers written in 
> different ways, like `2` vs `1 + 1`.
Indeed. It can happen only when comparing one partial specialization with 
another. I think the standard does not require an implementation to deal with 
this but we could use the best effort without much overhead. For `2` vs `1+1` 
or similar template arguments that are not dependent, we could assume the 
equivalence because they wouldn't be in the partial ordering stage if they're 
not equivalent. For more complicated cases like `J+2` vs `J+1+1` where J is 
NTTP, let's stop trying (match GCC) because the overhead is a little bit high. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128750: [C++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-10-14 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 467845.
ychen added a comment.

- skip non-dependent NTTP comparison because they're equivalent (match GCC)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclTemplate.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
  clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -963,7 +963,7 @@
   
   
 https://wg21.link/p2113r0;>P2113R0
-No
+Clang 16
   
 
 
Index: clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
+++ clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
@@ -1,10 +1,18 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
 
-struct A;
-struct B;
-
 template  constexpr bool True = true;
 template  concept C = True;
+template  concept D = C && sizeof(T) > 2;
+template  concept E = D && alignof(T) > 1;
+
+struct A {};
+template  struct S {};
+template  struct S2 {};
+template  struct X {};
+
+namespace p6 {
+
+struct B;
 
 void f(C auto &, auto &) = delete;
 template  void f(Q &, C auto &);
@@ -13,14 +21,125 @@
   f(*ap, *bp);
 }
 
-template  struct X {};
-
+#if 0
+// FIXME: [temp.func.order]p6.2.1 is not implemented, matching GCC.
 template  bool operator==(X, V) = delete;
 templatebool operator==(T, X);
 
 bool h() {
   return X{} == 0;
 }
+#endif
+
+template class U,
+ typename... Z>
+void foo(T, U) = delete;
+template class U,
+ typename... Z>
+void foo(T, U) = delete;
+template class U,
+ typename... Z>
+void foo(T, U);
+
+// check auto template parameter pack.
+template class U,
+ C auto... Z>
+void foo2(T, U) = delete;
+template class U,
+ D auto... Z>
+void foo2(T, U) = delete;
+template class U,
+ E auto... Z>
+void foo2(T, U);
+
+void bar(S s, S2 s2) {
+  foo(0, s);
+  foo2(0, s2);
+}
+
+template void bar2();
+template void bar2() = delete;
+
+} // namespace p6
+
+namespace TestConversionFunction {
+struct Y {
+  template operator X(); // expected-note {{candidate function [with T = int, U = int]}}
+  template operator X(); // expected-note {{candidate function [with T = int, U = int]}}
+};
+
+X f() {
+  return Y{}; // expected-error {{conversion from 'Y' to 'X' is ambiguous}}
+}
+}
+
+namespace ClassPartialSpecPartialOrdering {
+template struct Y { Y()=delete; }; // expected-note {{template is declared here}}
+template struct Y {}; // expected-error {{class template partial specialization is not more specialized than the primary template}}
+
+template struct Y1 { Y1()=delete; };
+template struct Y1  { Y1()=delete; };
+template struct Y1 {};
+
+template struct Y2 {};
+template struct Y2 {}; // expected-note {{partial specialization matches}}
+template struct Y2 {}; // expected-note {{partial specialization matches}}
+
+template class U, typename... Z>
+struct Y3 { Y3()=delete; };
+template class U, typename... Z>
+struct Y3 { Y3()=delete; };
+template class U, typename... Z>
+struct Y3 {};
+
+void f() {
+  Y1 a;
+  Y2 b; // expected-error {{ambiguous partial specializations}}
+  Y3 c;
+}
+
+template struct Y4; // expected-note {{template is declared here}}
+template struct Y4; // expected-error {{class template partial specialization is not more specialized than the primary template}}
+
+template struct W1;
+template struct W1 {};
+
+template struct W2;
+template struct W2 {};
+
+template
+concept C1 = C && C;
+template
+concept D1 = D && C;
+
+template auto T> struct W3;
+template auto T> struct W3 {};
+
+template auto... T> struct W4;
+template auto... T> struct W4 {};
+
+// FIXME: enable once Clang support non-trivial auto on NTTP.
+// template struct W5;
+// template struct W5 {};
+
+// FIXME: enable once Clang support non-trivial auto on NTTP.
+// template struct W6;
+// template struct W6 {};
+
+struct W1<0> w1;
+struct W2<0> w2;
+struct W3<0> w3;
+struct W4<0> w4;
+// FIXME: enable once Clang support non-trivial auto on NTTP.
+// struct W5<(int*)nullptr> w5;
+// struct W6 w6;
+}
 
 namespace PR53640 {
 
Index: clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
===
--- clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
+++ clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
@@ -98,26 +98,31 @@
   static_assert(is_same_v()), 

[PATCH] D128750: [C++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-10-13 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D128750#3854675 , 
@hubert.reinterpretcast wrote:

>> I reached out to the GCC author to confirm that the committee acknowledges 
>> that there should be a change to temp.func.order p6.2.1, but no consensus on 
>> what changes to make [3].
>
> A more accurate description is that some changes elsewhere to overload 
> resolution are probably needed, but no solution has been developed 
> sufficiently.

I've updated the patch description. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134507: [Clang] add missing ClangABICompat check

2022-10-13 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen abandoned this revision.
ychen added a comment.

Per further discussions in D128745 , this is 
not needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134507

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128745: [c++] implements DR692, DR1395 and tentatively DR1432, about partial ordering of variadic template partial specialization or function template

2022-10-12 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D128745#3851458 , @rjmccall wrote:

> Was this change in LLVM 15, or is it still unreleased?

This is still unreleased. It will be released in Clang16.

In D128745#3852409 , @aaron.ballman 
wrote:

> This sounds like a good plan to me. When you remove the ABI compat checks, 
> please be sure to add the clang-vendors group to the review and a release 
> note to the potentially breaking changes section. Once that lands, you should 
> also make an announcement in Discourse.

Will do. Thanks for the heads-up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128745

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128750: [C++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-10-12 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

@mizvekov it turns out I don't need that code anymore. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128750: [C++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-10-12 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 467031.
ychen added a comment.

- remove dead code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclTemplate.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
  clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -963,7 +963,7 @@
   
   
 https://wg21.link/p2113r0;>P2113R0
-No
+Clang 16
   
 
 
Index: clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
+++ clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
@@ -1,10 +1,18 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
 
-struct A;
-struct B;
-
 template  constexpr bool True = true;
 template  concept C = True;
+template  concept D = C && sizeof(T) > 2;
+template  concept E = D && alignof(T) > 1;
+
+struct A {};
+template  struct S {};
+template  struct S2 {};
+template  struct X {};
+
+namespace p6 {
+
+struct B;
 
 void f(C auto &, auto &) = delete;
 template  void f(Q &, C auto &);
@@ -13,14 +21,120 @@
   f(*ap, *bp);
 }
 
-template  struct X {};
-
+#if 0
+// FIXME: [temp.func.order]p6.2.1 is not implemented, matching GCC.
 template  bool operator==(X, V) = delete;
 templatebool operator==(T, X);
 
 bool h() {
   return X{} == 0;
 }
+#endif
+
+template class U,
+ typename... Z>
+void foo(T, U) = delete;
+template class U,
+ typename... Z>
+void foo(T, U) = delete;
+template class U,
+ typename... Z>
+void foo(T, U);
+
+// check auto template parameter pack.
+template class U,
+ C auto... Z>
+void foo2(T, U) = delete;
+template class U,
+ D auto... Z>
+void foo2(T, U) = delete;
+template class U,
+ E auto... Z>
+void foo2(T, U);
+
+void bar(S s, S2 s2) {
+  foo(0, s);
+  foo2(0, s2);
+}
+
+template void bar2();
+template void bar2() = delete;
+
+} // namespace p6
+
+namespace TestConversionFunction {
+struct Y {
+  template operator X(); // expected-note {{candidate function [with T = int, U = int]}}
+  template operator X(); // expected-note {{candidate function [with T = int, U = int]}}
+};
+
+X f() {
+  return Y{}; // expected-error {{conversion from 'Y' to 'X' is ambiguous}}
+}
+}
+
+namespace ClassPartialSpecPartialOrdering {
+template struct Y { Y()=delete; }; // expected-note {{template is declared here}}
+template struct Y {}; // expected-error {{class template partial specialization is not more specialized than the primary template}}
+
+template struct B{ B()=delete; };
+template struct B { B()=delete; };
+template struct B {};
+
+template class U, typename... Z>
+struct Some { Some()=delete; };
+template class U, typename... Z>
+struct Some { Some()=delete; };
+template class U, typename... Z>
+struct Some {};
+
+void f() {
+  B b;
+  Some c;
+}
+
+template struct Z; // expected-note {{template is declared here}}
+template struct Z; // expected-error {{class template partial specialization is not more specialized than the primary template}}
+
+template struct W1;
+template struct W1 {};
+
+template struct W2;
+template struct W2 {};
+
+template
+concept C1 = C && C;
+template
+concept D1 = D && C;
+
+template auto T> struct W3;
+template auto T> struct W3 {};
+
+template auto... T> struct W4;
+template auto... T> struct W4 {};
+
+// FIXME: enable once Clang support non-trivial auto on NTTP.
+// template struct W5;
+// template struct W5 {};
+
+// FIXME: enable once Clang support non-trivial auto on NTTP.
+// template struct W6;
+// template struct W6 {};
+
+struct W1<0> w1;
+struct W2<0> w2;
+struct W3<0> w3;
+struct W4<0> w4;
+// FIXME: enable once Clang support non-trivial auto on NTTP.
+// struct W5<(int*)nullptr> w5;
+// struct W6 w6;
+}
 
 namespace PR53640 {
 
Index: clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
===
--- clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
+++ clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
@@ -98,26 +98,31 @@
   static_assert(is_same_v()), void>); // expected-error {{call to 'bar' is ambiguous}}
 
   template
-  constexpr int goo(int a) requires AtLeast2 && true {
+  constexpr int goo(int a) requires AtLeast2 && true { // expected-note {{candidate function}}
 return 1;
   }
 
   template
-  constexpr int goo(const int b) 

[PATCH] D135045: [Frontend] Recognize environment variable SOURCE_DATE_EPOCH

2022-10-11 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen accepted this revision as: ychen.
ychen added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135045

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128745: [c++] implements DR692, DR1395 and tentatively DR1432, about partial ordering of variadic template partial specialization or function template

2022-10-11 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D128745#3850667 , 
@hubert.reinterpretcast wrote:

> In D128745#3834435 , @ychen wrote:
>
>> New flag or not, as long as we allow users to use the old behavior, it is 
>> already fracturing the ecosystem. Do you mean (1) we shouldn't give the user 
>> the choices or  (2) we allow users to use the old behavior but only for a 
>> few releases and then remove the flag? I think (1) is a little bit harsh but 
>> I would not say it is disruptive. (2) is more user-friendly.
>
> (1) has been the default absent information to indicate that the new 
> behaviour is not ready for deployment (because it would cause widespread 
> disruption). To consider alternatives would require information about the 
> nature of the deployment difficulties.

Agreed.

To all:
As a next step, I'll remove the ClangABICompat checks for these DRs (make these 
DRs effective unconditionally). If we saw proof that these have deployment 
difficulties. We can (1) re-run the rules with the committee as suggested by 
@rjmccall; (2) consider alternatives (including reverting these DRs) based on 
the feedback.  Please let me know if you object to this or have any other 
concerns.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128745

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128750: [C++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-10-11 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

Hi @mizvekov , after D135088 , this patch is 
ready.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D135045: [Frontend] Recognize environment variable SOURCE_DATE_EPOCH

2022-10-11 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/lib/Lex/PPMacroExpansion.cpp:1612
+  time_t TT = *getPreprocessorOpts().SourceDateEpoch;
+  std::tm *TM = std::gmtime();
   Result = asctime(TM);

MaskRay wrote:
> ychen wrote:
> > To be consistent with existing code, it might be better to use 
> > `std::localtime` instead of `std::gmtime`?
> No. This must use `std::gmtime`. localtime would introduce an undesired UTC 
> time offset.
Are you sure? https://linux.die.net/man/3/localtime  gmtime/localtime both 
accept a UTC time. I think the only difference is the time zone.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135045

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D135045: [Frontend] Recognize environment variable SOURCE_DATE_EPOCH

2022-10-11 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

Looks good to me except for one nit. And the test still fails on Windows for 
some reason.




Comment at: clang/lib/Lex/PPMacroExpansion.cpp:1612
+  time_t TT = *getPreprocessorOpts().SourceDateEpoch;
+  std::tm *TM = std::gmtime();
   Result = asctime(TM);

To be consistent with existing code, it might be better to use `std::localtime` 
instead of `std::gmtime`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135045

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D135115: [clang-format] update --files help description

2022-10-11 Thread Yuanfang Chen 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 rG2c94f75f00af: [clang-format] update --files help description 
(authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135115

Files:
  clang/docs/ClangFormat.rst
  clang/tools/clang-format/ClangFormat.cpp


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -125,9 +125,11 @@
  "determined by the QualifierAlignment style flag"),
 cl::init(""), cl::cat(ClangFormatCategory));
 
-static cl::opt
-Files("files", cl::desc("Provide a list of files to run clang-format"),
-  cl::init(""), cl::cat(ClangFormatCategory));
+static cl::opt Files(
+"files",
+cl::desc("A file containing a list of files to process, one per line."),
+cl::value_desc("filename"),
+cl::init(""), cl::cat(ClangFormatCategory));
 
 static cl::opt
 Verbose("verbose", cl::desc("If set, shows the list of processed files"),
Index: clang/docs/ClangFormat.rst
===
--- clang/docs/ClangFormat.rst
+++ clang/docs/ClangFormat.rst
@@ -26,7 +26,7 @@
   together with s, the files are edited in-place. Otherwise, the
   result is written to the standard output.
 
-  USAGE: clang-format [options] [ ...]
+  USAGE: clang-format [options] [@] [ ...]
 
   OPTIONS:
 
@@ -69,7 +69,8 @@
 --ferror-limit=  - Set the maximum number of clang-format 
errors to emit
  before stopping (0 = no limit).
  Used only with --dry-run or -n
---files=   - Provide a list of files to run 
clang-format
+--files= - A file containing a list of files to 
process, one
+ per line.
 -i - Inplace edit s, if specified.
 --length=- Format a range of this length (in bytes).
  Multiple ranges can be formatted by 
specifying


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -125,9 +125,11 @@
  "determined by the QualifierAlignment style flag"),
 cl::init(""), cl::cat(ClangFormatCategory));
 
-static cl::opt
-Files("files", cl::desc("Provide a list of files to run clang-format"),
-  cl::init(""), cl::cat(ClangFormatCategory));
+static cl::opt Files(
+"files",
+cl::desc("A file containing a list of files to process, one per line."),
+cl::value_desc("filename"),
+cl::init(""), cl::cat(ClangFormatCategory));
 
 static cl::opt
 Verbose("verbose", cl::desc("If set, shows the list of processed files"),
Index: clang/docs/ClangFormat.rst
===
--- clang/docs/ClangFormat.rst
+++ clang/docs/ClangFormat.rst
@@ -26,7 +26,7 @@
   together with s, the files are edited in-place. Otherwise, the
   result is written to the standard output.
 
-  USAGE: clang-format [options] [ ...]
+  USAGE: clang-format [options] [@] [ ...]
 
   OPTIONS:
 
@@ -69,7 +69,8 @@
 --ferror-limit=  - Set the maximum number of clang-format errors to emit
  before stopping (0 = no limit).
  Used only with --dry-run or -n
---files=   - Provide a list of files to run clang-format
+--files= - A file containing a list of files to process, one
+ per line.
 -i - Inplace edit s, if specified.
 --length=- Format a range of this length (in bytes).
  Multiple ranges can be formatted by specifying
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D135115: [clang-format] update --files help description

2022-10-06 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D135115#3839547 , 
@HazardyKnusperkeks wrote:

> Except for the `@` part. (Which also isn't handles by clang-format, or 
> is it?)

It is not. It is handled by the LLVM commandline library. 
https://llvm.org/docs/CommandLine.html#response-files


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135115

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D135045: [Frontend] Recognize environment variable SOURCE_DATE_EPOCH

2022-10-05 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/lib/Lex/PPMacroExpansion.cpp:1092
+TT = *PP.getPreprocessorOpts().SourceDateEpoch;
+TM = std::gmtime();
+  } else {

MaskRay wrote:
> ychen wrote:
> > MaskRay wrote:
> > > ychen wrote:
> > > > Why not use localtime as the else branch?
> > > > 
> > > > As mentioned above, diagnose null TM here or when parsing the 
> > > > user-specifed value. A small trade-off to make, up to you.
> > > Can you elaborate? With the check in Frontend I think a check here is not 
> > > necessary...
> > Sorry I was not clear. The time_t value is not portable so it is hard to 
> > diagnose in a target-independent way. For example, `253402300799` is too 
> > big of a value for windows that `gmtime` returns null (causes crash at 
> > `asctime` in the similar case below). We could diagnose when 
> > gmtime/localtime returns null, which is portable.
> I am still confused. In practice, a 64-bit `gmtime` implementation may 
> returns null when `tm_year` would overflow while 32-bit `gmtime` can't. The 
> way (with a more restricted upper bound) we check SOURCE_DATE_EPOCH in 
> Frontend, `std::gmtime();` cannot return null. `localtime()` for 
> `time(nullptr)` may overflow as where but that is an pre-existing issue.
> std::gmtime(); cannot return null

I couldn't find good references for this. But on windows, it may return null 
(as the premerge CI shows). https://godbolt.org/z/jfxdG3KrM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135045

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D135045: [Frontend] Recognize environment variable SOURCE_DATE_EPOCH

2022-10-05 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/lib/Lex/PPMacroExpansion.cpp:1092
+TT = *PP.getPreprocessorOpts().SourceDateEpoch;
+TM = std::gmtime();
+  } else {

MaskRay wrote:
> ychen wrote:
> > Why not use localtime as the else branch?
> > 
> > As mentioned above, diagnose null TM here or when parsing the user-specifed 
> > value. A small trade-off to make, up to you.
> Can you elaborate? With the check in Frontend I think a check here is not 
> necessary...
Sorry I was not clear. The time_t value is not portable so it is hard to 
diagnose in a target-independent way. For example, `253402300799` is too big of 
a value for windows that `gmtime` returns null (causes crash at `asctime` in 
the similar case below). We could diagnose when gmtime/localtime returns null, 
which is portable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135045

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128750: [C++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-10-05 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 465549.
ychen added a comment.

- rebased on D135088 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclTemplate.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/SemaConcept.h
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
  clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -963,7 +963,7 @@
   
   
 https://wg21.link/p2113r0;>P2113R0
-No
+Clang 16
   
 
 
Index: clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
+++ clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
@@ -1,10 +1,18 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
 
-struct A;
-struct B;
-
 template  constexpr bool True = true;
 template  concept C = True;
+template  concept D = C && sizeof(T) > 2;
+template  concept E = D && alignof(T) > 1;
+
+struct A {};
+template  struct S {};
+template  struct S2 {};
+template  struct X {};
+
+namespace p6 {
+
+struct B;
 
 void f(C auto &, auto &) = delete;
 template  void f(Q &, C auto &);
@@ -13,14 +21,120 @@
   f(*ap, *bp);
 }
 
-template  struct X {};
-
+#if 0
+// FIXME: [temp.func.order]p6.2.1 is not implemented, matching GCC.
 template  bool operator==(X, V) = delete;
 templatebool operator==(T, X);
 
 bool h() {
   return X{} == 0;
 }
+#endif
+
+template class U,
+ typename... Z>
+void foo(T, U) = delete;
+template class U,
+ typename... Z>
+void foo(T, U) = delete;
+template class U,
+ typename... Z>
+void foo(T, U);
+
+// check auto template parameter pack.
+template class U,
+ C auto... Z>
+void foo2(T, U) = delete;
+template class U,
+ D auto... Z>
+void foo2(T, U) = delete;
+template class U,
+ E auto... Z>
+void foo2(T, U);
+
+void bar(S s, S2 s2) {
+  foo(0, s);
+  foo2(0, s2);
+}
+
+template void bar2();
+template void bar2() = delete;
+
+} // namespace p6
+
+namespace TestConversionFunction {
+struct Y {
+  template operator X(); // expected-note {{candidate function [with T = int, U = int]}}
+  template operator X(); // expected-note {{candidate function [with T = int, U = int]}}
+};
+
+X f() {
+  return Y{}; // expected-error {{conversion from 'Y' to 'X' is ambiguous}}
+}
+}
+
+namespace ClassPartialSpecPartialOrdering {
+template struct Y { Y()=delete; }; // expected-note {{template is declared here}}
+template struct Y {}; // expected-error {{class template partial specialization is not more specialized than the primary template}}
+
+template struct B{ B()=delete; };
+template struct B { B()=delete; };
+template struct B {};
+
+template class U, typename... Z>
+struct Some { Some()=delete; };
+template class U, typename... Z>
+struct Some { Some()=delete; };
+template class U, typename... Z>
+struct Some {};
+
+void f() {
+  B b;
+  Some c;
+}
+
+template struct Z; // expected-note {{template is declared here}}
+template struct Z; // expected-error {{class template partial specialization is not more specialized than the primary template}}
+
+template struct W1;
+template struct W1 {};
+
+template struct W2;
+template struct W2 {};
+
+template
+concept C1 = C && C;
+template
+concept D1 = D && C;
+
+template auto T> struct W3;
+template auto T> struct W3 {};
+
+template auto... T> struct W4;
+template auto... T> struct W4 {};
+
+// FIXME: enable once Clang support non-trivial auto on NTTP.
+// template struct W5;
+// template struct W5 {};
+
+// FIXME: enable once Clang support non-trivial auto on NTTP.
+// template struct W6;
+// template struct W6 {};
+
+struct W1<0> w1;
+struct W2<0> w2;
+struct W3<0> w3;
+struct W4<0> w4;
+// FIXME: enable once Clang support non-trivial auto on NTTP.
+// struct W5<(int*)nullptr> w5;
+// struct W6 w6;
+}
 
 namespace PR53640 {
 
Index: clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
===
--- clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
+++ clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
@@ -98,26 +98,31 @@
   static_assert(is_same_v()), void>); // expected-error {{call to 'bar' is ambiguous}}
 
   template
-  constexpr int goo(int a) requires AtLeast2 && true {
+  constexpr int goo(int a) requires AtLeast2 && true { // expected-note {{candidate 

[PATCH] D128750: [C++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-10-05 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 465547.
ychen added a comment.

- rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclTemplate.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/SemaConcept.h
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
  clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -963,7 +963,7 @@
   
   
 https://wg21.link/p2113r0;>P2113R0
-No
+Clang 16
   
 
 
Index: clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
+++ clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
@@ -1,10 +1,18 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
 
-struct A;
-struct B;
-
 template  constexpr bool True = true;
 template  concept C = True;
+template  concept D = C && sizeof(T) > 2;
+template  concept E = D && alignof(T) > 1;
+
+struct A {};
+template  struct S {};
+template  struct S2 {};
+template  struct X {};
+
+namespace p6 {
+
+struct B;
 
 void f(C auto &, auto &) = delete;
 template  void f(Q &, C auto &);
@@ -13,14 +21,120 @@
   f(*ap, *bp);
 }
 
-template  struct X {};
-
+#if 0
+// FIXME: [temp.func.order]p6.2.1 is not implemented, matching GCC.
 template  bool operator==(X, V) = delete;
 templatebool operator==(T, X);
 
 bool h() {
   return X{} == 0;
 }
+#endif
+
+template class U,
+ typename... Z>
+void foo(T, U) = delete;
+template class U,
+ typename... Z>
+void foo(T, U) = delete;
+template class U,
+ typename... Z>
+void foo(T, U);
+
+// check auto template parameter pack.
+template class U,
+ C auto... Z>
+void foo2(T, U) = delete;
+template class U,
+ D auto... Z>
+void foo2(T, U) = delete;
+template class U,
+ E auto... Z>
+void foo2(T, U);
+
+void bar(S s, S2 s2) {
+  foo(0, s);
+  foo2(0, s2);
+}
+
+template void bar2();
+template void bar2() = delete;
+
+} // namespace p6
+
+namespace TestConversionFunction {
+struct Y {
+  template operator X(); // expected-note {{candidate function [with T = int, U = int]}}
+  template operator X(); // expected-note {{candidate function [with T = int, U = int]}}
+};
+
+X f() {
+  return Y{}; // expected-error {{conversion from 'Y' to 'X' is ambiguous}}
+}
+}
+
+namespace ClassPartialSpecPartialOrdering {
+template struct Y { Y()=delete; }; // expected-note {{template is declared here}}
+template struct Y {}; // expected-error {{class template partial specialization is not more specialized than the primary template}}
+
+template struct B{ B()=delete; };
+template struct B { B()=delete; };
+template struct B {};
+
+template class U, typename... Z>
+struct Some { Some()=delete; };
+template class U, typename... Z>
+struct Some { Some()=delete; };
+template class U, typename... Z>
+struct Some {};
+
+void f() {
+  B b;
+  Some c;
+}
+
+template struct Z; // expected-note {{template is declared here}}
+template struct Z; // expected-error {{class template partial specialization is not more specialized than the primary template}}
+
+template struct W1;
+template struct W1 {};
+
+template struct W2;
+template struct W2 {};
+
+template
+concept C1 = C && C;
+template
+concept D1 = D && C;
+
+template auto T> struct W3;
+template auto T> struct W3 {};
+
+template auto... T> struct W4;
+template auto... T> struct W4 {};
+
+// FIXME: enable once Clang support non-trivial auto on NTTP.
+// template struct W5;
+// template struct W5 {};
+
+// FIXME: enable once Clang support non-trivial auto on NTTP.
+// template struct W6;
+// template struct W6 {};
+
+struct W1<0> w1;
+struct W2<0> w2;
+struct W3<0> w3;
+struct W4<0> w4;
+// FIXME: enable once Clang support non-trivial auto on NTTP.
+// struct W5<(int*)nullptr> w5;
+// struct W6 w6;
+}
 
 namespace PR53640 {
 
Index: clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
===
--- clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
+++ clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
@@ -98,26 +98,31 @@
   static_assert(is_same_v()), void>); // expected-error {{call to 'bar' is ambiguous}}
 
   template
-  constexpr int goo(int a) requires AtLeast2 && true {
+  constexpr int goo(int a) requires AtLeast2 && true { // expected-note {{candidate function}}
 return 1;
   }
 
   template
-  

[PATCH] D128750: [C++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-10-05 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 465543.
ychen added a comment.

- rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclTemplate.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/SemaConcept.h
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
  clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -963,7 +963,7 @@
   
   
 https://wg21.link/p2113r0;>P2113R0
-No
+Clang 16
   
 
 
Index: clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
+++ clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
@@ -1,10 +1,18 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
 
-struct A;
-struct B;
-
 template  constexpr bool True = true;
 template  concept C = True;
+template  concept D = C && sizeof(T) > 2;
+template  concept E = D && alignof(T) > 1;
+
+struct A {};
+template  struct S {};
+template  struct S2 {};
+template  struct X {};
+
+namespace p6 {
+
+struct B;
 
 void f(C auto &, auto &) = delete;
 template  void f(Q &, C auto &);
@@ -13,14 +21,120 @@
   f(*ap, *bp);
 }
 
-template  struct X {};
-
+#if 0
+// FIXME: [temp.func.order]p6.2.1 is not implemented, matching GCC.
 template  bool operator==(X, V) = delete;
 templatebool operator==(T, X);
 
 bool h() {
   return X{} == 0;
 }
+#endif
+
+template class U,
+ typename... Z>
+void foo(T, U) = delete;
+template class U,
+ typename... Z>
+void foo(T, U) = delete;
+template class U,
+ typename... Z>
+void foo(T, U);
+
+// check auto template parameter pack.
+template class U,
+ C auto... Z>
+void foo2(T, U) = delete;
+template class U,
+ D auto... Z>
+void foo2(T, U) = delete;
+template class U,
+ E auto... Z>
+void foo2(T, U);
+
+void bar(S s, S2 s2) {
+  foo(0, s);
+  foo2(0, s2);
+}
+
+template void bar2();
+template void bar2() = delete;
+
+} // namespace p6
+
+namespace TestConversionFunction {
+struct Y {
+  template operator X(); // expected-note {{candidate function [with T = int, U = int]}}
+  template operator X(); // expected-note {{candidate function [with T = int, U = int]}}
+};
+
+X f() {
+  return Y{}; // expected-error {{conversion from 'Y' to 'X' is ambiguous}}
+}
+}
+
+namespace ClassPartialSpecPartialOrdering {
+template struct Y { Y()=delete; }; // expected-note {{template is declared here}}
+template struct Y {}; // expected-error {{class template partial specialization is not more specialized than the primary template}}
+
+template struct B{ B()=delete; };
+template struct B { B()=delete; };
+template struct B {};
+
+template class U, typename... Z>
+struct Some { Some()=delete; };
+template class U, typename... Z>
+struct Some { Some()=delete; };
+template class U, typename... Z>
+struct Some {};
+
+void f() {
+  B b;
+  Some c;
+}
+
+template struct Z; // expected-note {{template is declared here}}
+template struct Z; // expected-error {{class template partial specialization is not more specialized than the primary template}}
+
+template struct W1;
+template struct W1 {};
+
+template struct W2;
+template struct W2 {};
+
+template
+concept C1 = C && C;
+template
+concept D1 = D && C;
+
+template auto T> struct W3;
+template auto T> struct W3 {};
+
+template auto... T> struct W4;
+template auto... T> struct W4 {};
+
+// FIXME: enable once Clang support non-trivial auto on NTTP.
+// template struct W5;
+// template struct W5 {};
+
+// FIXME: enable once Clang support non-trivial auto on NTTP.
+// template struct W6;
+// template struct W6 {};
+
+struct W1<0> w1;
+struct W2<0> w2;
+struct W3<0> w3;
+struct W4<0> w4;
+// FIXME: enable once Clang support non-trivial auto on NTTP.
+// struct W5<(int*)nullptr> w5;
+// struct W6 w6;
+}
 
 namespace PR53640 {
 
Index: clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
===
--- clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
+++ clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
@@ -98,26 +98,31 @@
   static_assert(is_same_v()), void>); // expected-error {{call to 'bar' is ambiguous}}
 
   template
-  constexpr int goo(int a) requires AtLeast2 && true {
+  constexpr int goo(int a) requires AtLeast2 && true { // expected-note {{candidate function}}
 return 1;
   }
 
   template
-  

[PATCH] D135045: [Frontend] Recognize environment variable SOURCE_DATE_EPOCH

2022-10-05 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:4313
+// 253402300799 is the UNIX timestamp of -12-31T23:59:59Z.
+if (StringRef(Epoch).getAsInteger(10, V) || V > 253402300799)
+  Diags.Report(diag::err_fe_invalid_source_date_epoch) << Epoch;

The time_t value may be negative and its value range is platform-dependent. It 
is better to be as transparent as possible. gmtime/localtime should be able to 
do the check by returning nullptr.

getAsInteger could handle V as time_t directly.



Comment at: clang/lib/Lex/PPMacroExpansion.cpp:1092
+TT = *PP.getPreprocessorOpts().SourceDateEpoch;
+TM = std::gmtime();
+  } else {

Why not use localtime as the else branch?

As mentioned above, diagnose null TM here or when parsing the user-specifed 
value. A small trade-off to make, up to you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135045

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134772: [Clang] Make constraints of auto part of NTTP instead of AutoType

2022-10-05 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen abandoned this revision.
ychen added a comment.

D135088  was landed instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134772

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D135115: [clang-format] update --files help description

2022-10-04 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 465151.
ychen added a comment.

- make corresponding change in the commandline


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135115

Files:
  clang/docs/ClangFormat.rst
  clang/tools/clang-format/ClangFormat.cpp


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -125,9 +125,11 @@
  "determined by the QualifierAlignment style flag"),
 cl::init(""), cl::cat(ClangFormatCategory));
 
-static cl::opt
-Files("files", cl::desc("Provide a list of files to run clang-format"),
-  cl::init(""), cl::cat(ClangFormatCategory));
+static cl::opt Files(
+"files",
+cl::desc("A file containing a list of files to process, one per line."),
+cl::value_desc("filename"),
+cl::init(""), cl::cat(ClangFormatCategory));
 
 static cl::opt
 Verbose("verbose", cl::desc("If set, shows the list of processed files"),
Index: clang/docs/ClangFormat.rst
===
--- clang/docs/ClangFormat.rst
+++ clang/docs/ClangFormat.rst
@@ -26,7 +26,7 @@
   together with s, the files are edited in-place. Otherwise, the
   result is written to the standard output.
 
-  USAGE: clang-format [options] [ ...]
+  USAGE: clang-format [options] [@] [ ...]
 
   OPTIONS:
 
@@ -69,7 +69,8 @@
 --ferror-limit=  - Set the maximum number of clang-format 
errors to emit
  before stopping (0 = no limit).
  Used only with --dry-run or -n
---files=   - Provide a list of files to run 
clang-format
+--files= - A file containing a list of files to 
process, one
+ per line.
 -i - Inplace edit s, if specified.
 --length=- Format a range of this length (in bytes).
  Multiple ranges can be formatted by 
specifying


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -125,9 +125,11 @@
  "determined by the QualifierAlignment style flag"),
 cl::init(""), cl::cat(ClangFormatCategory));
 
-static cl::opt
-Files("files", cl::desc("Provide a list of files to run clang-format"),
-  cl::init(""), cl::cat(ClangFormatCategory));
+static cl::opt Files(
+"files",
+cl::desc("A file containing a list of files to process, one per line."),
+cl::value_desc("filename"),
+cl::init(""), cl::cat(ClangFormatCategory));
 
 static cl::opt
 Verbose("verbose", cl::desc("If set, shows the list of processed files"),
Index: clang/docs/ClangFormat.rst
===
--- clang/docs/ClangFormat.rst
+++ clang/docs/ClangFormat.rst
@@ -26,7 +26,7 @@
   together with s, the files are edited in-place. Otherwise, the
   result is written to the standard output.
 
-  USAGE: clang-format [options] [ ...]
+  USAGE: clang-format [options] [@] [ ...]
 
   OPTIONS:
 
@@ -69,7 +69,8 @@
 --ferror-limit=  - Set the maximum number of clang-format errors to emit
  before stopping (0 = no limit).
  Used only with --dry-run or -n
---files=   - Provide a list of files to run clang-format
+--files= - A file containing a list of files to process, one
+ per line.
 -i - Inplace edit s, if specified.
 --length=- Format a range of this length (in bytes).
  Multiple ranges can be formatted by specifying
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D135115: [clang-format] update --files help description

2022-10-04 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 465134.
ychen added a comment.

- address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135115

Files:
  clang/docs/ClangFormat.rst


Index: clang/docs/ClangFormat.rst
===
--- clang/docs/ClangFormat.rst
+++ clang/docs/ClangFormat.rst
@@ -26,7 +26,7 @@
   together with s, the files are edited in-place. Otherwise, the
   result is written to the standard output.
 
-  USAGE: clang-format [options] [ ...]
+  USAGE: clang-format [options] [@] [ ...] 
 
   OPTIONS:
 
@@ -69,7 +69,8 @@
 --ferror-limit=  - Set the maximum number of clang-format 
errors to emit
  before stopping (0 = no limit).
  Used only with --dry-run or -n
---files=   - Provide a list of files to run 
clang-format
+--files= - A file containing a list of files to 
process, one
+ per line.
 -i - Inplace edit s, if specified.
 --length=- Format a range of this length (in bytes).
  Multiple ranges can be formatted by 
specifying


Index: clang/docs/ClangFormat.rst
===
--- clang/docs/ClangFormat.rst
+++ clang/docs/ClangFormat.rst
@@ -26,7 +26,7 @@
   together with s, the files are edited in-place. Otherwise, the
   result is written to the standard output.
 
-  USAGE: clang-format [options] [ ...]
+  USAGE: clang-format [options] [@] [ ...] 
 
   OPTIONS:
 
@@ -69,7 +69,8 @@
 --ferror-limit=  - Set the maximum number of clang-format errors to emit
  before stopping (0 = no limit).
  Used only with --dry-run or -n
---files=   - Provide a list of files to run clang-format
+--files= - A file containing a list of files to process, one
+ per line.
 -i - Inplace edit s, if specified.
 --length=- Format a range of this length (in bytes).
  Multiple ranges can be formatted by specifying
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D135088: [Clang] make canonical AutoType constraints-free

2022-10-04 Thread Yuanfang Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
ychen marked an inline comment as done.
Closed by commit rG5d69937b9f9c: [Clang] make canonical AutoType 
constraints-free (authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135088

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp

Index: clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
===
--- clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
+++ clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
@@ -82,18 +82,12 @@
   template  class A {};
 
   template  C auto e(A) { return 0; }
-
-  // FIXME: The error here does not make sense.
   template auto e<>(A<>);
-  // expected-error@-1 {{explicit instantiation of 'e' does not refer to a function template}}
-  // expected-note@-5  {{candidate template ignored: failed template argument deduction}}
-
-  // FIXME: Should be able to instantiate this with no errors.
-  template C auto e(A);
-  // expected-error@-1 {{explicit instantiation of 'e' does not refer to a function template}}
-  // expected-note@-10 {{candidate template ignored: could not match 'C auto' against 'C auto'}}
-  
-  template C<> auto e<>(A<>);
+  template auto e(A);
+
+  template  C auto d(A) { return 0; }
+  template C<> auto d<>(A<>);
+  template C auto d(A);
 
   template  A c(Ts...);
   int f = e(c(1, 2));
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -7943,12 +7943,26 @@
  : Kind),
 TemplateArgLoc))
   return false;
-  } else if (Kind != Sema::TPL_TemplateTemplateArgumentMatch) {
+  }
+
+  if (Kind != Sema::TPL_TemplateTemplateArgumentMatch &&
+  !isa(Old)) {
 const Expr *NewC = nullptr, *OldC = nullptr;
-if (const auto *TC = cast(New)->getTypeConstraint())
-  NewC = TC->getImmediatelyDeclaredConstraint();
-if (const auto *TC = cast(Old)->getTypeConstraint())
-  OldC = TC->getImmediatelyDeclaredConstraint();
+
+if (isa(New)) {
+  if (const auto *TC = cast(New)->getTypeConstraint())
+NewC = TC->getImmediatelyDeclaredConstraint();
+  if (const auto *TC = cast(Old)->getTypeConstraint())
+OldC = TC->getImmediatelyDeclaredConstraint();
+} else if (isa(New)) {
+  if (const Expr *E = cast(New)
+  ->getPlaceholderTypeConstraint())
+NewC = E;
+  if (const Expr *E = cast(Old)
+  ->getPlaceholderTypeConstraint())
+OldC = E;
+} else
+  llvm_unreachable("unexpected template parameter type");
 
 auto Diagnose = [&] {
   S.Diag(NewC ? NewC->getBeginLoc() : New->getBeginLoc(),
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -8666,10 +8666,11 @@
   // C++2a [class.spaceship]p2 [P2002R0]:
   //   Let R be the declared return type [...]. If R is auto, [...]. Otherwise,
   //   R shall not contain a placeholder type.
-  if (DCK == DefaultedComparisonKind::ThreeWay &&
-  FD->getDeclaredReturnType()->getContainedDeducedType() &&
-  !Context.hasSameType(FD->getDeclaredReturnType(),
-   Context.getAutoDeductType())) {
+  if (QualType RT = FD->getDeclaredReturnType();
+  DCK == DefaultedComparisonKind::ThreeWay &&
+  RT->getContainedDeducedType() &&
+  (!Context.hasSameType(RT, Context.getAutoDeductType()) ||
+   RT->getContainedAutoType()->isConstrained())) {
 Diag(FD->getLocation(),
  diag::err_defaulted_comparison_deduced_return_type_not_auto)
 << (int)DCK << FD->getDeclaredReturnType() << Context.AutoDeductTy
Index: clang/lib/AST/DeclTemplate.cpp
===
--- clang/lib/AST/DeclTemplate.cpp
+++ clang/lib/AST/DeclTemplate.cpp
@@ -529,6 +529,9 @@
   ID.AddInteger(0);
   ID.AddBoolean(NTTP->isParameterPack());
   NTTP->getType().getCanonicalType().Profile(ID);
+  ID.AddBoolean(NTTP->hasPlaceholderTypeConstraint());
+  if (const Expr *E = NTTP->getPlaceholderTypeConstraint())
+E->Profile(ID, C, /*Canonical=*/true);
   continue;
 }
 if (const auto *TTP = dyn_cast(D)) {
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -696,7 +696,11 @@
 if (const auto *NTTP = dyn_cast(*P)) {
   ID.AddInteger(1);
   ID.AddBoolean(NTTP->isParameterPack());
+  const Expr *TC = 

[PATCH] D128745: [c++] implements DR692, DR1395 and tentatively DR1432, about partial ordering of variadic template partial specialization or function template

2022-10-04 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D128745#3834454 , @tahonermann 
wrote:

> Is it known what gcc and Microsoft maintainers are going to do with these 
> DRs? I don't see any recent changes in gcc, but the following is 
> interesting...

It's hard to tell if they didn't implement these DRs or if they're broken. But 
for P2113  (C++20) to work, DR692 is needed.

> For the test below, Clang has historically accepted it but now rejects it. 
> MSVC has historically rejected it, but started accepting it for v19.34 
> (perhaps a regression?). Gcc continues to accept it. See 
> https://godbolt.org/z/jax3GsYY5.
>
>   struct map {
> template 
> map(Sequence&& seq , void* = 0 );
> template 
> map(First&& first, T_&&... rest);
>   };
>   map m(0);

This should be ambiguous. Only the first parameter should be considered for 
partial ordering. This is basically the `g(42)` example in 
https://eel.is/c++draft/temp.func.order#example-4.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128745

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   4   5   6   7   >