[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-11-03 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 558001.
bolshakov-a added a comment.

One more problem has been discovered and fixed: IR emitting didn't work when 
using a subobject as a template argument when the corresponding template 
parameter is used in an lvalue context. A test case has been added into 
`CodeGenCXX/template-arguments.cpp` test (but, maybe, there is a more 
appropriate place?)


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/drs/dr12xx.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Index/USR/structural-value-tpl-arg.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7218,6 +7218,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::StructuralValue:
+return eTemplateArgumentKindStructuralValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -856,6 +856,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindStructuralValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -626,13 +626,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2;>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1;>P1907R1
+  
+
+  Clang 18 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. declared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1;>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3;>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::StructuralValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ 

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-11-03 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 557997.
bolshakov-a added a comment.

Fixes after review.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/drs/dr12xx.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Index/USR/structural-value-tpl-arg.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7218,6 +7218,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::StructuralValue:
+return eTemplateArgumentKindStructuralValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -856,6 +856,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindStructuralValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -626,13 +626,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2;>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1;>P1907R1
+  
+
+  Clang 18 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. declared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1;>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3;>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::StructuralValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1574,6 +1574,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::StructuralValue:
+if (Expr *E = TAL.getSourceStructuralValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-11-03 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:2205-2206
   "bit-field%select{| %1}2">;
+def err_reference_bind_to_bitfield_in_cce : Error<
+  "reference cannot bind to bit-field in converted constant expression">;
 def err_reference_bind_to_vector_element : Error<

aaron.ballman wrote:
> This change seems somewhat orthogonal to the rest of the patch; should this 
> be split out? Also, there doesn't appear to be test coverage for the new 
> diagnostic.
Separated into https://github.com/llvm/llvm-project/pull/71077

The problem showed up after one of rebasings when C++20 mode was turned on for 
`CXX/drs/dr12xx.cpp` test in [that 
commit](https://github.com/llvm/llvm-project/commit/653a82e95257a7cd3f22c24e40d54459a6608429).



Comment at: clang/lib/AST/ItaniumMangle.cpp:4397
+// argument.
+// As proposed in https://github.com/itanium-cxx-abi/cxx-abi/issues/111.
+auto *SNTTPE = cast(E);

aaron.ballman wrote:
> bolshakov-a wrote:
> > bolshakov-a wrote:
> > > efriedma wrote:
> > > > bolshakov-a wrote:
> > > > > erichkeane wrote:
> > > > > > erichkeane wrote:
> > > > > > > aaron.ballman wrote:
> > > > > > > > We should get this nailed down. It was proposed in Nov 2020 and 
> > > > > > > > the issue is still open. CC @rjmccall 
> > > > > > > This definitely needs to happen.  @rjmccall or @eli.friedman ^^ 
> > > > > > > Any idea what the actual mangling should be?
> > > > > > This is still an open, and we need @rjmccall @eli.friedman or @asl 
> > > > > > to help out here.
> > > > > Ping @efriedma, @rjmccall, @asl.
> > > > I'm not really familiar with the mangling implications for this 
> > > > particular construct, nor am I actively involved with the Itanium ABI 
> > > > specification, so I'm not sure how I can help you directly.
> > > > 
> > > > That said, as a general opinion, I don't think it's worth waiting for 
> > > > updates to the Itanuim ABI  document to be merged; such updates are 
> > > > happening slowly at the moment, and having a consistent mangling is 
> > > > clearly an improvement even if it's not specified.  My suggested plan 
> > > > of action:
> > > > 
> > > > - Make sure you're satisfied the proposed mangling doesn't have any 
> > > > holes you're concerned about (i.e. it produces a unique mangling for 
> > > > all the relevant cases).  If you're not sure, I can try to spend some 
> > > > time understanding this, but it doesn't sound like you have any 
> > > > concerns about this.
> > > > - Put a note on the issue in the Itanium ABI repo that you're planning 
> > > > to go ahead with using this mangling in clang.  Also send an email 
> > > > directly to @rjmccall and @rsmith in case they miss the notifications.
> > > > - Go ahead with this.
> > > > Put a note on the issue in the Itanium ABI repo that you're planning to 
> > > > go ahead with using this mangling in clang. Also send an email directly 
> > > > to @rjmccall and @rsmith in case they miss the notifications.
> > > 
> > > I'm sorry for noting one more time that Richard already pushed these 
> > > changes in clang upstream, but they had been just reverted.
> > > 
> > > Maybe, I should make a PR into Itanium API repository, but I probably 
> > > need some time to dig into the theory and all the discussions. But yes, 
> > > even NTTP argument mangling rules are not still merged: 
> > > https://github.com/itanium-cxx-abi/cxx-abi/pull/140
> > @aaron.ballman, @erichkeane, seems like it is already fixed in the ABI 
> > document:
> > > Typically, only references to function template parameters occurring 
> > > within the dependent signature of the template are mangled this way. In 
> > > other contexts, template instantiation replaces references to template 
> > > parameters with the actual template arguments, and mangling should mangle 
> > > such references exactly as if they were that template argument.
> > 
> > https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangle.template-param
> > 
> > See also [the discussion in the 
> > issue](https://github.com/itanium-cxx-abi/cxx-abi/issues/111#issuecomment-1567486892).
> Okay, I think I agree that this is already addressed in the ABI document. I 
> think we can drop the comment referencing the ABI issue, wdyt?
Ok, dropped.



Comment at: clang/lib/Sema/SemaTemplate.cpp:7968
+  case APValue::FixedPoint:
+return FixedPointLiteral::CreateFromRawInt(
+S.Context, Val.getFixedPoint().getValue(), T, Loc,

aaron.ballman wrote:
> What should happen if `T` isn't a fixed point type? (Should we assert here?)
I don't expect that it will happen. Non-type template argument is a constant 
expression converted to the type of the template parameter. Hence, a value 
produced by such an expression should correspond to the NTTP type.

Should an assert be placed here, it should be placed in the other `switch` 
branches as well, I think. The 

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-11-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D140996#4655288 , @bolshakov-a 
wrote:

> Sorry, but I don't know what remains to be done here. It seems that the only 
> important question is about ABI, but I've already answered that the changes 
> under discussion seem to be already fixed in the Itanium ABI document.

Oh gosh, this must have fallen through the cracks then -- I thought it was 
waiting on further changes, so I hadn't been re-reviewing it. I'm sorry about 
that! Let's get this ball rolling again to try to get this landed. CC 
@erichkeane (who may not be available for the next while due to WG21 meetings, 
FYI).




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:2205-2206
   "bit-field%select{| %1}2">;
+def err_reference_bind_to_bitfield_in_cce : Error<
+  "reference cannot bind to bit-field in converted constant expression">;
 def err_reference_bind_to_vector_element : Error<

This change seems somewhat orthogonal to the rest of the patch; should this be 
split out? Also, there doesn't appear to be test coverage for the new 
diagnostic.



Comment at: clang/lib/AST/ItaniumMangle.cpp:4397
+// argument.
+// As proposed in https://github.com/itanium-cxx-abi/cxx-abi/issues/111.
+auto *SNTTPE = cast(E);

bolshakov-a wrote:
> bolshakov-a wrote:
> > efriedma wrote:
> > > bolshakov-a wrote:
> > > > erichkeane wrote:
> > > > > erichkeane wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > We should get this nailed down. It was proposed in Nov 2020 and 
> > > > > > > the issue is still open. CC @rjmccall 
> > > > > > This definitely needs to happen.  @rjmccall or @eli.friedman ^^ Any 
> > > > > > idea what the actual mangling should be?
> > > > > This is still an open, and we need @rjmccall @eli.friedman or @asl to 
> > > > > help out here.
> > > > Ping @efriedma, @rjmccall, @asl.
> > > I'm not really familiar with the mangling implications for this 
> > > particular construct, nor am I actively involved with the Itanium ABI 
> > > specification, so I'm not sure how I can help you directly.
> > > 
> > > That said, as a general opinion, I don't think it's worth waiting for 
> > > updates to the Itanuim ABI  document to be merged; such updates are 
> > > happening slowly at the moment, and having a consistent mangling is 
> > > clearly an improvement even if it's not specified.  My suggested plan of 
> > > action:
> > > 
> > > - Make sure you're satisfied the proposed mangling doesn't have any holes 
> > > you're concerned about (i.e. it produces a unique mangling for all the 
> > > relevant cases).  If you're not sure, I can try to spend some time 
> > > understanding this, but it doesn't sound like you have any concerns about 
> > > this.
> > > - Put a note on the issue in the Itanium ABI repo that you're planning to 
> > > go ahead with using this mangling in clang.  Also send an email directly 
> > > to @rjmccall and @rsmith in case they miss the notifications.
> > > - Go ahead with this.
> > > Put a note on the issue in the Itanium ABI repo that you're planning to 
> > > go ahead with using this mangling in clang. Also send an email directly 
> > > to @rjmccall and @rsmith in case they miss the notifications.
> > 
> > I'm sorry for noting one more time that Richard already pushed these 
> > changes in clang upstream, but they had been just reverted.
> > 
> > Maybe, I should make a PR into Itanium API repository, but I probably need 
> > some time to dig into the theory and all the discussions. But yes, even 
> > NTTP argument mangling rules are not still merged: 
> > https://github.com/itanium-cxx-abi/cxx-abi/pull/140
> @aaron.ballman, @erichkeane, seems like it is already fixed in the ABI 
> document:
> > Typically, only references to function template parameters occurring within 
> > the dependent signature of the template are mangled this way. In other 
> > contexts, template instantiation replaces references to template parameters 
> > with the actual template arguments, and mangling should mangle such 
> > references exactly as if they were that template argument.
> 
> https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangle.template-param
> 
> See also [the discussion in the 
> issue](https://github.com/itanium-cxx-abi/cxx-abi/issues/111#issuecomment-1567486892).
Okay, I think I agree that this is already addressed in the ABI document. I 
think we can drop the comment referencing the ABI issue, wdyt?



Comment at: clang/lib/AST/TemplateBase.cpp:408-409
   case Integral:
-getAsIntegral().Profile(ID);
 getIntegralType().Profile(ID);
+getAsIntegral().Profile(ID);
+break;

bolshakov-a wrote:
> aaron.ballman wrote:
> > Why did the order of these calls change?
> I don't know, it is from 9e08e51a20d0d2. I've tried to invert the order along 
> with the order for `StructuralValue`, and all tests have been passed.
I don't think the 

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-10-26 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a added a comment.

Sorry, but I don't know what remains to be done here. It seems that the only 
important question is about ABI, but I've already answered that the changes 
under discussion seem to be already fixed in the Itanium ABI document.


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-10-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D140996#4646880 , @cor3ntin wrote:

> It would be nice to figure out a plan for this PR in the next few weeks, 
> before we get kicked out of Phab!

Agreed -- @bolshakov-a are you still planning to actively work on this patch 
(it's okay if you're not, but in that case, do you mind if someone commandeers 
the patch)? We've got a few weeks left until Phabricator is going into 
read-only mode, so it would be good if we could get this review across the 
finish line before mid-Nov if possible.


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-09-16 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

It would be nice to figure out a plan for this PR in the next few weeks, before 
we get kicked out of Phab!


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-08-06 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a added inline comments.



Comment at: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp:56
+using CF = ComplexFloat<1.0f + 3.0fi>;
+using CF = ComplexFloat<3.0fi + 1.0f>;
 

bolshakov-a wrote:
> aaron.ballman wrote:
> > bolshakov-a wrote:
> > > shafik wrote:
> > > > Can we add an enum example e.g.:
> > > > 
> > > > ```
> > > > enum E{ E1, E2};
> > > > template  struct SE {};
> > > > using IPE = SE;
> > > > using IPE = SE;
> > > > 
> > > > ```
> > > What for? Enumerators as non-type template arguments are allowed since 
> > > C++98, AFAIK. And this test is about changes in C++20.
> > Sometimes we're lacking coverage for existing features, so when updating 
> > code in the area, we'll sometimes ask for extra coverage just to be sure 
> > we're not regressing something we think might not have a lot of existing 
> > test coverage.
> `temp_arg_nontype.cpp` test already has some `enum` cases. If a case with 
> type alias should be added, it shoud be added there, not in the 
> `temp_arg_nontype_cxx20.cpp`, I think.
I've just realized that C++98 didn't had type aliases. But `typedef`s should 
probably go as well.


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-08-06 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a added a comment.

Btw, formatting of unrelated lines has leaked into `TemplateBase.h`. Sorry.




Comment at: clang/lib/AST/MicrosoftMangle.cpp:1624-1626
+  return const_cast(
+  V.getLValueBase().dyn_cast());
+}

aaron.ballman wrote:
> Does this work or is the `const_cast` actually required?
No, it doesn't compile, likewise the standard C++ `dynamic_cast` cannot remove 
constness.



Comment at: clang/lib/AST/TemplateBase.cpp:408-409
   case Integral:
-getAsIntegral().Profile(ID);
 getIntegralType().Profile(ID);
+getAsIntegral().Profile(ID);
+break;

aaron.ballman wrote:
> Why did the order of these calls change?
I don't know, it is from 9e08e51a20d0d2. I've tried to invert the order along 
with the order for `StructuralValue`, and all tests have been passed.



Comment at: clang/lib/Sema/SemaOverload.cpp:5983-5985
+  Expr *E = Result.get();
+  if (!isa(E))
+E = ConstantExpr::Create(S.Context, Result.get(), Value);

aaron.ballman wrote:
> I thought we could run into situations where we had a `ConstantExpr` but it 
> did not yet have its result stored in it. Should we assert that isn't the 
> case here?
If I understand correctly, the sole place where `ConstantExpr` is constructed 
which may occur here is `BuildExpressionFromNonTypeTemplateArgumentValue` 
function, and a value is set into it there. Should I add the assertion into 
code?



Comment at: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp:56
+using CF = ComplexFloat<1.0f + 3.0fi>;
+using CF = ComplexFloat<3.0fi + 1.0f>;
 

aaron.ballman wrote:
> bolshakov-a wrote:
> > shafik wrote:
> > > Can we add an enum example e.g.:
> > > 
> > > ```
> > > enum E{ E1, E2};
> > > template  struct SE {};
> > > using IPE = SE;
> > > using IPE = SE;
> > > 
> > > ```
> > What for? Enumerators as non-type template arguments are allowed since 
> > C++98, AFAIK. And this test is about changes in C++20.
> Sometimes we're lacking coverage for existing features, so when updating code 
> in the area, we'll sometimes ask for extra coverage just to be sure we're not 
> regressing something we think might not have a lot of existing test coverage.
`temp_arg_nontype.cpp` test already has some `enum` cases. If a case with type 
alias should be added, it shoud be added there, not in the 
`temp_arg_nontype_cxx20.cpp`, I think.


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-08-06 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 547603.
bolshakov-a added a comment.

Fixes after review.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/drs/dr12xx.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Index/USR/structural-value-tpl-arg.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7218,6 +7218,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::StructuralValue:
+return eTemplateArgumentKindStructuralValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -856,6 +856,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindStructuralValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -626,13 +626,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2;>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1;>P1907R1
+  
+
+  Clang 18 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. declared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1;>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3;>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::StructuralValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1574,6 +1574,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::StructuralValue:
+if (Expr *E = TAL.getSourceStructuralValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-08-06 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 547589.
bolshakov-a added a comment.

Rebased.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/drs/dr12xx.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Index/USR/structural-value-tpl-arg.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7218,6 +7218,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::StructuralValue:
+return eTemplateArgumentKindStructuralValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -856,6 +856,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindStructuralValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -626,13 +626,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2;>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1;>P1907R1
+  
+
+  Clang 17 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. declared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1;>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3;>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::StructuralValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1574,6 +1574,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::StructuralValue:
+if (Expr *E = TAL.getSourceStructuralValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case 

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-08-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.
Herald added a subscriber: wangpc.

I've not spotted any major concerns with this patch, but I did have some minor 
nits to look into. I'd love to hear from @rsmith and @erichkeane before signing 
off on this, as the changes are pretty involved and they've both done some 
in-depth looks at the patch already.




Comment at: clang/include/clang/AST/TemplateBase.h:168-173
+  void initFromType(QualType, bool isNullPtr, bool IsDefaulted);
+  void initFromDeclaration(ValueDecl *, QualType, bool IsDefaulted);
+  void initFromIntegral(const ASTContext &, const llvm::APSInt &, QualType,
+bool IsDefaulted);
+  void initFromStructural(const ASTContext &, QualType, const APValue &,
+  bool IsDefaulted);

Can you add parameter names for the unnamed ones (we typically only leave a 
parameter unnamed when it is unused).



Comment at: clang/include/clang/AST/TemplateBase.h:382-385
+  /// Get the value of an StructuralValue.
+  const APValue () const { return *Value.Value; }
+
+  /// Get the type of an StructuralValue.





Comment at: clang/lib/AST/MicrosoftMangle.cpp:1624-1626
+  return const_cast(
+  V.getLValueBase().dyn_cast());
+}

Does this work or is the `const_cast` actually required?



Comment at: clang/lib/AST/ODRHash.cpp:1324-1327
+if (auto *AT = TypeSoFar->getAsArrayTypeUnsafe()) {
+  if (auto *CAT = dyn_cast(AT))
+OnePastTheEnd |= CAT->getSize() == E.getAsArrayIndex();
+  TypeSoFar = AT->getElementType();





Comment at: clang/lib/AST/ODRHash.cpp:1330
+  const Decl *D = E.getAsBaseOrMember().getPointer();
+  if (auto *FD = dyn_cast(D)) {
+if (FD->getParent()->isUnion())





Comment at: clang/lib/AST/ODRHash.cpp:1341-1342
+}
+ID.AddInteger((Value.isNullPointer() ? 1 : 0) | (OnePastTheEnd ? 2 : 0) |
+  (Value.hasLValuePath() ? 4 : 0));
+break;

I think this might be a bit clearer, but I don't insist on the change.



Comment at: clang/lib/AST/TemplateBase.cpp:163
 
-TemplateArgument::TemplateArgument(ASTContext , const llvm::APSInt ,
-   QualType Type, bool IsDefaulted) {
+void TemplateArgument::initFromType(QualType T, bool isNullPtr,
+bool IsDefaulted) {





Comment at: clang/lib/AST/TemplateBase.cpp:408-409
   case Integral:
-getAsIntegral().Profile(ID);
 getIntegralType().Profile(ID);
+getAsIntegral().Profile(ID);
+break;

Why did the order of these calls change?



Comment at: clang/lib/AST/TemplateBase.cpp:619
+  case TemplateArgument::UncommonValue: {
+// FIXME: We're guessing at LangOptions!
+SmallString<32> Str;

bolshakov-a wrote:
> erichkeane wrote:
> > aaron.ballman wrote:
> > > It's probably okay enough, but this is now the third instance of adding 
> > > the same bug to this helper method -- maybe we should fix that instead?
> > Agreed, seems to me we should do the work NOW to just wire in the lang-opts 
> > to this function.
> The problem here is because this function is called from a stream insertion 
> operator, and there isn't obviously any way to pass 3rd parameter into it 
> without switching it into an ordinary function.
Okay, that's reasonable enough to hold off on changing. Thanks!



Comment at: clang/lib/Sema/SemaOverload.cpp:5983-5985
+  Expr *E = Result.get();
+  if (!isa(E))
+E = ConstantExpr::Create(S.Context, Result.get(), Value);

I thought we could run into situations where we had a `ConstantExpr` but it did 
not yet have its result stored in it. Should we assert that isn't the case here?



Comment at: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp:56
+using CF = ComplexFloat<1.0f + 3.0fi>;
+using CF = ComplexFloat<3.0fi + 1.0f>;
 

bolshakov-a wrote:
> shafik wrote:
> > Can we add an enum example e.g.:
> > 
> > ```
> > enum E{ E1, E2};
> > template  struct SE {};
> > using IPE = SE;
> > using IPE = SE;
> > 
> > ```
> What for? Enumerators as non-type template arguments are allowed since C++98, 
> AFAIK. And this test is about changes in C++20.
Sometimes we're lacking coverage for existing features, so when updating code 
in the area, we'll sometimes ask for extra coverage just to be sure we're not 
regressing something we think might not have a lot of existing test coverage.



Comment at: clang/www/cxx_status.html:1061
+
+  Clang 17 (Partial)
+  Reference type template arguments referring to 
instantiation-dependent objects and subobjects




CHANGES SINCE LAST ACTION
  

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-06-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

It would be great if we could make progress on this for clang 17, I was told 
it's forcing some people to use other compilers.
Are the recent changes to the itanium abi enough to complete this work? Thanks!


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-06-06 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a added inline comments.



Comment at: clang/lib/AST/ItaniumMangle.cpp:4397
+// argument.
+// As proposed in https://github.com/itanium-cxx-abi/cxx-abi/issues/111.
+auto *SNTTPE = cast(E);

bolshakov-a wrote:
> efriedma wrote:
> > bolshakov-a wrote:
> > > erichkeane wrote:
> > > > erichkeane wrote:
> > > > > aaron.ballman wrote:
> > > > > > We should get this nailed down. It was proposed in Nov 2020 and the 
> > > > > > issue is still open. CC @rjmccall 
> > > > > This definitely needs to happen.  @rjmccall or @eli.friedman ^^ Any 
> > > > > idea what the actual mangling should be?
> > > > This is still an open, and we need @rjmccall @eli.friedman or @asl to 
> > > > help out here.
> > > Ping @efriedma, @rjmccall, @asl.
> > I'm not really familiar with the mangling implications for this particular 
> > construct, nor am I actively involved with the Itanium ABI specification, 
> > so I'm not sure how I can help you directly.
> > 
> > That said, as a general opinion, I don't think it's worth waiting for 
> > updates to the Itanuim ABI  document to be merged; such updates are 
> > happening slowly at the moment, and having a consistent mangling is clearly 
> > an improvement even if it's not specified.  My suggested plan of action:
> > 
> > - Make sure you're satisfied the proposed mangling doesn't have any holes 
> > you're concerned about (i.e. it produces a unique mangling for all the 
> > relevant cases).  If you're not sure, I can try to spend some time 
> > understanding this, but it doesn't sound like you have any concerns about 
> > this.
> > - Put a note on the issue in the Itanium ABI repo that you're planning to 
> > go ahead with using this mangling in clang.  Also send an email directly to 
> > @rjmccall and @rsmith in case they miss the notifications.
> > - Go ahead with this.
> > Put a note on the issue in the Itanium ABI repo that you're planning to go 
> > ahead with using this mangling in clang. Also send an email directly to 
> > @rjmccall and @rsmith in case they miss the notifications.
> 
> I'm sorry for noting one more time that Richard already pushed these changes 
> in clang upstream, but they had been just reverted.
> 
> Maybe, I should make a PR into Itanium API repository, but I probably need 
> some time to dig into the theory and all the discussions. But yes, even NTTP 
> argument mangling rules are not still merged: 
> https://github.com/itanium-cxx-abi/cxx-abi/pull/140
@aaron.ballman, @erichkeane, seems like it is already fixed in the ABI document:
> Typically, only references to function template parameters occurring within 
> the dependent signature of the template are mangled this way. In other 
> contexts, template instantiation replaces references to template parameters 
> with the actual template arguments, and mangling should mangle such 
> references exactly as if they were that template argument.

https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangle.template-param

See also [the discussion in the 
issue](https://github.com/itanium-cxx-abi/cxx-abi/issues/111#issuecomment-1567486892).


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-05-14 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a added inline comments.



Comment at: clang/lib/AST/ItaniumMangle.cpp:4397
+// argument.
+// As proposed in https://github.com/itanium-cxx-abi/cxx-abi/issues/111.
+auto *SNTTPE = cast(E);

efriedma wrote:
> bolshakov-a wrote:
> > erichkeane wrote:
> > > erichkeane wrote:
> > > > aaron.ballman wrote:
> > > > > We should get this nailed down. It was proposed in Nov 2020 and the 
> > > > > issue is still open. CC @rjmccall 
> > > > This definitely needs to happen.  @rjmccall or @eli.friedman ^^ Any 
> > > > idea what the actual mangling should be?
> > > This is still an open, and we need @rjmccall @eli.friedman or @asl to 
> > > help out here.
> > Ping @efriedma, @rjmccall, @asl.
> I'm not really familiar with the mangling implications for this particular 
> construct, nor am I actively involved with the Itanium ABI specification, so 
> I'm not sure how I can help you directly.
> 
> That said, as a general opinion, I don't think it's worth waiting for updates 
> to the Itanuim ABI  document to be merged; such updates are happening slowly 
> at the moment, and having a consistent mangling is clearly an improvement 
> even if it's not specified.  My suggested plan of action:
> 
> - Make sure you're satisfied the proposed mangling doesn't have any holes 
> you're concerned about (i.e. it produces a unique mangling for all the 
> relevant cases).  If you're not sure, I can try to spend some time 
> understanding this, but it doesn't sound like you have any concerns about 
> this.
> - Put a note on the issue in the Itanium ABI repo that you're planning to go 
> ahead with using this mangling in clang.  Also send an email directly to 
> @rjmccall and @rsmith in case they miss the notifications.
> - Go ahead with this.
> Put a note on the issue in the Itanium ABI repo that you're planning to go 
> ahead with using this mangling in clang. Also send an email directly to 
> @rjmccall and @rsmith in case they miss the notifications.

I'm sorry for noting one more time that Richard already pushed these changes in 
clang upstream, but they had been just reverted.

Maybe, I should make a PR into Itanium API repository, but I probably need some 
time to dig into the theory and all the discussions. But yes, even NTTP 
argument mangling rules are not still merged: 
https://github.com/itanium-cxx-abi/cxx-abi/pull/140


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-05-14 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a added inline comments.



Comment at: clang/lib/AST/ItaniumMangle.cpp:4579
+  if (CE->hasAPValueResult())
+mangleValueInTemplateArg(ParamType, CE->getResultAsAPValue(), false,
+ /*NeedExactType=*/true);

efriedma wrote:
> I'm not sure what the point of the `if (CE->hasAPValueResult())` is; are you 
> just trying to avoid copying the APValue?  (If this is going to be a 
> repeating pattern, maybe we can add some sort of utility class to represent 
> the pattern.)
I don't know too, it is Richard's code. Looks really like an optimization.


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-05-14 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/AST/ItaniumMangle.cpp:4579
+  if (CE->hasAPValueResult())
+mangleValueInTemplateArg(ParamType, CE->getResultAsAPValue(), false,
+ /*NeedExactType=*/true);

I'm not sure what the point of the `if (CE->hasAPValueResult())` is; are you 
just trying to avoid copying the APValue?  (If this is going to be a repeating 
pattern, maybe we can add some sort of utility class to represent the pattern.)



Comment at: clang/lib/AST/ItaniumMangle.cpp:4397
+// argument.
+// As proposed in https://github.com/itanium-cxx-abi/cxx-abi/issues/111.
+auto *SNTTPE = cast(E);

bolshakov-a wrote:
> erichkeane wrote:
> > erichkeane wrote:
> > > aaron.ballman wrote:
> > > > We should get this nailed down. It was proposed in Nov 2020 and the 
> > > > issue is still open. CC @rjmccall 
> > > This definitely needs to happen.  @rjmccall or @eli.friedman ^^ Any idea 
> > > what the actual mangling should be?
> > This is still an open, and we need @rjmccall @eli.friedman or @asl to help 
> > out here.
> Ping @efriedma, @rjmccall, @asl.
I'm not really familiar with the mangling implications for this particular 
construct, nor am I actively involved with the Itanium ABI specification, so 
I'm not sure how I can help you directly.

That said, as a general opinion, I don't think it's worth waiting for updates 
to the Itanuim ABI  document to be merged; such updates are happening slowly at 
the moment, and having a consistent mangling is clearly an improvement even if 
it's not specified.  My suggested plan of action:

- Make sure you're satisfied the proposed mangling doesn't have any holes 
you're concerned about (i.e. it produces a unique mangling for all the relevant 
cases).  If you're not sure, I can try to spend some time understanding this, 
but it doesn't sound like you have any concerns about this.
- Put a note on the issue in the Itanium ABI repo that you're planning to go 
ahead with using this mangling in clang.  Also send an email directly to 
@rjmccall and @rsmith in case they miss the notifications.
- Go ahead with this.


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-05-11 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a added a subscriber: efriedma.
bolshakov-a added inline comments.



Comment at: clang/lib/AST/ItaniumMangle.cpp:4397
+// argument.
+// As proposed in https://github.com/itanium-cxx-abi/cxx-abi/issues/111.
+auto *SNTTPE = cast(E);

erichkeane wrote:
> erichkeane wrote:
> > aaron.ballman wrote:
> > > We should get this nailed down. It was proposed in Nov 2020 and the issue 
> > > is still open. CC @rjmccall 
> > This definitely needs to happen.  @rjmccall or @eli.friedman ^^ Any idea 
> > what the actual mangling should be?
> This is still an open, and we need @rjmccall @eli.friedman or @asl to help 
> out here.
Ping @efriedma, @rjmccall, @asl.


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-05-09 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 520716.
bolshakov-a added a comment.

Rebased.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/drs/dr12xx.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Index/USR/structural-value-tpl-arg.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7305,6 +7305,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::StructuralValue:
+return eTemplateArgumentKindStructuralValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -849,6 +849,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindStructuralValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1049,13 +1049,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2;>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1;>P1907R1
+  
+
+  Clang 17 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. declared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1;>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3;>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::StructuralValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::StructuralValue:
+if (Expr *E = TAL.getSourceStructuralValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case 

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-05-09 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 520678.
bolshakov-a added a comment.

Fix MS compatibility mangling algorithm. Tested with MSVC ver. 19.35 (toolset 
ver. 143).


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/drs/dr12xx.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Index/USR/structural-value-tpl-arg.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7305,6 +7305,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::StructuralValue:
+return eTemplateArgumentKindStructuralValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -849,6 +849,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindStructuralValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1053,13 +1053,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2;>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1;>P1907R1
+  
+
+  Clang 17 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. declared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1;>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3;>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::StructuralValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::StructuralValue:
+if (Expr *E = TAL.getSourceStructuralValueExpression())
+  return 

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-05-08 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 520478.
bolshakov-a added a subscriber: hubert.reinterpretcast.
bolshakov-a added a comment.

Avoid binding references in template arguments to bit-fields. @erichkeane, 
@hubert.reinterpretcast, please verify.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/drs/dr12xx.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Index/USR/structural-value-tpl-arg.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7305,6 +7305,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::StructuralValue:
+return eTemplateArgumentKindStructuralValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -849,6 +849,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindStructuralValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1053,13 +1053,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2;>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1;>P1907R1
+  
+
+  Clang 17 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. declared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1;>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3;>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::StructuralValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::StructuralValue:

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-05-06 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 520080.
bolshakov-a added a comment.

Rebased; somehow incorrectly merged `ReleaseNotes.rst` fixed.

`CXX/drs/dr12xx.cpp` starts to show that clang accepts now references to 
bitfields as template arguments in C++20 mode. It is probably not OK.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Index/USR/structural-value-tpl-arg.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7305,6 +7305,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::StructuralValue:
+return eTemplateArgumentKindStructuralValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -849,6 +849,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindStructuralValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1053,13 +1053,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2;>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1;>P1907R1
+  
+
+  Clang 17 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. declared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1;>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3;>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::StructuralValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case 

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-25 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 508311.
bolshakov-a added a comment.

Rebased.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Index/USR/structural-value-tpl-arg.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7297,6 +7297,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::StructuralValue:
+return eTemplateArgumentKindStructuralValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindStructuralValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1053,13 +1053,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2;>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1;>P1907R1
+  
+
+  Clang 17 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. declared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1;>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3;>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::StructuralValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::StructuralValue:
+if (Expr *E = TAL.getSourceStructuralValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-25 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 508305.
bolshakov-a added a comment.

Add type to USR so as not to get confused with

  template  struct S {};
  struct { int n; } s;
  
  template<>
  struct S<(void*)> {};
  
  template<>
  struct S<> {};

Add test on structural type NTTP USR. Just a couple of cases have been added 
because most of the relevant code should already be covered by `odr_hash.cpp` 
test.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Index/USR/structural-value-tpl-arg.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7311,6 +7311,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::StructuralValue:
+return eTemplateArgumentKindStructuralValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindStructuralValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1053,13 +1053,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2;>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1;>P1907R1
+  
+
+  Clang 17 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. declared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1;>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3;>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::StructuralValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-21 Thread Ben Barham via Phabricator via cfe-commits
bnbarham added inline comments.



Comment at: clang/lib/Index/USRGeneration.cpp:1032
+  case TemplateArgument::UncommonValue:
+// FIXME: Visit value.
+break;

bolshakov-a wrote:
> bnbarham wrote:
> > bolshakov-a wrote:
> > > bnbarham wrote:
> > > > bolshakov-a wrote:
> > > > > bnbarham wrote:
> > > > > > akyrtzi wrote:
> > > > > > > erichkeane wrote:
> > > > > > > > bolshakov-a wrote:
> > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > Any particular reason this isn't being handled now?
> > > > > > > > > I need some guidance here. Which characters are allowed in 
> > > > > > > > > the USR? Could the mangling algorithm from 
> > > > > > > > > `CXXNameMangler::mangleValueInTemplateArg` be moved into some 
> > > > > > > > > common place and reused here?
> > > > > > > > I have no idea what is valid here.  BUT @akyrtzi and @gribozavr 
> > > > > > > > (or @gribozavr2 ?) seem to be the ones that touch these files 
> > > > > > > > the most?
> > > > > > > Adding @bnbarham to review the `Index` changes.
> > > > > > Just visiting the underlying type seems reasonable, ie. 
> > > > > > `VisitType(Arg.getUncommonValueType());`. If it needed to be 
> > > > > > differentiated between a `TemplateArgument::Type` you could add a 
> > > > > > prefix character (eg. `U`), but that doesn't seem needed to me.
> > > > > Doesn't the holded value be added so as to distinguish e.g. 
> > > > > `Tpl<1.5>` from `Tpl<2.5>`?
> > > > Ah I see, yeah, we would. And there's no USR generation for APValue 
> > > > currently, which I assume is why your original question came up.
> > > > 
> > > > In general a USR just wants to uniquely identify an entity across 
> > > > compilations and isn't as restricted as the mangled name. For basically 
> > > > everything but `LValue` it seems like you'd be fine to print the value 
> > > > (for eg. int, float, etc), visit the underlying type (array, vector), 
> > > > or the visit the underlying decl (struct, union, member pointer). 
> > > > That's almost true for `LValue` as well, just with the extra parts that 
> > > > are also added to the ODR hash.
> > > > 
> > > > Alternatively, you could also just print the hash from `Profile` with 
> > > > the same handling as ODR hash. Worst case we'd accidentally merge 
> > > > specializations, but if that's good enough for the ODR hash it's 
> > > > probably good enough here as well.
> > > > it seems like you'd be fine to print the value (for eg. int, float, etc)
> > > 
> > > I'm in doubt about the dot inside a floating point value representation. 
> > > Minus sign is allowed, as I can see for `TemplateArgument::Integral` case.
> > As long as there's a prefix for APValue and its kind, the dot is fine (eg. 
> > maybe `@AP@` and then `f` for float, `i` for integer, etc).
> Thank you! I've decided to go the simplest way, i. e. to use `ODRHash` here. 
> Should I write a test case (or some test cases), or they could become fragile 
> due to possible `ODRHash` implementation changes? I've checked USR locally a 
> little.
You could add a test that checks the ref has the same USR as the def, but yeah, 
I wouldn't specifically check the USR here.


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-20 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a subscriber: asl.
erichkeane added a comment.

I've got the 1 concern with the mangling that I REALLY want one of our codegen 
owners to chime in on, otherwise this LGTM.




Comment at: clang/lib/AST/ItaniumMangle.cpp:4397
+// argument.
+// As proposed in https://github.com/itanium-cxx-abi/cxx-abi/issues/111.
+auto *SNTTPE = cast(E);

erichkeane wrote:
> aaron.ballman wrote:
> > We should get this nailed down. It was proposed in Nov 2020 and the issue 
> > is still open. CC @rjmccall 
> This definitely needs to happen.  @rjmccall or @eli.friedman ^^ Any idea what 
> the actual mangling should be?
This is still an open, and we need @rjmccall @eli.friedman or @asl to help out 
here.


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-19 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 506430.
bolshakov-a added a comment.

Finalize renaming one more time.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7311,6 +7311,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::StructuralValue:
+return eTemplateArgumentKindStructuralValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindStructuralValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1053,13 +1053,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2;>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1;>P1907R1
+  
+
+  Clang 17 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. declared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1;>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3;>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::StructuralValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::StructuralValue:
+if (Expr *E = TAL.getSourceStructuralValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = 

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-19 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 506429.
bolshakov-a added a comment.

Finalize renaming.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7311,6 +7311,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::StructuralValue:
+return eTemplateArgumentKindStructuralValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindStructuralValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1053,13 +1053,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2;>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1;>P1907R1
+  
+
+  Clang 17 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. declared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1;>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3;>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::StructuralValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::StructuralValue:
+if (Expr *E = TAL.getSourceStructuralValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = 

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-19 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 506428.
bolshakov-a added a comment.

Add USR generation and a couple of minor fixes.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7311,6 +7311,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1053,13 +1053,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2;>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1;>P1907R1
+  
+
+  Clang 17 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. declared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1;>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3;>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::StructuralValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::StructuralValue:
+if (Expr *E = TAL.getSourceStructuralValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = 

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-19 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 506426.
bolshakov-a added a comment.

Rename `UncommonValue` to `StructuralValue` and add "TODO" about it.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7311,6 +7311,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1053,13 +1053,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2;>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1;>P1907R1
+  
+
+  Clang 17 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. delcared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1;>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3;>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::StructuralValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::StructuralValue:
+if (Expr *E = TAL.getSourceStructuralValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-19 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a added inline comments.



Comment at: clang/lib/AST/MicrosoftMangle.cpp:1670
+  case TemplateArgument::UncommonValue:
+if (ValueDecl *D = getAsArrayToPointerDecayedDecl(
+TA.getUncommonValueType(), TA.getAsUncommonValue())) {

erichkeane wrote:
> bolshakov-a wrote:
> > erichkeane wrote:
> > > Has microsoft implemented this yet?  Can we see what they chose to do and 
> > > make sure we match them? 
> > Experimentally, I've made me sure that MSVC produces the same mangled names 
> > for the cases provided in the `mangle-ms-templates` test as in the test. 
> > But there are problems with references to subobjects: some cases are 
> > explicitly unsupported in `mangleTemplateArgValue`, and some cases produce 
> > a magled name different from what MSVC does. Should it be fixed in this PR, 
> > or may be delayed?
> We need to end up doing our best to match the microsoft mangling if at all 
> possible, since they own the ABI.  I DEFINITELY would want any followup patch 
> to be promised for Clang17 (that is, we don't release Clang17 with this patch 
> and NOT that patch), so I'd expect said patch to be available for review 
> before this gets committed.
> 
> As far as whether it needs to happen in THIS patch, we can perhaps decide 
> based on the severity of the break, if you can provide examples (or, if it is 
> split into a separate patch, we can use the tests there).
I've addressed some issues already present on the main branch in 
[D146386](https://reviews.llvm.org/D146386). I could try to fix remaining 
issues in this PR afrer landing that one.



Comment at: clang/lib/AST/TemplateBase.cpp:244
+  else if (const ValueDecl *VD = getAsSimpleValueDeclRef(Ctx, Type, V))
+// FIXME: The Declaration form should expose a const ValueDecl*.
+initFromDeclaration(const_cast(VD), Type, IsDefaulted);

erichkeane wrote:
> Why can this not happen now?
Adding `const` to the `TemplateArgument::DA::D` type and to the 
`TemplateArgument::getAsDecl()` return type would lead to many changes 
unrelated to this PR.



Comment at: clang/lib/Index/USRGeneration.cpp:1032
+  case TemplateArgument::UncommonValue:
+// FIXME: Visit value.
+break;

bnbarham wrote:
> bolshakov-a wrote:
> > bnbarham wrote:
> > > bolshakov-a wrote:
> > > > bnbarham wrote:
> > > > > akyrtzi wrote:
> > > > > > erichkeane wrote:
> > > > > > > bolshakov-a wrote:
> > > > > > > > aaron.ballman wrote:
> > > > > > > > > Any particular reason this isn't being handled now?
> > > > > > > > I need some guidance here. Which characters are allowed in the 
> > > > > > > > USR? Could the mangling algorithm from 
> > > > > > > > `CXXNameMangler::mangleValueInTemplateArg` be moved into some 
> > > > > > > > common place and reused here?
> > > > > > > I have no idea what is valid here.  BUT @akyrtzi and @gribozavr 
> > > > > > > (or @gribozavr2 ?) seem to be the ones that touch these files the 
> > > > > > > most?
> > > > > > Adding @bnbarham to review the `Index` changes.
> > > > > Just visiting the underlying type seems reasonable, ie. 
> > > > > `VisitType(Arg.getUncommonValueType());`. If it needed to be 
> > > > > differentiated between a `TemplateArgument::Type` you could add a 
> > > > > prefix character (eg. `U`), but that doesn't seem needed to me.
> > > > Doesn't the holded value be added so as to distinguish e.g. `Tpl<1.5>` 
> > > > from `Tpl<2.5>`?
> > > Ah I see, yeah, we would. And there's no USR generation for APValue 
> > > currently, which I assume is why your original question came up.
> > > 
> > > In general a USR just wants to uniquely identify an entity across 
> > > compilations and isn't as restricted as the mangled name. For basically 
> > > everything but `LValue` it seems like you'd be fine to print the value 
> > > (for eg. int, float, etc), visit the underlying type (array, vector), or 
> > > the visit the underlying decl (struct, union, member pointer). That's 
> > > almost true for `LValue` as well, just with the extra parts that are also 
> > > added to the ODR hash.
> > > 
> > > Alternatively, you could also just print the hash from `Profile` with the 
> > > same handling as ODR hash. Worst case we'd accidentally merge 
> > > specializations, but if that's good enough for the ODR hash it's probably 
> > > good enough here as well.
> > > it seems like you'd be fine to print the value (for eg. int, float, etc)
> > 
> > I'm in doubt about the dot inside a floating point value representation. 
> > Minus sign is allowed, as I can see for `TemplateArgument::Integral` case.
> As long as there's a prefix for APValue and its kind, the dot is fine (eg. 
> maybe `@AP@` and then `f` for float, `i` for integer, etc).
Thank you! I've decided to go the simplest way, i. e. to use `ODRHash` here. 
Should I write a test case (or some test cases), or they could become fragile 
due to possible `ODRHash` implementation changes? 

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-13 Thread Ben Barham via Phabricator via cfe-commits
bnbarham added inline comments.



Comment at: clang/lib/Index/USRGeneration.cpp:1032
+  case TemplateArgument::UncommonValue:
+// FIXME: Visit value.
+break;

bolshakov-a wrote:
> bnbarham wrote:
> > bolshakov-a wrote:
> > > bnbarham wrote:
> > > > akyrtzi wrote:
> > > > > erichkeane wrote:
> > > > > > bolshakov-a wrote:
> > > > > > > aaron.ballman wrote:
> > > > > > > > Any particular reason this isn't being handled now?
> > > > > > > I need some guidance here. Which characters are allowed in the 
> > > > > > > USR? Could the mangling algorithm from 
> > > > > > > `CXXNameMangler::mangleValueInTemplateArg` be moved into some 
> > > > > > > common place and reused here?
> > > > > > I have no idea what is valid here.  BUT @akyrtzi and @gribozavr (or 
> > > > > > @gribozavr2 ?) seem to be the ones that touch these files the most?
> > > > > Adding @bnbarham to review the `Index` changes.
> > > > Just visiting the underlying type seems reasonable, ie. 
> > > > `VisitType(Arg.getUncommonValueType());`. If it needed to be 
> > > > differentiated between a `TemplateArgument::Type` you could add a 
> > > > prefix character (eg. `U`), but that doesn't seem needed to me.
> > > Doesn't the holded value be added so as to distinguish e.g. `Tpl<1.5>` 
> > > from `Tpl<2.5>`?
> > Ah I see, yeah, we would. And there's no USR generation for APValue 
> > currently, which I assume is why your original question came up.
> > 
> > In general a USR just wants to uniquely identify an entity across 
> > compilations and isn't as restricted as the mangled name. For basically 
> > everything but `LValue` it seems like you'd be fine to print the value (for 
> > eg. int, float, etc), visit the underlying type (array, vector), or the 
> > visit the underlying decl (struct, union, member pointer). That's almost 
> > true for `LValue` as well, just with the extra parts that are also added to 
> > the ODR hash.
> > 
> > Alternatively, you could also just print the hash from `Profile` with the 
> > same handling as ODR hash. Worst case we'd accidentally merge 
> > specializations, but if that's good enough for the ODR hash it's probably 
> > good enough here as well.
> > it seems like you'd be fine to print the value (for eg. int, float, etc)
> 
> I'm in doubt about the dot inside a floating point value representation. 
> Minus sign is allowed, as I can see for `TemplateArgument::Integral` case.
As long as there's a prefix for APValue and its kind, the dot is fine (eg. 
maybe `@AP@` and then `f` for float, `i` for integer, etc).


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-13 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a added inline comments.



Comment at: clang/lib/Index/USRGeneration.cpp:1032
+  case TemplateArgument::UncommonValue:
+// FIXME: Visit value.
+break;

bnbarham wrote:
> bolshakov-a wrote:
> > bnbarham wrote:
> > > akyrtzi wrote:
> > > > erichkeane wrote:
> > > > > bolshakov-a wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > Any particular reason this isn't being handled now?
> > > > > > I need some guidance here. Which characters are allowed in the USR? 
> > > > > > Could the mangling algorithm from 
> > > > > > `CXXNameMangler::mangleValueInTemplateArg` be moved into some 
> > > > > > common place and reused here?
> > > > > I have no idea what is valid here.  BUT @akyrtzi and @gribozavr (or 
> > > > > @gribozavr2 ?) seem to be the ones that touch these files the most?
> > > > Adding @bnbarham to review the `Index` changes.
> > > Just visiting the underlying type seems reasonable, ie. 
> > > `VisitType(Arg.getUncommonValueType());`. If it needed to be 
> > > differentiated between a `TemplateArgument::Type` you could add a prefix 
> > > character (eg. `U`), but that doesn't seem needed to me.
> > Doesn't the holded value be added so as to distinguish e.g. `Tpl<1.5>` from 
> > `Tpl<2.5>`?
> Ah I see, yeah, we would. And there's no USR generation for APValue 
> currently, which I assume is why your original question came up.
> 
> In general a USR just wants to uniquely identify an entity across 
> compilations and isn't as restricted as the mangled name. For basically 
> everything but `LValue` it seems like you'd be fine to print the value (for 
> eg. int, float, etc), visit the underlying type (array, vector), or the visit 
> the underlying decl (struct, union, member pointer). That's almost true for 
> `LValue` as well, just with the extra parts that are also added to the ODR 
> hash.
> 
> Alternatively, you could also just print the hash from `Profile` with the 
> same handling as ODR hash. Worst case we'd accidentally merge 
> specializations, but if that's good enough for the ODR hash it's probably 
> good enough here as well.
> it seems like you'd be fine to print the value (for eg. int, float, etc)

I'm in doubt about the dot inside a floating point value representation. Minus 
sign is allowed, as I can see for `TemplateArgument::Integral` case.


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-13 Thread Ben Barham via Phabricator via cfe-commits
bnbarham added inline comments.



Comment at: clang/lib/Index/USRGeneration.cpp:1032
+  case TemplateArgument::UncommonValue:
+// FIXME: Visit value.
+break;

bolshakov-a wrote:
> bnbarham wrote:
> > akyrtzi wrote:
> > > erichkeane wrote:
> > > > bolshakov-a wrote:
> > > > > aaron.ballman wrote:
> > > > > > Any particular reason this isn't being handled now?
> > > > > I need some guidance here. Which characters are allowed in the USR? 
> > > > > Could the mangling algorithm from 
> > > > > `CXXNameMangler::mangleValueInTemplateArg` be moved into some common 
> > > > > place and reused here?
> > > > I have no idea what is valid here.  BUT @akyrtzi and @gribozavr (or 
> > > > @gribozavr2 ?) seem to be the ones that touch these files the most?
> > > Adding @bnbarham to review the `Index` changes.
> > Just visiting the underlying type seems reasonable, ie. 
> > `VisitType(Arg.getUncommonValueType());`. If it needed to be differentiated 
> > between a `TemplateArgument::Type` you could add a prefix character (eg. 
> > `U`), but that doesn't seem needed to me.
> Doesn't the holded value be added so as to distinguish e.g. `Tpl<1.5>` from 
> `Tpl<2.5>`?
Ah I see, yeah, we would. And there's no USR generation for APValue currently, 
which I assume is why your original question came up.

In general a USR just wants to uniquely identify an entity across compilations 
and isn't as restricted as the mangled name. For basically everything but 
`LValue` it seems like you'd be fine to print the value (for eg. int, float, 
etc), visit the underlying type (array, vector), or the visit the underlying 
decl (struct, union, member pointer). That's almost true for `LValue` as well, 
just with the extra parts that are also added to the ODR hash.

Alternatively, you could also just print the hash from `Profile` with the same 
handling as ODR hash. Worst case we'd accidentally merge specializations, but 
if that's good enough for the ODR hash it's probably good enough here as well.


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-13 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a added inline comments.



Comment at: clang/lib/Index/USRGeneration.cpp:1032
+  case TemplateArgument::UncommonValue:
+// FIXME: Visit value.
+break;

bnbarham wrote:
> akyrtzi wrote:
> > erichkeane wrote:
> > > bolshakov-a wrote:
> > > > aaron.ballman wrote:
> > > > > Any particular reason this isn't being handled now?
> > > > I need some guidance here. Which characters are allowed in the USR? 
> > > > Could the mangling algorithm from 
> > > > `CXXNameMangler::mangleValueInTemplateArg` be moved into some common 
> > > > place and reused here?
> > > I have no idea what is valid here.  BUT @akyrtzi and @gribozavr (or 
> > > @gribozavr2 ?) seem to be the ones that touch these files the most?
> > Adding @bnbarham to review the `Index` changes.
> Just visiting the underlying type seems reasonable, ie. 
> `VisitType(Arg.getUncommonValueType());`. If it needed to be differentiated 
> between a `TemplateArgument::Type` you could add a prefix character (eg. 
> `U`), but that doesn't seem needed to me.
Doesn't the holded value be added so as to distinguish e.g. `Tpl<1.5>` from 
`Tpl<2.5>`?


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-13 Thread Ben Barham via Phabricator via cfe-commits
bnbarham added inline comments.



Comment at: clang/lib/Index/USRGeneration.cpp:1032
+  case TemplateArgument::UncommonValue:
+// FIXME: Visit value.
+break;

akyrtzi wrote:
> erichkeane wrote:
> > bolshakov-a wrote:
> > > aaron.ballman wrote:
> > > > Any particular reason this isn't being handled now?
> > > I need some guidance here. Which characters are allowed in the USR? Could 
> > > the mangling algorithm from `CXXNameMangler::mangleValueInTemplateArg` be 
> > > moved into some common place and reused here?
> > I have no idea what is valid here.  BUT @akyrtzi and @gribozavr (or 
> > @gribozavr2 ?) seem to be the ones that touch these files the most?
> Adding @bnbarham to review the `Index` changes.
Just visiting the underlying type seems reasonable, ie. 
`VisitType(Arg.getUncommonValueType());`. If it needed to be differentiated 
between a `TemplateArgument::Type` you could add a prefix character (eg. `U`), 
but that doesn't seem needed to me.


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-13 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi added a subscriber: bnbarham.
akyrtzi added inline comments.



Comment at: clang/lib/Index/USRGeneration.cpp:1032
+  case TemplateArgument::UncommonValue:
+// FIXME: Visit value.
+break;

erichkeane wrote:
> bolshakov-a wrote:
> > aaron.ballman wrote:
> > > Any particular reason this isn't being handled now?
> > I need some guidance here. Which characters are allowed in the USR? Could 
> > the mangling algorithm from `CXXNameMangler::mangleValueInTemplateArg` be 
> > moved into some common place and reused here?
> I have no idea what is valid here.  BUT @akyrtzi and @gribozavr (or 
> @gribozavr2 ?) seem to be the ones that touch these files the most?
Adding @bnbarham to review the `Index` changes.


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-13 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/www/cxx_status.html:1067
+  Reference type template arguments referring to 
instantiation-dependent objects and subobjects
+  (i.e. delcared inside a template but neither type- nor 
value-dependent) aren't fully supported.
+




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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-13 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added subscribers: eli.friedman, gribozavr2, akyrtzi, gribozavr.
erichkeane added inline comments.



Comment at: clang/include/clang/AST/TemplateBase.h:88
+/// so cannot be dependent.
+UncommonValue,
+

bolshakov-a wrote:
> shafik wrote:
> > erichkeane wrote:
> > > I definitely hate the name here... Just `Value` makes a bit more sense, 
> > > but isn't perfectly accurate.  Perhaps `NonTypeValue`?  But that is a 
> > > little redundant.  `Uncommon` here is just strange and not particularly 
> > > descriptive. 
> > This catch all `UncommonValue` feels artificial. Maybe we need a separate 
> > out the cases into more granular cases like `Float` etc
> @erichkeane, it looks strange, I agree. Even just `CommonValue` sounds better 
> for me (but my English is far from fluent). Maybe, `ArbitraryValue`?
> 
> @shafik, your suggestion would move this PR far enough from the original 
> Richard's commit. And I'd prefer to merge `Declaration`, `Integral`, and 
> `NullPtr` kinds into that is currently called `UncommonValue` rather than to 
> repeat here various `APValue` kinds.
I don't think splitting out the individual cases has all that much value, at 
least until we NEED it.  

As far as a name, what about `StructuralValue`?  P1907 calls the 'type' of that 
A 'structural type'? It isn't perfect, but it at least seems to be somewhat 
defensible with standards language.



Comment at: clang/lib/AST/ItaniumMangle.cpp:4397
+// argument.
+// As proposed in https://github.com/itanium-cxx-abi/cxx-abi/issues/111.
+auto *SNTTPE = cast(E);

aaron.ballman wrote:
> We should get this nailed down. It was proposed in Nov 2020 and the issue is 
> still open. CC @rjmccall 
This definitely needs to happen.  @rjmccall or @eli.friedman ^^ Any idea what 
the actual mangling should be?



Comment at: clang/lib/AST/MicrosoftMangle.cpp:1670
+  case TemplateArgument::UncommonValue:
+if (ValueDecl *D = getAsArrayToPointerDecayedDecl(
+TA.getUncommonValueType(), TA.getAsUncommonValue())) {

bolshakov-a wrote:
> erichkeane wrote:
> > Has microsoft implemented this yet?  Can we see what they chose to do and 
> > make sure we match them? 
> Experimentally, I've made me sure that MSVC produces the same mangled names 
> for the cases provided in the `mangle-ms-templates` test as in the test. But 
> there are problems with references to subobjects: some cases are explicitly 
> unsupported in `mangleTemplateArgValue`, and some cases produce a magled name 
> different from what MSVC does. Should it be fixed in this PR, or may be 
> delayed?
We need to end up doing our best to match the microsoft mangling if at all 
possible, since they own the ABI.  I DEFINITELY would want any followup patch 
to be promised for Clang17 (that is, we don't release Clang17 with this patch 
and NOT that patch), so I'd expect said patch to be available for review before 
this gets committed.

As far as whether it needs to happen in THIS patch, we can perhaps decide based 
on the severity of the break, if you can provide examples (or, if it is split 
into a separate patch, we can use the tests there).



Comment at: clang/lib/AST/TemplateBase.cpp:244
+  else if (const ValueDecl *VD = getAsSimpleValueDeclRef(Ctx, Type, V))
+// FIXME: The Declaration form should expose a const ValueDecl*.
+initFromDeclaration(const_cast(VD), Type, IsDefaulted);

Why can this not happen now?



Comment at: clang/lib/Index/USRGeneration.cpp:1032
+  case TemplateArgument::UncommonValue:
+// FIXME: Visit value.
+break;

bolshakov-a wrote:
> aaron.ballman wrote:
> > Any particular reason this isn't being handled now?
> I need some guidance here. Which characters are allowed in the USR? Could the 
> mangling algorithm from `CXXNameMangler::mangleValueInTemplateArg` be moved 
> into some common place and reused here?
I have no idea what is valid here.  BUT @akyrtzi and @gribozavr (or @gribozavr2 
?) seem to be the ones that touch these files the most?



Comment at: clang/lib/Sema/SemaTemplate.cpp:7944
+  case APValue::Indeterminate:
+// FIXME: Are these values possible?
+  case APValue::LValue:

Rather than this, I'd prefer these all down to the llvm_unreachable below.  If 
we find they are reachable, then we'd be expected to implement them at that 
point.


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-13 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a added a comment.

It works, thanks!


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-13 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 504681.
bolshakov-a added a comment.

Update patch with more context.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7311,6 +7311,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1053,13 +1053,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2;>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1;>P1907R1
+  
+
+  Clang 17 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. delcared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1;>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3;>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::UncommonValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::UncommonValue:
+if (Expr *E = TAL.getSourceUncommonValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = 

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-13 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill added a comment.

In D140996#4189452 , @bolshakov-a 
wrote:

> Sorry! It's my first time using Phabricator. Maybe, the problem occurs 
> because I've solved the issue with Arcanist just by means of copy-pasting 
> patches into "Update Diff" Web GUI form.

There's nothing wrong with copy-pasting into web GUI form. You just have to 
export the patch with the right options, e.g. `git diff HEAD~1 -U99 > 
mypatch.patch` (more on this here 
).

> Maybe, I should reopen the PR?

You can simply update the review with properly exported patch.


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-13 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D140996#4189452 , @bolshakov-a 
wrote:

> Sorry! It's my first time using Phabricator. Maybe, the problem occurs 
> because I've solved the issue with Arcanist just by means of copy-pasting 
> patches into "Update Diff" Web GUI form. Maybe, I should reopen the PR?

When you generate your patch, you need to use -U99 to make sure you get 
full context.  I typically pipe it to a file (the git diff /git show HEAD), 
then use the upload file version.


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-13 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a added a comment.

Sorry! It's my first time using Phabricator. Maybe, the problem occurs because 
I've solved the issue with Arcanist just by means of copy-pasting patches into 
"Update Diff" Web GUI form. Maybe, I should reopen the PR?


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-13 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Patch seems to be missing all the context.


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-11 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 504407.
bolshakov-a added a comment.

Fix formatting.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7311,6 +7311,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1053,13 +1053,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2;>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1;>P1907R1
+  
+
+  Clang 17 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. delcared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1;>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3;>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::UncommonValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::UncommonValue:
+if (Expr *E = TAL.getSourceUncommonValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = TAL.getSourceNullPtrExpression())
   

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-11 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 504402.
bolshakov-a added a comment.

Rebase and replace "Clang 16" with "Clang 17" in `cxx_status.html` (Clang 16 RC 
has already been branched off, AFAIK).


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7311,6 +7311,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1053,13 +1053,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2;>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1;>P1907R1
+  
+
+  Clang 17 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. delcared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1;>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3;>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::UncommonValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::UncommonValue:
+if (Expr *E = TAL.getSourceUncommonValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return 

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added a comment.

In D140996#4185795 , @bolshakov-a 
wrote:

> @royjacobson, I've added some test cases for using the new NTTP arguments in 
> clang modules. It uses serialization, in principle. Or more specialized tests 
> are still needed?

No, I think that's good. Thanks for adding them!


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a added a comment.

@royjacobson, I've added some test cases for using the new NTTP arguments in 
clang modules. It uses serialization, in principle. Or more specialized tests 
are still needed?


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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 504255.
bolshakov-a added a comment.

Add relnote and update C++ status.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7293,6 +7293,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1053,13 +1053,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2;>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1;>P1907R1
+  
+
+  Clang 16 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. delcared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1;>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3;>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::UncommonValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::UncommonValue:
+if (Expr *E = TAL.getSourceUncommonValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = 

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 504254.
bolshakov-a added a comment.

Fix constness issue in `TemplateArgument` for `ASTContext`.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7293,6 +7293,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::UncommonValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::UncommonValue:
+if (Expr *E = TAL.getSourceUncommonValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = TAL.getSourceNullPtrExpression())
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
Index: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -8,8 +8,8 @@
 
 // floating-point arguments
 template struct Float {};
-using F1 = Float<1.0f>; // FIXME expected-error {{sorry}}
-using F1 = Float<2.0f / 2>; // FIXME expected-error {{sorry}}
+using F1 = Float<1.0f>;
+using F1 = Float<2.0f / 2>;
 
 struct S { int n[3]; } s; // expected-note 1+{{here}}
 union U { int a, b; } u;
@@ -17,24 +17,28 @@
 
 // pointers to subobjects
 template struct IntPtr {};
-using IPn = IntPtr< + 1>; // FIXME expected-error {{refers to subobject}}
-using IPn = IntPtr< + 1>; // FIXME expected-error {{refers to subobject}}
+using IPn = IntPtr< + 1>;
+using IPn = IntPtr< + 1>;
 
-using IP2 = 

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 504253.
bolshakov-a added a comment.

Add some testcases.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7293,6 +7293,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::UncommonValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::UncommonValue:
+if (Expr *E = TAL.getSourceUncommonValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = TAL.getSourceNullPtrExpression())
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
Index: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -8,8 +8,8 @@
 
 // floating-point arguments
 template struct Float {};
-using F1 = Float<1.0f>; // FIXME expected-error {{sorry}}
-using F1 = Float<2.0f / 2>; // FIXME expected-error {{sorry}}
+using F1 = Float<1.0f>;
+using F1 = Float<2.0f / 2>;
 
 struct S { int n[3]; } s; // expected-note 1+{{here}}
 union U { int a, b; } u;
@@ -17,24 +17,28 @@
 
 // pointers to subobjects
 template struct IntPtr {};
-using IPn = IntPtr< + 1>; // FIXME expected-error {{refers to subobject}}
-using IPn = IntPtr< + 1>; // FIXME expected-error {{refers to subobject}}
+using IPn = IntPtr< + 1>;
+using IPn = IntPtr< + 1>;
 
-using IP2 = 

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 504251.
bolshakov-a added a comment.

Add `ODRHash` calculation for `UncommonValue` (and test it).


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7293,6 +7293,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::UncommonValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::UncommonValue:
+if (Expr *E = TAL.getSourceUncommonValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = TAL.getSourceNullPtrExpression())
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
Index: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -8,8 +8,8 @@
 
 // floating-point arguments
 template struct Float {};
-using F1 = Float<1.0f>; // FIXME expected-error {{sorry}}
-using F1 = Float<2.0f / 2>; // FIXME expected-error {{sorry}}
+using F1 = Float<1.0f>;
+using F1 = Float<2.0f / 2>;
 
 struct S { int n[3]; } s; // expected-note 1+{{here}}
 union U { int a, b; } u;
@@ -17,24 +17,24 @@
 
 // pointers to subobjects
 template struct IntPtr {};
-using IPn = IntPtr< + 1>; // FIXME expected-error {{refers to subobject}}
-using IPn = IntPtr< + 1>; // FIXME expected-error {{refers to subobject}}
+using IPn = IntPtr< + 1>;
+using IPn 

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 504250.
bolshakov-a added a comment.
Herald added a subscriber: ChuanqiXu.

Add `ODRHash` calculation for UncommonValue (and test it).


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7293,6 +7293,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::UncommonValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::UncommonValue:
+if (Expr *E = TAL.getSourceUncommonValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = TAL.getSourceNullPtrExpression())
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
Index: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -8,8 +8,8 @@
 
 // floating-point arguments
 template struct Float {};
-using F1 = Float<1.0f>; // FIXME expected-error {{sorry}}
-using F1 = Float<2.0f / 2>; // FIXME expected-error {{sorry}}
+using F1 = Float<1.0f>;
+using F1 = Float<2.0f / 2>;
 
 struct S { int n[3]; } s; // expected-note 1+{{here}}
 union U { int a, b; } u;
@@ -17,24 +17,24 @@
 
 // pointers to subobjects
 template struct IntPtr {};
-using IPn = IntPtr< + 1>; // FIXME expected-error {{refers to subobject}}
-using IPn = IntPtr< + 1>; // FIXME expected-error {{refers to subobject}}

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 504249.
bolshakov-a added a comment.

Refactor `TemplateArgument` constructors.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7293,6 +7293,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::UncommonValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::UncommonValue:
+if (Expr *E = TAL.getSourceUncommonValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = TAL.getSourceNullPtrExpression())
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
Index: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -8,8 +8,8 @@
 
 // floating-point arguments
 template struct Float {};
-using F1 = Float<1.0f>; // FIXME expected-error {{sorry}}
-using F1 = Float<2.0f / 2>; // FIXME expected-error {{sorry}}
+using F1 = Float<1.0f>;
+using F1 = Float<2.0f / 2>;
 
 struct S { int n[3]; } s; // expected-note 1+{{here}}
 union U { int a, b; } u;
@@ -17,24 +17,24 @@
 
 // pointers to subobjects
 template struct IntPtr {};
-using IPn = IntPtr< + 1>; // FIXME expected-error {{refers to subobject}}
-using IPn = IntPtr< + 1>; // FIXME expected-error {{refers to subobject}}
+using IPn = IntPtr< + 1>;
+using IPn = IntPtr< + 1>;
 
-using IP2 = IntPtr<[2]>; // FIXME expected-error {{refers to 

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 504248.
bolshakov-a added a comment.

Fix after rebase.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7293,6 +7293,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::UncommonValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::UncommonValue:
+if (Expr *E = TAL.getSourceUncommonValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = TAL.getSourceNullPtrExpression())
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
Index: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -8,8 +8,8 @@
 
 // floating-point arguments
 template struct Float {};
-using F1 = Float<1.0f>; // FIXME expected-error {{sorry}}
-using F1 = Float<2.0f / 2>; // FIXME expected-error {{sorry}}
+using F1 = Float<1.0f>;
+using F1 = Float<2.0f / 2>;
 
 struct S { int n[3]; } s; // expected-note 1+{{here}}
 union U { int a, b; } u;
@@ -17,24 +17,24 @@
 
 // pointers to subobjects
 template struct IntPtr {};
-using IPn = IntPtr< + 1>; // FIXME expected-error {{refers to subobject}}
-using IPn = IntPtr< + 1>; // FIXME expected-error {{refers to subobject}}
+using IPn = IntPtr< + 1>;
+using IPn = IntPtr< + 1>;
 
-using IP2 = IntPtr<[2]>; // FIXME expected-error {{refers to subobject}}
-using IP2 = IntPtr; 

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 504247.
bolshakov-a added a comment.

Fix after rebase.


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

https://reviews.llvm.org/D140996

Files:
  clang/include/clang/AST/PropertiesBase.td


Index: clang/include/clang/AST/PropertiesBase.td
===
--- clang/include/clang/AST/PropertiesBase.td
+++ clang/include/clang/AST/PropertiesBase.td
@@ -798,8 +798,11 @@
   def : Property<"type", QualType> {
 let Read = [{ node.getUncommonValueType() }];
   }
+  def : Property<"isDefaulted", Bool> {
+let Read = [{ node.getIsDefaulted() }];
+  }
   def : Creator<[{
-return TemplateArgument(ctx, type, value);
+return TemplateArgument(ctx, type, value, isDefaulted);
   }]>;
 }
 let Class = PropertyTypeCase in {


Index: clang/include/clang/AST/PropertiesBase.td
===
--- clang/include/clang/AST/PropertiesBase.td
+++ clang/include/clang/AST/PropertiesBase.td
@@ -798,8 +798,11 @@
   def : Property<"type", QualType> {
 let Read = [{ node.getUncommonValueType() }];
   }
+  def : Property<"isDefaulted", Bool> {
+let Read = [{ node.getIsDefaulted() }];
+  }
   def : Creator<[{
-return TemplateArgument(ctx, type, value);
+return TemplateArgument(ctx, type, value, isDefaulted);
   }]>;
 }
 let Class = PropertyTypeCase in {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 504242.
bolshakov-a added a comment.

Rebased.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7293,6 +7293,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::UncommonValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::UncommonValue:
+if (Expr *E = TAL.getSourceUncommonValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = TAL.getSourceNullPtrExpression())
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
Index: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -8,8 +8,8 @@
 
 // floating-point arguments
 template struct Float {};
-using F1 = Float<1.0f>; // FIXME expected-error {{sorry}}
-using F1 = Float<2.0f / 2>; // FIXME expected-error {{sorry}}
+using F1 = Float<1.0f>;
+using F1 = Float<2.0f / 2>;
 
 struct S { int n[3]; } s; // expected-note 1+{{here}}
 union U { int a, b; } u;
@@ -17,24 +17,24 @@
 
 // pointers to subobjects
 template struct IntPtr {};
-using IPn = IntPtr< + 1>; // FIXME expected-error {{refers to subobject}}
-using IPn = IntPtr< + 1>; // FIXME expected-error {{refers to subobject}}
+using IPn = IntPtr< + 1>;
+using IPn = IntPtr< + 1>;
 
-using IP2 = IntPtr<[2]>; // FIXME expected-error {{refers to subobject}}
-using IP2 = IntPtr; // FIXME 

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a added a comment.

I have some problems with Arcanist... It tries to open a new PR instead of 
updating this one. Probably because I've re-cloned my local repository.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-10 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a added inline comments.



Comment at: clang/include/clang/AST/ASTContext.h:3036
 if (!std::is_trivially_destructible::value) {
-  auto DestroyPtr = [](void *V) { static_cast(V)->~T(); };
-  AddDeallocation(DestroyPtr, Ptr);
+  auto DestroyPtr = [](void *V) { ((T *)V)->~T(); };
+  AddDeallocation(DestroyPtr, (void *)Ptr);

erichkeane wrote:
> bolshakov-a wrote:
> > erichkeane wrote:
> > > This change is weird... what is going on here?
> > Here is not very beautiful attempt to workaround const-ness of 
> > `TemplateArgument::V::Value` pointer passed here from the added 
> > `TemplateArgument` constructor. The change in this line isn't acually 
> > needed and made only for consistence with the next line, I think. 
> > Alternatively, I can
> > 1) refactor `addDestruction` and `AddDeallocation` to work with pointers to 
> > constants, or
> > 2) add `const_cast` to `AddDeallocation` call in the next line, or
> > 3) make `TemplateArgument::V::Value` pointer non-const.
> > 
> > I'm biased to the first variant.
> I'd lean towards #3, it ends up being consistent with the rest of the things 
> here.  #1 is interesting, but that results in these functions violating 
> const-correctness.
I understand that calling the destructor on a reference to `const` looks 
strange, but it is reasonable: even constants should be destroyed.



Comment at: clang/include/clang/AST/TemplateBase.h:88
+/// so cannot be dependent.
+UncommonValue,
+

shafik wrote:
> erichkeane wrote:
> > I definitely hate the name here... Just `Value` makes a bit more sense, but 
> > isn't perfectly accurate.  Perhaps `NonTypeValue`?  But that is a little 
> > redundant.  `Uncommon` here is just strange and not particularly 
> > descriptive. 
> This catch all `UncommonValue` feels artificial. Maybe we need a separate out 
> the cases into more granular cases like `Float` etc
@erichkeane, it looks strange, I agree. Even just `CommonValue` sounds better 
for me (but my English is far from fluent). Maybe, `ArbitraryValue`?

@shafik, your suggestion would move this PR far enough from the original 
Richard's commit. And I'd prefer to merge `Declaration`, `Integral`, and 
`NullPtr` kinds into that is currently called `UncommonValue` rather than to 
repeat here various `APValue` kinds.



Comment at: clang/lib/AST/MicrosoftMangle.cpp:1670
+  case TemplateArgument::UncommonValue:
+if (ValueDecl *D = getAsArrayToPointerDecayedDecl(
+TA.getUncommonValueType(), TA.getAsUncommonValue())) {

erichkeane wrote:
> Has microsoft implemented this yet?  Can we see what they chose to do and 
> make sure we match them? 
Experimentally, I've made me sure that MSVC produces the same mangled names for 
the cases provided in the `mangle-ms-templates` test as in the test. But there 
are problems with references to subobjects: some cases are explicitly 
unsupported in `mangleTemplateArgValue`, and some cases produce a magled name 
different from what MSVC does. Should it be fixed in this PR, or may be delayed?



Comment at: clang/lib/AST/TemplateBase.cpp:619
+  case TemplateArgument::UncommonValue: {
+// FIXME: We're guessing at LangOptions!
+SmallString<32> Str;

erichkeane wrote:
> aaron.ballman wrote:
> > It's probably okay enough, but this is now the third instance of adding the 
> > same bug to this helper method -- maybe we should fix that instead?
> Agreed, seems to me we should do the work NOW to just wire in the lang-opts 
> to this function.
The problem here is because this function is called from a stream insertion 
operator, and there isn't obviously any way to pass 3rd parameter into it 
without switching it into an ordinary function.



Comment at: clang/lib/Index/USRGeneration.cpp:1032
+  case TemplateArgument::UncommonValue:
+// FIXME: Visit value.
+break;

aaron.ballman wrote:
> Any particular reason this isn't being handled now?
I need some guidance here. Which characters are allowed in the USR? Could the 
mangling algorithm from `CXXNameMangler::mangleValueInTemplateArg` be moved 
into some common place and reused here?



Comment at: clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp:204
+#if __cplusplus == 201703L
+  // cxx17-error@-3 {{non-type template argument refers to subobject '(int 
*)1'}}
+#endif

shafik wrote:
> Shouldn't this be an error b/c it is a temporary? What is `(int*)1` a 
> subobject of?
This PR doesn't change C++17 mode diagnostics. Btw, in C++20 mode, this is 
acceptable template argument.



Comment at: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp:12
+using F1 = Float<1.0f>;
+using F1 = Float<2.0f / 2>;
 

shafik wrote:
> I believe this is IFNDR the template-heads are functionally equivelent but 
> not equivelent: 

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-02-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/include/clang/AST/ASTContext.h:3036
 if (!std::is_trivially_destructible::value) {
-  auto DestroyPtr = [](void *V) { static_cast(V)->~T(); };
-  AddDeallocation(DestroyPtr, Ptr);
+  auto DestroyPtr = [](void *V) { ((T *)V)->~T(); };
+  AddDeallocation(DestroyPtr, (void *)Ptr);

bolshakov-a wrote:
> erichkeane wrote:
> > This change is weird... what is going on here?
> Here is not very beautiful attempt to workaround const-ness of 
> `TemplateArgument::V::Value` pointer passed here from the added 
> `TemplateArgument` constructor. The change in this line isn't acually needed 
> and made only for consistence with the next line, I think. Alternatively, I 
> can
> 1) refactor `addDestruction` and `AddDeallocation` to work with pointers to 
> constants, or
> 2) add `const_cast` to `AddDeallocation` call in the next line, or
> 3) make `TemplateArgument::V::Value` pointer non-const.
> 
> I'm biased to the first variant.
I'd lean towards #3, it ends up being consistent with the rest of the things 
here.  #1 is interesting, but that results in these functions violating 
const-correctness.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-02-25 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added a comment.

There are no AST [de]serialization tests in this PR, right? Would be nice to 
add some.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-02-25 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a added inline comments.



Comment at: clang/include/clang/AST/ASTContext.h:3036
 if (!std::is_trivially_destructible::value) {
-  auto DestroyPtr = [](void *V) { static_cast(V)->~T(); };
-  AddDeallocation(DestroyPtr, Ptr);
+  auto DestroyPtr = [](void *V) { ((T *)V)->~T(); };
+  AddDeallocation(DestroyPtr, (void *)Ptr);

erichkeane wrote:
> This change is weird... what is going on here?
Here is not very beautiful attempt to workaround const-ness of 
`TemplateArgument::V::Value` pointer passed here from the added 
`TemplateArgument` constructor. The change in this line isn't acually needed 
and made only for consistence with the next line, I think. Alternatively, I can
1) refactor `addDestruction` and `AddDeallocation` to work with pointers to 
constants, or
2) add `const_cast` to `AddDeallocation` call in the next line, or
3) make `TemplateArgument::V::Value` pointer non-const.

I'm biased to the first variant.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-02-24 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/include/clang/AST/TemplateBase.h:88
+/// so cannot be dependent.
+UncommonValue,
+

erichkeane wrote:
> I definitely hate the name here... Just `Value` makes a bit more sense, but 
> isn't perfectly accurate.  Perhaps `NonTypeValue`?  But that is a little 
> redundant.  `Uncommon` here is just strange and not particularly descriptive. 
This catch all `UncommonValue` feels artificial. Maybe we need a separate out 
the cases into more granular cases like `Float` etc



Comment at: clang/lib/AST/TemplateBase.cpp:204-211
+  if (Type->isIntegralOrEnumerationType() && V.isInt())
+*this = TemplateArgument(Ctx, V.getInt(), Type);
+  else if ((V.isLValue() && V.isNullPointer()) ||
+   (V.isMemberPointer() && !V.getMemberPointerDecl()))
+*this = TemplateArgument(Type, /*isNullPtr=*/true);
+  else if (const ValueDecl *VD = getAsSimpleValueDeclRef(Ctx, Type, V))
+// FIXME: The Declaration form should expose a const ValueDecl*.

erichkeane wrote:
> aaron.ballman wrote:
> > Well this is certainly a unique approach...  Personally, I think it'd be 
> > nice to not assign to `this` within a constructor by calling other 
> > constructor; that falls squarely into "wait, what, can you even DO that?" 
> > kind of questions for me.
> I agree, this function needs to be refactored to call some sort of 'init' 
> function or something, even if we have to refactor the other constructors.  
> This assignment to `*this` is just too strange to let stay.
I am going to third this sentiment, this is definitely not the right approach 
and the fact that you have this ad-hoc case below here also speaks to this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-02-24 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/test/CodeGenCXX/template-arguments.cpp:4
+
+template CONSTEXPR T id(T v) { return v; }
+template auto value = id(V);

I don't see any tests covering unions or enums.



Comment at: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp:12
+using F1 = Float<1.0f>;
+using F1 = Float<2.0f / 2>;
 

I believe this is IFNDR the template-heads are functionally equivelent but not 
equivelent: https://eel.is/c++draft/temp.class#general-3



Comment at: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp:56
+using CF = ComplexFloat<1.0f + 3.0fi>;
+using CF = ComplexFloat<3.0fi + 1.0f>;
 

Can we add an enum example e.g.:

```
enum E{ E1, E2};
template  struct SE {};
using IPE = SE;
using IPE = SE;

```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-02-24 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp:204
+#if __cplusplus == 201703L
+  // cxx17-error@-3 {{non-type template argument refers to subobject '(int 
*)1'}}
+#endif

Shouldn't this be an error b/c it is a temporary? What is `(int*)1` a subobject 
of?



Comment at: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp:21
+using IPn = IntPtr< + 1>;
+using IPn = IntPtr< + 1>;
 

`using IPn = IntPtr< + 2>` should be an error since that would be out of 
bounds, while `+1` is ok b/c it is one past the end as long as we don't deref.



Comment at: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp:21
+using IPn = IntPtr< + 1>;
+using IPn = IntPtr< + 1>;
 

shafik wrote:
> `using IPn = IntPtr< + 2>` should be an error since that would be out of 
> bounds, while `+1` is ok b/c it is one past the end as long as we don't deref.
gcc reject this one but I think their pointer math is wonky here: 
https://godbolt.org/z/fhMqPPefG



Comment at: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp:26
 
-using IP3 = IntPtr<[3]>; // FIXME expected-error {{refers to subobject}}
-using IP3 = IntPtr; // FIXME expected-error {{refers to subobject}}
+using IP3 = IntPtr<[3]>;
+using IP3 = IntPtr;

We should reject `IntPtr<[5]>;` again b/c it is out of bounds. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-02-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D140996#4150848 , @bolshakov-a 
wrote:

>> Should this also update the status in clang/www/cxx_status.html?
>
> I'm not sure. There still remains an issue with template parameters of 
> reference type, which was tried to be fixed in 5a391d38ac6c 
> . (On 
> the other hand, MSVC team claims that their compiler supports P1907R1, 
> despite that it simply crashes on some of the test cases from 5a391d38ac6c 
> )

Hmmm, okay, then I'd say we probably should update cxx_status. We can leave the 
status as "partial" but we can at least add details about what's still missing 
before we can claim full support. Kind of like we do for P0848R3 or P0315R4 on 
that page.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-02-24 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a added a subscriber: mizvekov.
bolshakov-a added a comment.

Thanks for the review! I definitely can try to answer questions and fix issues, 
but I just want to note that I'm not the original author, and these changes 
already were upstream. (Maybe, @rsmith will find some time for taking a look at 
this, after all?)

It would be nice if @mizvekov would check my changes regarding 
`SugaredConverted` vs `CanonicalConverted`.

> Should this also update the status in clang/www/cxx_status.html?

I'm not sure. There still remains an issue with template parameters of 
reference type, which was tried to be fixed in 5a391d38ac6c 
. (On the 
other hand, MSVC team claims that their compiler supports P1907R1, despite that 
it simply crashes on some of the test cases from 5a391d38ac6c 
)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-02-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/include/clang/AST/ASTContext.h:3036
 if (!std::is_trivially_destructible::value) {
-  auto DestroyPtr = [](void *V) { static_cast(V)->~T(); };
-  AddDeallocation(DestroyPtr, Ptr);
+  auto DestroyPtr = [](void *V) { ((T *)V)->~T(); };
+  AddDeallocation(DestroyPtr, (void *)Ptr);

This change is weird... what is going on here?



Comment at: clang/include/clang/AST/TemplateBase.h:88
+/// so cannot be dependent.
+UncommonValue,
+

I definitely hate the name here... Just `Value` makes a bit more sense, but 
isn't perfectly accurate.  Perhaps `NonTypeValue`?  But that is a little 
redundant.  `Uncommon` here is just strange and not particularly descriptive. 



Comment at: clang/lib/AST/MicrosoftMangle.cpp:1670
+  case TemplateArgument::UncommonValue:
+if (ValueDecl *D = getAsArrayToPointerDecayedDecl(
+TA.getUncommonValueType(), TA.getAsUncommonValue())) {

Has microsoft implemented this yet?  Can we see what they chose to do and make 
sure we match them? 



Comment at: clang/lib/AST/ODRHash.cpp:177
+case TemplateArgument::UncommonValue:
+  // FIXME: Include a representation of these arguments.
   break;

I feel like this DEFINITELY needs to happen.  Nullptr/integral is less 
important, but now that we have an actual value here, I think it needs to be 
part of the hash.



Comment at: clang/lib/AST/TemplateBase.cpp:204-211
+  if (Type->isIntegralOrEnumerationType() && V.isInt())
+*this = TemplateArgument(Ctx, V.getInt(), Type);
+  else if ((V.isLValue() && V.isNullPointer()) ||
+   (V.isMemberPointer() && !V.getMemberPointerDecl()))
+*this = TemplateArgument(Type, /*isNullPtr=*/true);
+  else if (const ValueDecl *VD = getAsSimpleValueDeclRef(Ctx, Type, V))
+// FIXME: The Declaration form should expose a const ValueDecl*.

aaron.ballman wrote:
> Well this is certainly a unique approach...  Personally, I think it'd be nice 
> to not assign to `this` within a constructor by calling other constructor; 
> that falls squarely into "wait, what, can you even DO that?" kind of 
> questions for me.
I agree, this function needs to be refactored to call some sort of 'init' 
function or something, even if we have to refactor the other constructors.  
This assignment to `*this` is just too strange to let stay.



Comment at: clang/lib/AST/TemplateBase.cpp:619
+  case TemplateArgument::UncommonValue: {
+// FIXME: We're guessing at LangOptions!
+SmallString<32> Str;

aaron.ballman wrote:
> It's probably okay enough, but this is now the third instance of adding the 
> same bug to this helper method -- maybe we should fix that instead?
Agreed, seems to me we should do the work NOW to just wire in the lang-opts to 
this function.



Comment at: clang/lib/Sema/SemaTemplate.cpp:7882
+Sema , QualType T, const APValue , SourceLocation Loc) {
+  auto MakeInitList = [&](ArrayRef Elts) -> Expr * {
+auto *ILE = new (S.Context) InitListExpr(S.Context, Loc, Elts, Loc);

I don't have a good idea of what is happening in this function here, it isn't 
really clear... before committing, someone needs to do a deep dive on this 
function for review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-02-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman edited reviewers, added: erichkeane, royjacobson, 
clang-language-wg; removed: mizvekov.
aaron.ballman added a subscriber: rjmccall.
aaron.ballman added a comment.

In D140996#4125177 , @bolshakov-a 
wrote:

> @aaron.ballman, @rsmith, @mizvekov, @shafik,  has the mankind any chance to 
> get this reviewed and merged?

Sorry for the delay in review! I've changed the reviewer list a bit to get more 
visibility on this. Also, don't forget to add a release note for the changes. 
Should this also update the status in `clang/www/cxx_status.html`?




Comment at: clang/lib/AST/ItaniumMangle.cpp:4397
+// argument.
+// As proposed in https://github.com/itanium-cxx-abi/cxx-abi/issues/111.
+auto *SNTTPE = cast(E);

We should get this nailed down. It was proposed in Nov 2020 and the issue is 
still open. CC @rjmccall 



Comment at: clang/lib/AST/TemplateBase.cpp:204-211
+  if (Type->isIntegralOrEnumerationType() && V.isInt())
+*this = TemplateArgument(Ctx, V.getInt(), Type);
+  else if ((V.isLValue() && V.isNullPointer()) ||
+   (V.isMemberPointer() && !V.getMemberPointerDecl()))
+*this = TemplateArgument(Type, /*isNullPtr=*/true);
+  else if (const ValueDecl *VD = getAsSimpleValueDeclRef(Ctx, Type, V))
+// FIXME: The Declaration form should expose a const ValueDecl*.

Well this is certainly a unique approach...  Personally, I think it'd be nice 
to not assign to `this` within a constructor by calling other constructor; that 
falls squarely into "wait, what, can you even DO that?" kind of questions for 
me.



Comment at: clang/lib/AST/TemplateBase.cpp:619
+  case TemplateArgument::UncommonValue: {
+// FIXME: We're guessing at LangOptions!
+SmallString<32> Str;

It's probably okay enough, but this is now the third instance of adding the 
same bug to this helper method -- maybe we should fix that instead?



Comment at: clang/lib/Index/USRGeneration.cpp:1032
+  case TemplateArgument::UncommonValue:
+// FIXME: Visit value.
+break;

Any particular reason this isn't being handled now?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-02-13 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a added a comment.

@aaron.ballman, @rsmith, @mizvekov, @shafik,  has the mankind any chance to get 
this reviewed and merged?

Btw, FYI, I've investigated the Chromium compilation crash that caused the 
rollback in 8ba442bc2136 
 and have 
succeeded in obtaining a smaller reproducer:

  void fn() {
auto L = [i = 5](auto) -> decltype(auto) { return i; };
L(2);
  }

After 5a391d38ac6c 
, 
`DeclRefExpr` in lambda `return` statement referring to `i` becomes 
instantiation dependent because decl context of `i` declaration occurs to be 
the templated lambda `operator()` and not the lambda implicit (non-templated) 
class (which seems to be wrong). Then, after da986511fb9da1a 
, that 
dependence flag started to propagate through `DecltypeType`, and `L(2)` call 
result type becomes "dependent", which, of course, should not occur.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140996

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-01-04 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a created this revision.
bolshakov-a added reviewers: aaron.ballman, rsmith, mizvekov.
Herald added subscribers: kadircet, arphaman, martong, kristof.beyls.
Herald added a reviewer: shafik.
Herald added a project: All.
bolshakov-a requested review of this revision.
Herald added projects: clang, LLDB, clang-tools-extra.
Herald added subscribers: cfe-commits, lldb-commits.

Previously committed as 9e08e51a20d0d2b1c5724bb17e969d036fced4cd 
, and
reverted because a dependency commit was reverted, then commited again
as 4b574008aef5a7235c1f894ab065fe300d26e786 
 and 
reverted again because
"dependency commit" 5a391d38ac6c561ba908334d427f26124ed9132e 
 was
reverted. But it doesn't seem that 5a391d38ac6c 
 was a 
real dependency
for this.

This commit incorporates 4b574008aef5a7235c1f894ab065fe300d26e786 
 and
18e093faf726d15f210ab4917142beec51848258 
 by 
Richard Smith, with some
minor fixes, most notably:

- `VK_PRValue` instead of `VK_RValue` as default kind in lvalue and

member pointer handling branch
in `BuildExpressionFromNonTypeTemplateArgumentValue`;

- handling of `UncommonValue` in `IsTypeDeclaredInsideVisitor`;

- filling in `SugaredConverted` along with `CanonicalConverted`

parameter in `Sema::CheckTemplateArgument`;

- minor cleanup

in `TemplateInstantiator::transformNonTypeTemplateParmRef`;

- `noundef` attribute and opaque pointers in `template-arguments` test;

- analysis for C++17 mode is turned off for templates

in `warn-bool-conversion` test;
in C++17 and C++20 mode, array reference used as a template argument
of pointer type produces template argument of UncommonValue type, and
`BuildExpressionFromNonTypeTemplateArgumentValue` makes
`OpaqueValueExpr` for it, and `DiagnoseAlwaysNonNullPointer` cannot see
through it; despite of "These cases should not warn" comment, I'm not
sure about correct behavior; I'd expect a suggestion to replace `if` by
`if constexpr`;

- `temp.arg.nontype/p1.cpp` test fixed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7276,6 +7276,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -832,6 +832,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 ///