[clang] retain type sugar in auto / template argument deduction
authorMatheus Izvekov <mizvekov@gmail.com>
Mon, 13 Sep 2021 13:35:45 +0000 (15:35 +0200)
committerMatheus Izvekov <mizvekov@gmail.com>
Fri, 12 Nov 2021 00:16:31 +0000 (01:16 +0100)
commit9b6036deedf28e10d797fc4ca734d57680d18053
treec27b5d77fd4c7fc217f1e38f6572a4633bfdeb3f
parentac33e65d2169260364e3e92fed2ba81c58d5ce33
[clang] retain type sugar in auto / template argument deduction

This implements the following changes:
* AutoType retains sugared deduced-as-type.
* Template argument deduction machinery analyses the sugared type all the way
down. It would previously lose the sugar on first recursion.
* Undeduced AutoType will be properly canonicalized, including the constraint
template arguments.
* Remove the decltype node created from the decltype(auto) deduction.

As a result, we start seeing sugared types in a lot more test cases,
including some which showed very unfriendly `type-parameter-*-*` types.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D110216
44 files changed:
clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/InlayHints.cpp
clang-tools-extra/clangd/unittests/ASTTests.cpp
clang-tools-extra/clangd/unittests/HoverTests.cpp
clang-tools-extra/clangd/unittests/InlayHintTests.cpp
clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-owning-memory.cpp
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/Type.h
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/Type.cpp
clang/lib/Sema/SemaCXXScopeSpec.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/SemaStmt.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/Sema/TreeTransform.h
clang/test/CXX/over/over.match/over.match.funcs/over.match.class.deduct/p2.cpp
clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
clang/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp
clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p1-0x.cpp
clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p4.cpp
clang/test/Index/print-type.cpp
clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
clang/test/SemaCXX/cxx1z-decomposition.cpp
clang/test/SemaCXX/deduced-return-type-cxx14.cpp
clang/test/SemaCXX/friend.cpp
clang/test/SemaCXX/recovery-expr-type.cpp
clang/test/SemaCXX/sizeless-1.cpp
clang/test/SemaCXX/sugared-auto.cpp [new file with mode: 0644]
clang/test/SemaTemplate/attributes.cpp
clang/test/SemaTemplate/friend.cpp
clang/test/SemaTemplate/operator-template.cpp