[PATCH] D42863: Make __has_unique_object_representations reject empty union types.

2018-02-02 Thread Eric Fiselier via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL324134: Make __has_unique_object_representations reject 
empty union types. (authored by EricWF, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42863?vs=132651=132656#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42863

Files:
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/test/SemaCXX/type-traits.cpp


Index: cfe/trunk/test/SemaCXX/type-traits.cpp
===
--- cfe/trunk/test/SemaCXX/type-traits.cpp
+++ cfe/trunk/test/SemaCXX/type-traits.cpp
@@ -2566,6 +2566,7 @@
 static_assert(!has_unique_object_representations::value, "No 
references!");
 static_assert(!has_unique_object_representations::value, 
"No references!");
 static_assert(!has_unique_object_representations::value, "No empty 
types!");
+static_assert(!has_unique_object_representations::value, "No empty 
types!");
 
 class Compressed : Empty {
   int x;
Index: cfe/trunk/lib/AST/ASTContext.cpp
===
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -2145,7 +2145,7 @@
 if (FieldSize != UnionSize)
   return false;
   }
-  return true;
+  return !RD->field_empty();
 }
 
 static bool isStructEmpty(QualType Ty) {


Index: cfe/trunk/test/SemaCXX/type-traits.cpp
===
--- cfe/trunk/test/SemaCXX/type-traits.cpp
+++ cfe/trunk/test/SemaCXX/type-traits.cpp
@@ -2566,6 +2566,7 @@
 static_assert(!has_unique_object_representations::value, "No references!");
 static_assert(!has_unique_object_representations::value, "No references!");
 static_assert(!has_unique_object_representations::value, "No empty types!");
+static_assert(!has_unique_object_representations::value, "No empty types!");
 
 class Compressed : Empty {
   int x;
Index: cfe/trunk/lib/AST/ASTContext.cpp
===
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -2145,7 +2145,7 @@
 if (FieldSize != UnionSize)
   return false;
   }
-  return true;
+  return !RD->field_empty();
 }
 
 static bool isStructEmpty(QualType Ty) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42863: Make __has_unique_object_representations reject empty union types.

2018-02-02 Thread Eric Fiselier via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC324134: Make __has_unique_object_representations reject 
empty union types. (authored by EricWF, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D42863

Files:
  lib/AST/ASTContext.cpp
  test/SemaCXX/type-traits.cpp


Index: test/SemaCXX/type-traits.cpp
===
--- test/SemaCXX/type-traits.cpp
+++ test/SemaCXX/type-traits.cpp
@@ -2566,6 +2566,7 @@
 static_assert(!has_unique_object_representations::value, "No 
references!");
 static_assert(!has_unique_object_representations::value, 
"No references!");
 static_assert(!has_unique_object_representations::value, "No empty 
types!");
+static_assert(!has_unique_object_representations::value, "No empty 
types!");
 
 class Compressed : Empty {
   int x;
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -2145,7 +2145,7 @@
 if (FieldSize != UnionSize)
   return false;
   }
-  return true;
+  return !RD->field_empty();
 }
 
 static bool isStructEmpty(QualType Ty) {


Index: test/SemaCXX/type-traits.cpp
===
--- test/SemaCXX/type-traits.cpp
+++ test/SemaCXX/type-traits.cpp
@@ -2566,6 +2566,7 @@
 static_assert(!has_unique_object_representations::value, "No references!");
 static_assert(!has_unique_object_representations::value, "No references!");
 static_assert(!has_unique_object_representations::value, "No empty types!");
+static_assert(!has_unique_object_representations::value, "No empty types!");
 
 class Compressed : Empty {
   int x;
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -2145,7 +2145,7 @@
 if (FieldSize != UnionSize)
   return false;
   }
-  return true;
+  return !RD->field_empty();
 }
 
 static bool isStructEmpty(QualType Ty) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42863: Make __has_unique_object_representations reject empty union types.

2018-02-02 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

Yep, LGTM, thanks!


https://reviews.llvm.org/D42863



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42863: Make __has_unique_object_representations reject empty union types.

2018-02-02 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.
EricWF added reviewers: erichkeane, rsmith, aaron.ballman, majnemer.

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.


https://reviews.llvm.org/D42863

Files:
  lib/AST/ASTContext.cpp
  test/SemaCXX/type-traits.cpp


Index: test/SemaCXX/type-traits.cpp
===
--- test/SemaCXX/type-traits.cpp
+++ test/SemaCXX/type-traits.cpp
@@ -2566,6 +2566,7 @@
 static_assert(!has_unique_object_representations::value, "No 
references!");
 static_assert(!has_unique_object_representations::value, 
"No references!");
 static_assert(!has_unique_object_representations::value, "No empty 
types!");
+static_assert(!has_unique_object_representations::value, "No empty 
types!");
 
 class Compressed : Empty {
   int x;
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -2145,7 +2145,7 @@
 if (FieldSize != UnionSize)
   return false;
   }
-  return true;
+  return !RD->field_empty();
 }
 
 static bool isStructEmpty(QualType Ty) {


Index: test/SemaCXX/type-traits.cpp
===
--- test/SemaCXX/type-traits.cpp
+++ test/SemaCXX/type-traits.cpp
@@ -2566,6 +2566,7 @@
 static_assert(!has_unique_object_representations::value, "No references!");
 static_assert(!has_unique_object_representations::value, "No references!");
 static_assert(!has_unique_object_representations::value, "No empty types!");
+static_assert(!has_unique_object_representations::value, "No empty types!");
 
 class Compressed : Empty {
   int x;
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -2145,7 +2145,7 @@
 if (FieldSize != UnionSize)
   return false;
   }
-  return true;
+  return !RD->field_empty();
 }
 
 static bool isStructEmpty(QualType Ty) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits