[clang] retain type sugar in auto / template argument deduction
authorMatheus Izvekov <mizvekov@gmail.com>
Fri, 12 Nov 2021 23:40:18 +0000 (00:40 +0100)
committerMatheus Izvekov <mizvekov@gmail.com>
Mon, 15 Nov 2021 22:07:45 +0000 (23:07 +0100)
commitc9e46219f38da5c3fbfe41012173dc893516826e
tree85f67ee7019d7fd890bad0232e9d247e71e51472
parentfcd07f810781c1754c2e7e9641fd18b95fa1368c
[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, #libc, ldionne

Differential Revision: https://reviews.llvm.org/D110216
48 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/deduction.cpp
clang/test/SemaTemplate/friend.cpp
clang/test/SemaTemplate/operator-template.cpp
libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.verify.cpp [moved from libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.fail.cpp with 81% similarity]
libcxx/test/std/utilities/any/any.nonmembers/any.cast/not_copy_constructible.verify.cpp [moved from libcxx/test/std/utilities/any/any.nonmembers/any.cast/not_copy_constructible.fail.cpp with 81% similarity]
lldb/test/Shell/SymbolFile/NativePDB/function-types-builtins.cpp