[llvm-branch-commits] [cfe-branch] r324213 - Merging r324134:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Feb 5 00:56:25 PST 2018
Author: hans
Date: Mon Feb 5 00:56:25 2018
New Revision: 324213
URL: http://llvm.org/viewvc/llvm-project?rev=324213&view=rev
Log:
Merging r324134:
------------------------------------------------------------------------
r324134 | ericwf | 2018-02-02 21:30:39 +0100 (Fri, 02 Feb 2018) | 14 lines
Make __has_unique_object_representations reject empty union types.
Summary:
Clang incorrectly reports empty unions as having a unique object representation. However, this is not correct since `sizeof(EmptyUnion) == 1` AKA it has 8 bits of padding. Therefore it should be treated the same as an empty struct and report `false`.
@erichkeane also suggested this fix should be merged into the 6.0 release branch, so the initial release of `__has_unique_object_representations` is as bug-free as possible.
Reviewers: erichkeane, rsmith, aaron.ballman, majnemer
Reviewed By: erichkeane
Subscribers: cfe-commits, erichkeane
Differential Revision: https://reviews.llvm.org/D42863
------------------------------------------------------------------------
Modified:
cfe/branches/release_60/ (props changed)
cfe/branches/release_60/lib/AST/ASTContext.cpp
cfe/branches/release_60/test/SemaCXX/type-traits.cpp
Propchange: cfe/branches/release_60/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Feb 5 00:56:25 2018
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:321754,321771,321777,321779,321933,322018,322236,322245-322246,322350,322390,322405,322420,322518,322593,322813,322901,322904,322984,323008,323123,323155,323360,323485
+/cfe/trunk:321754,321771,321777,321779,321933,322018,322236,322245-322246,322350,322390,322405,322420,322518,322593,322813,322901,322904,322984,323008,323123,323155,323360,323485,324134
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_60/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_60/lib/AST/ASTContext.cpp?rev=324213&r1=324212&r2=324213&view=diff
==============================================================================
--- cfe/branches/release_60/lib/AST/ASTContext.cpp (original)
+++ cfe/branches/release_60/lib/AST/ASTContext.cpp Mon Feb 5 00:56:25 2018
@@ -2145,7 +2145,7 @@ static bool unionHasUniqueObjectRepresen
if (FieldSize != UnionSize)
return false;
}
- return true;
+ return !RD->field_empty();
}
static bool isStructEmpty(QualType Ty) {
Modified: cfe/branches/release_60/test/SemaCXX/type-traits.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_60/test/SemaCXX/type-traits.cpp?rev=324213&r1=324212&r2=324213&view=diff
==============================================================================
--- cfe/branches/release_60/test/SemaCXX/type-traits.cpp (original)
+++ cfe/branches/release_60/test/SemaCXX/type-traits.cpp Mon Feb 5 00:56:25 2018
@@ -2524,6 +2524,7 @@ static_assert(!has_unique_object_represe
static_assert(!has_unique_object_representations<volatile int &>::value, "No references!");
static_assert(!has_unique_object_representations<const volatile int &>::value, "No references!");
static_assert(!has_unique_object_representations<Empty>::value, "No empty types!");
+static_assert(!has_unique_object_representations<EmptyUnion>::value, "No empty types!");
class Compressed : Empty {
int x;
More information about the llvm-branch-commits
mailing list