]> granicus.if.org Git - clang/commit
[C++2a] Add __builtin_bit_cast, used to implement std::bit_cast
authorErik Pilkington <erik.pilkington@gmail.com>
Tue, 2 Jul 2019 18:28:13 +0000 (18:28 +0000)
committerErik Pilkington <erik.pilkington@gmail.com>
Tue, 2 Jul 2019 18:28:13 +0000 (18:28 +0000)
commit159cd770e3ea0c5cba37006c4dc96b3235670f0d
tree0f7c041619d7593e111a77c1f79954b83b6dbf99
parent54b8029400637989d16f8467643c46296e62e1d3
[C++2a] Add __builtin_bit_cast, used to implement std::bit_cast

This commit adds a new builtin, __builtin_bit_cast(T, v), which performs a
bit_cast from a value v to a type T. This expression can be evaluated at
compile time under specific circumstances.

The compile time evaluation currently doesn't support bit-fields, but I'm
planning on fixing this in a follow up (some of the logic for figuring this out
is in CodeGen). I'm also planning follow-ups for supporting some more esoteric
types that the constexpr evaluator supports, as well as extending
__builtin_memcpy constexpr evaluation to use the same infrastructure.

rdar://44987528

Differential revision: https://reviews.llvm.org/D62825

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@364954 91177308-0d34-0410-b5e6-96231b3b80d8
38 files changed:
include/clang-c/Index.h
include/clang/AST/ExprCXX.h
include/clang/AST/OperationKinds.def
include/clang/AST/RecursiveASTVisitor.h
include/clang/Basic/DiagnosticASTKinds.td
include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Basic/StmtNodes.td
include/clang/Basic/TokenKinds.def
include/clang/Parse/Parser.h
include/clang/Sema/Sema.h
lib/AST/Expr.cpp
lib/AST/ExprClassification.cpp
lib/AST/ExprConstant.cpp
lib/AST/ItaniumMangle.cpp
lib/AST/StmtPrinter.cpp
lib/AST/StmtProfile.cpp
lib/CodeGen/CGExpr.cpp
lib/CodeGen/CGExprAgg.cpp
lib/CodeGen/CGExprComplex.cpp
lib/CodeGen/CGExprConstant.cpp
lib/CodeGen/CGExprScalar.cpp
lib/Edit/RewriteObjCFoundationAPI.cpp
lib/Lex/PPMacroExpansion.cpp
lib/Parse/ParseExpr.cpp
lib/Parse/ParseExprCXX.cpp
lib/Sema/SemaCast.cpp
lib/Sema/SemaExceptionSpec.cpp
lib/Sema/TreeTransform.h
lib/Serialization/ASTReaderStmt.cpp
lib/Serialization/ASTWriterStmt.cpp
lib/StaticAnalyzer/Core/ExprEngine.cpp
lib/StaticAnalyzer/Core/ExprEngineC.cpp
test/CodeGenCXX/builtin-bit-cast-no-tbaa.cpp [new file with mode: 0644]
test/CodeGenCXX/builtin-bit-cast.cpp [new file with mode: 0644]
test/SemaCXX/builtin-bit-cast.cpp [new file with mode: 0644]
test/SemaCXX/constexpr-builtin-bit-cast.cpp [new file with mode: 0644]
tools/libclang/CIndex.cpp
tools/libclang/CXCursor.cpp