[clang] [clang-tools-extra] [lldb] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)
mizvekov wrote: This missed adding support to StructuralValue template arguments to the template differ. See https://github.com/llvm/llvm-project/pull/93265 Te support is still missing, we are just avoiding the crash for now. https://github.com/llvm/llvm-project/pull/78041 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [lldb] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)
https://github.com/bolshakov-a updated https://github.com/llvm/llvm-project/pull/78041 >From 35e5e87d5c6f250f9f7a6cf5e5aeaebe5929f155 Mon Sep 17 00:00:00 2001 From: Andrey Ali Khan Bolshakov Date: Sun, 6 Aug 2023 19:38:23 +0300 Subject: [PATCH] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. Previously committed as 9e08e51a20d0d2b1c5724bb17e969d036fced4cd, and reverted because a dependency commit was reverted, then committed 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: - `UncommonValue` renamed to `StructuralValue` - `VK_PRValue` instead of `VK_RValue` as default kind in lvalue and member pointer handling branch in `BuildExpressionFromNonTypeTemplateArgumentValue`; - handling of `StructuralValue` in `IsTypeDeclaredInsideVisitor`; - filling in `SugaredConverted` along with `CanonicalConverted` parameter in `Sema::CheckTemplateArgument`; - minor cleanup in `TemplateInstantiator::transformNonTypeTemplateParmRef`; - `TemplateArgument` constructors refactored; - `ODRHash` calculation for `UncommonValue`; - USR generation for `UncommonValue`; - more correct MS compatibility mangling algorithm (tested on MSVC ver. 19.35; toolset ver. 143); - IR emitting fixed on using a subobject as a template argument when the corresponding template parameter is used in an lvalue context; - `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` and `dr18xx.cpp` tests fixed. --- clang-tools-extra/clangd/DumpAST.cpp | 1 + clang-tools-extra/clangd/FindTarget.cpp | 1 + clang/docs/ReleaseNotes.rst | 2 + clang/include/clang/AST/ODRHash.h | 3 + clang/include/clang/AST/PropertiesBase.td | 14 ++ clang/include/clang/AST/RecursiveASTVisitor.h | 2 + .../clang/AST/TemplateArgumentVisitor.h | 2 + clang/include/clang/AST/TemplateBase.h| 86 --- .../clang/Basic/DiagnosticSemaKinds.td| 5 - clang/include/clang/Sema/Sema.h | 4 +- clang/lib/AST/ASTContext.cpp | 5 + clang/lib/AST/ASTImporter.cpp | 13 ++ clang/lib/AST/ASTStructuralEquivalence.cpp| 3 + clang/lib/AST/Decl.cpp| 4 + clang/lib/AST/ItaniumMangle.cpp | 36 ++- clang/lib/AST/MicrosoftMangle.cpp | 78 +-- clang/lib/AST/ODRHash.cpp | 67 ++ clang/lib/AST/StmtProfile.cpp | 6 + clang/lib/AST/TemplateBase.cpp| 113 - clang/lib/AST/TypeLoc.cpp | 1 + clang/lib/CodeGen/CGDebugInfo.cpp | 10 + clang/lib/CodeGen/CGExpr.cpp | 12 +- clang/lib/Index/USRGeneration.cpp | 10 + clang/lib/Sema/SemaLookup.cpp | 1 + clang/lib/Sema/SemaOverload.cpp | 10 +- clang/lib/Sema/SemaTemplate.cpp | 218 +++--- clang/lib/Sema/SemaTemplateDeduction.cpp | 64 +++-- clang/lib/Sema/SemaTemplateInstantiate.cpp| 14 +- clang/lib/Sema/SemaTemplateVariadic.cpp | 2 + clang/lib/Sema/TreeTransform.h| 12 +- clang/lib/Serialization/ASTReader.cpp | 1 + clang/lib/Serialization/ASTWriter.cpp | 1 + clang/test/CXX/drs/dr18xx.cpp | 4 +- .../CXX/temp/temp.arg/temp.arg.nontype/p1.cpp | 4 +- clang/test/CodeGenCXX/mangle-ms-templates.cpp | 48 clang/test/CodeGenCXX/mangle-template.cpp | 40 +++- clang/test/CodeGenCXX/template-arguments.cpp | 113 + .../Index/USR/structural-value-tpl-arg.cpp| 23 ++ clang/test/Modules/odr_hash.cpp | 193 +++- clang/test/SemaCXX/warn-bool-conversion.cpp | 2 + .../SemaTemplate/temp_arg_nontype_cxx1z.cpp | 40 ++-- .../SemaTemplate/temp_arg_nontype_cxx20.cpp | 40 ++-- clang/tools/libclang/CIndex.cpp | 5 + clang/tools/libclang/CXCursor.cpp | 3 + clang/www/cxx_status.html | 18 +- lldb/include/lldb/lldb-enumerations.h | 1 + .../TypeSystem/Clang/TypeSystemClang.cpp
[clang] [clang-tools-extra] [lldb] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)
https://github.com/bolshakov-a updated https://github.com/llvm/llvm-project/pull/78041 >From 7abb30826263ad69d529dd6af585bf3bce40f979 Mon Sep 17 00:00:00 2001 From: Andrey Ali Khan Bolshakov Date: Sun, 6 Aug 2023 19:38:23 +0300 Subject: [PATCH] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. Previously committed as 9e08e51a20d0d2b1c5724bb17e969d036fced4cd, and reverted because a dependency commit was reverted, then committed 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: - `UncommonValue` renamed to `StructuralValue` - `VK_PRValue` instead of `VK_RValue` as default kind in lvalue and member pointer handling branch in `BuildExpressionFromNonTypeTemplateArgumentValue`; - handling of `StructuralValue` in `IsTypeDeclaredInsideVisitor`; - filling in `SugaredConverted` along with `CanonicalConverted` parameter in `Sema::CheckTemplateArgument`; - minor cleanup in `TemplateInstantiator::transformNonTypeTemplateParmRef`; - `TemplateArgument` constructors refactored; - `ODRHash` calculation for `UncommonValue`; - USR generation for `UncommonValue`; - more correct MS compatibility mangling algorithm (tested on MSVC ver. 19.35; toolset ver. 143); - IR emitting fixed on using a subobject as a template argument when the corresponding template parameter is used in an lvalue context; - `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` and `dr18xx.cpp` tests fixed. --- clang-tools-extra/clangd/DumpAST.cpp | 1 + clang-tools-extra/clangd/FindTarget.cpp | 1 + clang/docs/ReleaseNotes.rst | 2 + clang/include/clang/AST/ODRHash.h | 3 + clang/include/clang/AST/PropertiesBase.td | 14 ++ clang/include/clang/AST/RecursiveASTVisitor.h | 2 + .../clang/AST/TemplateArgumentVisitor.h | 2 + clang/include/clang/AST/TemplateBase.h| 86 --- .../clang/Basic/DiagnosticSemaKinds.td| 5 - clang/include/clang/Sema/Sema.h | 4 +- clang/lib/AST/ASTContext.cpp | 5 + clang/lib/AST/ASTImporter.cpp | 13 ++ clang/lib/AST/ASTStructuralEquivalence.cpp| 3 + clang/lib/AST/Decl.cpp| 4 + clang/lib/AST/ItaniumMangle.cpp | 36 ++- clang/lib/AST/MicrosoftMangle.cpp | 78 +-- clang/lib/AST/ODRHash.cpp | 67 ++ clang/lib/AST/StmtProfile.cpp | 6 + clang/lib/AST/TemplateBase.cpp| 113 - clang/lib/AST/TypeLoc.cpp | 1 + clang/lib/CodeGen/CGDebugInfo.cpp | 10 + clang/lib/CodeGen/CGExpr.cpp | 12 +- clang/lib/Index/USRGeneration.cpp | 10 + clang/lib/Sema/SemaLookup.cpp | 1 + clang/lib/Sema/SemaOverload.cpp | 10 +- clang/lib/Sema/SemaTemplate.cpp | 218 +++--- clang/lib/Sema/SemaTemplateDeduction.cpp | 64 +++-- clang/lib/Sema/SemaTemplateInstantiate.cpp| 14 +- clang/lib/Sema/SemaTemplateVariadic.cpp | 2 + clang/lib/Sema/TreeTransform.h| 12 +- clang/lib/Serialization/ASTReader.cpp | 1 + clang/lib/Serialization/ASTWriter.cpp | 1 + clang/test/CXX/drs/dr18xx.cpp | 4 +- .../CXX/temp/temp.arg/temp.arg.nontype/p1.cpp | 4 +- clang/test/CodeGenCXX/mangle-ms-templates.cpp | 48 clang/test/CodeGenCXX/mangle-template.cpp | 40 +++- clang/test/CodeGenCXX/template-arguments.cpp | 113 + .../Index/USR/structural-value-tpl-arg.cpp| 23 ++ clang/test/Modules/odr_hash.cpp | 193 +++- clang/test/SemaCXX/warn-bool-conversion.cpp | 2 + .../SemaTemplate/temp_arg_nontype_cxx1z.cpp | 40 ++-- .../SemaTemplate/temp_arg_nontype_cxx20.cpp | 40 ++-- clang/tools/libclang/CIndex.cpp | 5 + clang/tools/libclang/CXCursor.cpp | 3 + clang/www/cxx_status.html | 18 +- lldb/include/lldb/lldb-enumerations.h | 1 + .../TypeSystem/Clang/TypeSystemClang.cpp
[clang] [clang-tools-extra] [lldb] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)
https://github.com/bolshakov-a updated https://github.com/llvm/llvm-project/pull/78041 >From e2fa0ec1fbb77a521b92f2a17f45879ca01cd304 Mon Sep 17 00:00:00 2001 From: Andrey Ali Khan Bolshakov Date: Sun, 6 Aug 2023 19:38:23 +0300 Subject: [PATCH] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. Previously committed as 9e08e51a20d0d2b1c5724bb17e969d036fced4cd, and reverted because a dependency commit was reverted, then committed 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: - `UncommonValue` renamed to `StructuralValue` - `VK_PRValue` instead of `VK_RValue` as default kind in lvalue and member pointer handling branch in `BuildExpressionFromNonTypeTemplateArgumentValue`; - handling of `StructuralValue` in `IsTypeDeclaredInsideVisitor`; - filling in `SugaredConverted` along with `CanonicalConverted` parameter in `Sema::CheckTemplateArgument`; - minor cleanup in `TemplateInstantiator::transformNonTypeTemplateParmRef`; - `TemplateArgument` constructors refactored; - `ODRHash` calculation for `UncommonValue`; - USR generation for `UncommonValue`; - more correct MS compatibility mangling algorithm (tested on MSVC ver. 19.35; toolset ver. 143); - IR emitting fixed on using a subobject as a template argument when the corresponding template parameter is used in an lvalue context; - `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` and `dr18xx.cpp` tests fixed. --- clang-tools-extra/clangd/DumpAST.cpp | 1 + clang-tools-extra/clangd/FindTarget.cpp | 1 + clang/docs/ReleaseNotes.rst | 3 + clang/include/clang/AST/ODRHash.h | 3 + clang/include/clang/AST/PropertiesBase.td | 14 ++ clang/include/clang/AST/RecursiveASTVisitor.h | 2 + .../clang/AST/TemplateArgumentVisitor.h | 2 + clang/include/clang/AST/TemplateBase.h| 86 --- .../clang/Basic/DiagnosticSemaKinds.td| 5 - clang/include/clang/Sema/Sema.h | 4 +- clang/lib/AST/ASTContext.cpp | 5 + clang/lib/AST/ASTImporter.cpp | 13 ++ clang/lib/AST/ASTStructuralEquivalence.cpp| 3 + clang/lib/AST/Decl.cpp| 4 + clang/lib/AST/ItaniumMangle.cpp | 36 ++- clang/lib/AST/MicrosoftMangle.cpp | 78 +-- clang/lib/AST/ODRHash.cpp | 67 ++ clang/lib/AST/StmtProfile.cpp | 6 + clang/lib/AST/TemplateBase.cpp| 113 - clang/lib/AST/TypeLoc.cpp | 1 + clang/lib/CodeGen/CGDebugInfo.cpp | 10 + clang/lib/CodeGen/CGExpr.cpp | 12 +- clang/lib/Index/USRGeneration.cpp | 10 + clang/lib/Sema/SemaLookup.cpp | 1 + clang/lib/Sema/SemaOverload.cpp | 10 +- clang/lib/Sema/SemaTemplate.cpp | 218 +++--- clang/lib/Sema/SemaTemplateDeduction.cpp | 64 +++-- clang/lib/Sema/SemaTemplateInstantiate.cpp| 14 +- clang/lib/Sema/SemaTemplateVariadic.cpp | 2 + clang/lib/Sema/TreeTransform.h| 12 +- clang/lib/Serialization/ASTReader.cpp | 1 + clang/lib/Serialization/ASTWriter.cpp | 1 + clang/test/CXX/drs/dr18xx.cpp | 4 +- .../CXX/temp/temp.arg/temp.arg.nontype/p1.cpp | 4 +- clang/test/CodeGenCXX/mangle-ms-templates.cpp | 48 clang/test/CodeGenCXX/mangle-template.cpp | 40 +++- clang/test/CodeGenCXX/template-arguments.cpp | 113 + .../Index/USR/structural-value-tpl-arg.cpp| 23 ++ clang/test/Modules/odr_hash.cpp | 193 +++- clang/test/SemaCXX/warn-bool-conversion.cpp | 2 + .../SemaTemplate/temp_arg_nontype_cxx1z.cpp | 40 ++-- .../SemaTemplate/temp_arg_nontype_cxx20.cpp | 40 ++-- clang/tools/libclang/CIndex.cpp | 5 + clang/tools/libclang/CXCursor.cpp | 3 + clang/www/cxx_status.html | 18 +- lldb/include/lldb/lldb-enumerations.h | 1 + .../TypeSystem/Clang/TypeSystemClang.cpp
[clang] [clang-tools-extra] [lldb] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)
@@ -5401,6 +5409,8 @@ std::string CGDebugInfo::GetName(const Decl *D, bool Qualified) const { // feasible some day. return TA.getAsIntegral().getBitWidth() <= 64 && IsReconstitutableType(TA.getIntegralType()); + case TemplateArgument::StructuralValue: +return false; dwblaikie wrote: I did finally take a look at this - I think the Clang side of things is fine - if anything improvements could be made to LLVM to be able to lower constants to DWARF for a wider variety of values. eg: For the `float` example, the IR is: ``` !8 = !DITemplateValueParameter(name: "F", type: !9, value: float 1.00e+00) ``` But the DWARF backend can't handle the float constant - the handling is in `DwarfUnit::constructTemplateValueParameterDIE` (in llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp) and currently only handles ConstantInt (for basic stuff - bools, ints, etc) and GlobalValue (for pointer non-type template parameters). So for these new floats and such, the DWARF doesn't include the value, only the type. GCC uses this encoding, for instance: ``` 0x002b: DW_TAG_template_value_parameter [3] (0x001e) DW_AT_name [DW_FORM_string] ("F") DW_AT_type [DW_FORM_ref4] (cu + 0x004d => {0x004d} "float") DW_AT_const_value [DW_FORM_block1](<0x04> 00 00 80 3f ) ``` https://github.com/llvm/llvm-project/pull/78041 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [lldb] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)
@@ -5401,6 +5409,8 @@ std::string CGDebugInfo::GetName(const Decl *D, bool Qualified) const { // feasible some day. return TA.getAsIntegral().getBitWidth() <= 64 && IsReconstitutableType(TA.getIntegralType()); + case TemplateArgument::StructuralValue: +return false; bolshakov-a wrote: Thanks for clarifying! Probably, I'll come back to this some day to extend the backend, but I'm not sure. https://github.com/llvm/llvm-project/pull/78041 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [lldb] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)
@@ -5401,6 +5409,8 @@ std::string CGDebugInfo::GetName(const Decl *D, bool Qualified) const { // feasible some day. return TA.getAsIntegral().getBitWidth() <= 64 && IsReconstitutableType(TA.getIntegralType()); + case TemplateArgument::StructuralValue: +return false; dwblaikie wrote: Sorry for the delays in the debug info review for this - it is on my list :/ https://github.com/llvm/llvm-project/pull/78041 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [lldb] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)
eaeltsin wrote: > @eaeltsin, could you try out [that > branch](https://github.com/bolshakov-a/llvm-project/tree/avoid_regressions)? @bolshakov-a yes, this patch makes the "undefined symbol" linker error go away. Will you proceed with submitting? https://github.com/llvm/llvm-project/pull/78041 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [lldb] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)
https://github.com/erichkeane edited https://github.com/llvm/llvm-project/pull/78041 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits