[clang] adds unary type transformations as compiler built-ins
authorChristopher Di Bella <cjdb@google.com>
Mon, 22 Aug 2022 00:27:10 +0000 (00:27 +0000)
committerChristopher Di Bella <cjdb@google.com>
Mon, 22 Aug 2022 03:03:32 +0000 (03:03 +0000)
commite9ef45635b77598fc9ce0cd38d7d3f8c9d88a49d
tree8efe48cde4ea5365183924ac3cd27c962e29dd3f
parentd2d77e050b32ce3f917688aeeb9e6f8f3c209560
[clang] adds unary type transformations as compiler built-ins

Adds

* `__add_lvalue_reference`
* `__add_pointer`
* `__add_rvalue_reference`
* `__decay`
* `__make_signed`
* `__make_unsigned`
* `__remove_all_extents`
* `__remove_extent`
* `__remove_const`
* `__remove_volatile`
* `__remove_cv`
* `__remove_pointer`
* `__remove_reference`
* `__remove_cvref`

These are all compiler built-in equivalents of the unary type traits
found in [[meta.trans]][1]. The compiler already has all of the
information it needs to answer these transformations, so we can skip
needing to make partial specialisations in standard library
implementations (we already do this for a lot of the query traits). This
will hopefully improve compile times, as we won't need use as much
memory in such a base part of the standard library.

[1]: http://wg21.link/meta.trans

Co-authored-by: zoecarver
Reviewed By: aaron.ballman, rsmith

Differential Revision: https://reviews.llvm.org/D116203
33 files changed:
clang/include/clang/AST/Type.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/Specifiers.h
clang/include/clang/Basic/TokenKinds.def
clang/include/clang/Basic/TransformTypeTraits.def [new file with mode: 0644]
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/DeclSpec.h
clang/include/clang/Sema/Sema.h
clang/include/clang/module.modulemap
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/JSONNodeDumper.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/AST/TypePrinter.cpp
clang/lib/Format/FormatToken.cpp
clang/lib/Format/FormatToken.h
clang/lib/Format/TokenAnnotator.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Parse/ParseExpr.cpp
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Parse/ParseStmt.cpp
clang/lib/Parse/ParseTentative.cpp
clang/lib/Sema/DeclSpec.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaTemplateVariadic.cpp
clang/lib/Sema/SemaType.cpp
clang/test/CodeGenCXX/mangle.cpp
clang/test/SemaCXX/libstdcxx_transform_type_traits_hack.cpp [new file with mode: 0644]
clang/test/SemaCXX/remove_pointer.mm [new file with mode: 0644]
clang/test/SemaCXX/type-traits.cpp
clang/utils/ClangVisualizers/clang.natvis