[llvm-branch-commits] [cfe-branch] r309135 - Merging r309058:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jul 26 09:35:53 PDT 2017
Author: hans
Date: Wed Jul 26 09:35:53 2017
New Revision: 309135
URL: http://llvm.org/viewvc/llvm-project?rev=309135&view=rev
Log:
Merging r309058:
------------------------------------------------------------------------
r309058 | majnemer | 2017-07-25 16:33:58 -0700 (Tue, 25 Jul 2017) | 9 lines
[CodeGen] Correctly model std::byte's aliasing properties
std::byte, when defined as an enum, needs to be given special treatment
with regards to its aliasing properties. An array of std::byte is
allowed to be used as storage for other types.
This fixes PR33916.
Differential Revision: https://reviews.llvm.org/D35824
------------------------------------------------------------------------
Added:
cfe/branches/release_50/test/CodeGenCXX/std-byte.cpp
- copied unchanged from r309058, cfe/trunk/test/CodeGenCXX/std-byte.cpp
Modified:
cfe/branches/release_50/ (props changed)
cfe/branches/release_50/include/clang/AST/Type.h
cfe/branches/release_50/lib/AST/Type.cpp
cfe/branches/release_50/lib/CodeGen/CodeGenTBAA.cpp
Propchange: cfe/branches/release_50/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jul 26 09:35:53 2017
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:308455,308824,308897
+/cfe/trunk:308455,308824,308897,309058
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_50/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/include/clang/AST/Type.h?rev=309135&r1=309134&r2=309135&view=diff
==============================================================================
--- cfe/branches/release_50/include/clang/AST/Type.h (original)
+++ cfe/branches/release_50/include/clang/AST/Type.h Wed Jul 26 09:35:53 2017
@@ -1752,6 +1752,7 @@ public:
bool isTemplateTypeParmType() const; // C++ template type parameter
bool isNullPtrType() const; // C++11 std::nullptr_t
bool isAlignValT() const; // C++17 std::align_val_t
+ bool isStdByteType() const; // C++17 std::byte
bool isAtomicType() const; // C11 _Atomic()
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
Modified: cfe/branches/release_50/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/lib/AST/Type.cpp?rev=309135&r1=309134&r2=309135&view=diff
==============================================================================
--- cfe/branches/release_50/lib/AST/Type.cpp (original)
+++ cfe/branches/release_50/lib/AST/Type.cpp Wed Jul 26 09:35:53 2017
@@ -2313,6 +2313,15 @@ bool Type::isAlignValT() const {
return false;
}
+bool Type::isStdByteType() const {
+ if (auto *ET = getAs<EnumType>()) {
+ auto *II = ET->getDecl()->getIdentifier();
+ if (II && II->isStr("byte") && ET->getDecl()->isInStdNamespace())
+ return true;
+ }
+ return false;
+}
+
bool Type::isPromotableIntegerType() const {
if (const BuiltinType *BT = getAs<BuiltinType>())
switch (BT->getKind()) {
Modified: cfe/branches/release_50/lib/CodeGen/CodeGenTBAA.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/lib/CodeGen/CodeGenTBAA.cpp?rev=309135&r1=309134&r2=309135&view=diff
==============================================================================
--- cfe/branches/release_50/lib/CodeGen/CodeGenTBAA.cpp (original)
+++ cfe/branches/release_50/lib/CodeGen/CodeGenTBAA.cpp Wed Jul 26 09:35:53 2017
@@ -139,6 +139,12 @@ CodeGenTBAA::getTBAAInfo(QualType QTy) {
}
}
+ // C++1z [basic.lval]p10: "If a program attempts to access the stored value of
+ // an object through a glvalue of other than one of the following types the
+ // behavior is undefined: [...] a char, unsigned char, or std::byte type."
+ if (Ty->isStdByteType())
+ return MetadataCache[Ty] = getChar();
+
// Handle pointers.
// TODO: Implement C++'s type "similarity" and consider dis-"similar"
// pointers distinct.
More information about the llvm-branch-commits
mailing list