diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2017-07-25 23:33:58 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2017-07-25 23:33:58 +0000 |
| commit | 8f94a2350538f7fa7504f2f963760230dd197cab (patch) | |
| tree | 91af9f94a6a42f18fedfe34e169254a54ced585b /clang/lib/CodeGen/CodeGenTBAA.cpp | |
| parent | be66271f04c8a2c7911a549bfd961a47a8d5e12d (diff) | |
| download | bcm5719-llvm-8f94a2350538f7fa7504f2f963760230dd197cab.tar.gz bcm5719-llvm-8f94a2350538f7fa7504f2f963760230dd197cab.zip | |
[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
llvm-svn: 309058
Diffstat (limited to 'clang/lib/CodeGen/CodeGenTBAA.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CodeGenTBAA.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenTBAA.cpp b/clang/lib/CodeGen/CodeGenTBAA.cpp index 04224e72679..8a75a552d9f 100644 --- a/clang/lib/CodeGen/CodeGenTBAA.cpp +++ b/clang/lib/CodeGen/CodeGenTBAA.cpp @@ -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. |

