[PATCH] D137458: [clang] Add __decay<T> as a builtin template

Troy Johnson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 4 12:37:53 PDT 2022


troyj created this revision.
troyj added a reviewer: bruno.
Herald added a subscriber: martong.
Herald added a reviewer: shafik.
Herald added a project: All.
troyj requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

`__decay(T)` exists as a builtin, but does not use template syntax like the other builtin templates `__make_integer_seq` and `__type_pack_element`. With template syntax, users can write portable code that uses `__decay<T>` when it's available but falls back to a `__decay<T>` in a local namespace when it's not available. Template aliasing can provide the same behavior, but at the cost of longer compile time. It is faster to compile a direct use of a builtin than a use via an alias. This compile time difference is measurable in large TUs that make heavy use of templates. Currently the only performant alternative is to use preprocessor macros in the user's code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137458

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/Builtins.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/SemaCXX/libstdcxx_transform_type_traits_hack.cpp
  clang/test/SemaCXX/type-traits.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137458.473315.patch
Type: text/x-patch
Size: 11770 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221104/86231470/attachment.bin>


More information about the cfe-commits mailing list