[PATCH] D129799: [clang-tidy] Add CLANG_TIDY_CONFUSABLE_CHARS_GEN cmake setting to avoid building when cross compiling

2022-07-30 Thread cqwrteur via Phabricator via cfe-commits
trcrsired added a comment.

Hi i have a question. Does llvm provide a general toggle to set all those 
things with a directory? It becomes unmanagable since the end of llvm 15.

like LLVM_NATIVE_TOOL_DIR some thing like that?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129799/new/

https://reviews.llvm.org/D129799

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


[PATCH] D117888: [clang][driver][wasm] Support -stdlib=libstdc++ for WebAssembly

2022-02-04 Thread cqwrteur via Phabricator via cfe-commits
expnkx reopened this revision.
expnkx added a comment.
This revision is now accepted and ready to land.

This patch is simply wrong.

cqwrteur@Home-Server:~/fast_io_cleanup/fast_io/examples/0001.helloworld$ 
clang++ -o helloworld helloworld.cc -Ofast -std=c++2b -s -flto -fuse-ld=lld 
--target=wasm32-wasi --sysroot=$HOME/toolchains/sysroot/wasm32-wasi 
-fno-exceptions -fno-rtti -fno-unwind-tables -fno-asynchronous-unwind-tables 
-I../../include -stdlib=libstdc++
In file included from helloworld.cc:1:
In file included from ../../include/fast_io.h:9:
In file included from ../../include/fast_io_hosted.h:17:
In file included from ../../include/fast_io_freestanding.h:12:
In file included from ../../include/fast_io_core.h:11:
In file included from ../../include/fast_io_concept.h:20:
In file included from 
/home/cqwrteur/toolchains/sysroot/wasm32-wasi/include/c++/12.0.1/concepts:44:
/home/cqwrteur/toolchains/sysroot/wasm32-wasi/include/c++/12.0.1/type_traits:38:10:
 fatal error: 'bits/c++config.h' file not found
#include 

  ^~

1 error generated.

It cannot find bits/c++config.h

wasm32-wasi\include\c++\12.0.1\wasm32-wasi\bits


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117888/new/

https://reviews.llvm.org/D117888

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


[PATCH] D110485: Support [[no_unique_address]] for all targets.

2021-09-27 Thread cqwrteur via Phabricator via cfe-commits
expnkx updated this revision to Diff 375431.
expnkx added a comment.

do not know why it cannot be built. upload and then verify again


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110485/new/

https://reviews.llvm.org/D110485

Files:
  clang/include/clang/Basic/Attr.td
  clang/test/SemaCXX/cxx2a-no-unique-address.cpp


Index: clang/test/SemaCXX/cxx2a-no-unique-address.cpp
===
--- clang/test/SemaCXX/cxx2a-no-unique-address.cpp
+++ clang/test/SemaCXX/cxx2a-no-unique-address.cpp
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -std=c++2a %s -verify -triple x86_64-linux-gnu
-// RUN: %clang_cc1 -std=c++2a %s -verify=unsupported -triple x86_64-windows
 
 [[no_unique_address]] int a; // expected-error {{only applies to non-bit-field 
non-static data members}} unsupported-warning {{unknown}}
 [[no_unique_address]] void f(); // expected-error {{only applies to 
non-bit-field non-static data members}} unsupported-warning {{unknown}}
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -1686,7 +1686,7 @@
   let Documentation = [ArmMveStrictPolymorphismDocs];
 }
 
-def NoUniqueAddress : InheritableAttr, TargetSpecificAttr 
{
+def NoUniqueAddress : InheritableAttr {
   let Spellings = [CXX11<"", "no_unique_address", 201803>];
   let Subjects = SubjectList<[NonBitField], ErrorDiag>;
   let Documentation = [NoUniqueAddressDocs];


Index: clang/test/SemaCXX/cxx2a-no-unique-address.cpp
===
--- clang/test/SemaCXX/cxx2a-no-unique-address.cpp
+++ clang/test/SemaCXX/cxx2a-no-unique-address.cpp
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -std=c++2a %s -verify -triple x86_64-linux-gnu
-// RUN: %clang_cc1 -std=c++2a %s -verify=unsupported -triple x86_64-windows
 
 [[no_unique_address]] int a; // expected-error {{only applies to non-bit-field non-static data members}} unsupported-warning {{unknown}}
 [[no_unique_address]] void f(); // expected-error {{only applies to non-bit-field non-static data members}} unsupported-warning {{unknown}}
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -1686,7 +1686,7 @@
   let Documentation = [ArmMveStrictPolymorphismDocs];
 }
 
-def NoUniqueAddress : InheritableAttr, TargetSpecificAttr {
+def NoUniqueAddress : InheritableAttr {
   let Spellings = [CXX11<"", "no_unique_address", 201803>];
   let Subjects = SubjectList<[NonBitField], ErrorDiag>;
   let Documentation = [NoUniqueAddressDocs];
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110485: Support [[no_unique_address]] for all targets.

2021-09-27 Thread cqwrteur via Phabricator via cfe-commits
expnkx added a comment.

ninja: error: unknown target 'check-libc', did you mean 'check-lit'?

what's wrong with this?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110485/new/

https://reviews.llvm.org/D110485

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


[PATCH] D110485: Support [[no_unique_address]] for all targets.

2021-09-27 Thread cqwrteur via Phabricator via cfe-commits
expnkx updated this revision to Diff 375461.
expnkx added a comment.

I just find that Preprocessor test has a windows (msvc not gnu) specific test 
that tests no_unique_address.

add that to patch and see whether it is mergable.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110485/new/

https://reviews.llvm.org/D110485

Files:
  clang/include/clang/Basic/Attr.td
  clang/test/Preprocessor/has_attribute.cpp
  clang/test/SemaCXX/cxx2a-no-unique-address.cpp


Index: clang/test/SemaCXX/cxx2a-no-unique-address.cpp
===
--- clang/test/SemaCXX/cxx2a-no-unique-address.cpp
+++ clang/test/SemaCXX/cxx2a-no-unique-address.cpp
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -std=c++2a %s -verify -triple x86_64-linux-gnu
-// RUN: %clang_cc1 -std=c++2a %s -verify=unsupported -triple x86_64-windows
 
 [[no_unique_address]] int a; // expected-error {{only applies to non-bit-field 
non-static data members}} unsupported-warning {{unknown}}
 [[no_unique_address]] void f(); // expected-error {{only applies to 
non-bit-field non-static data members}} unsupported-warning {{unknown}}
Index: clang/test/Preprocessor/has_attribute.cpp
===
--- clang/test/Preprocessor/has_attribute.cpp
+++ clang/test/Preprocessor/has_attribute.cpp
@@ -64,8 +64,7 @@
 // CHECK: fallthrough: 201603L
 // CHECK: likely: 201803L
 // CHECK: maybe_unused: 201603L
-// ITANIUM: no_unique_address: 201803L
-// WINDOWS: no_unique_address: 0
+// CHECK: no_unique_address: 201803L
 // CHECK: nodiscard: 201907L
 // CHECK: noreturn: 200809L
 // CHECK: unlikely: 201803L
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -1686,7 +1686,7 @@
   let Documentation = [ArmMveStrictPolymorphismDocs];
 }
 
-def NoUniqueAddress : InheritableAttr, TargetSpecificAttr 
{
+def NoUniqueAddress : InheritableAttr {
   let Spellings = [CXX11<"", "no_unique_address", 201803>];
   let Subjects = SubjectList<[NonBitField], ErrorDiag>;
   let Documentation = [NoUniqueAddressDocs];


Index: clang/test/SemaCXX/cxx2a-no-unique-address.cpp
===
--- clang/test/SemaCXX/cxx2a-no-unique-address.cpp
+++ clang/test/SemaCXX/cxx2a-no-unique-address.cpp
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -std=c++2a %s -verify -triple x86_64-linux-gnu
-// RUN: %clang_cc1 -std=c++2a %s -verify=unsupported -triple x86_64-windows
 
 [[no_unique_address]] int a; // expected-error {{only applies to non-bit-field non-static data members}} unsupported-warning {{unknown}}
 [[no_unique_address]] void f(); // expected-error {{only applies to non-bit-field non-static data members}} unsupported-warning {{unknown}}
Index: clang/test/Preprocessor/has_attribute.cpp
===
--- clang/test/Preprocessor/has_attribute.cpp
+++ clang/test/Preprocessor/has_attribute.cpp
@@ -64,8 +64,7 @@
 // CHECK: fallthrough: 201603L
 // CHECK: likely: 201803L
 // CHECK: maybe_unused: 201603L
-// ITANIUM: no_unique_address: 201803L
-// WINDOWS: no_unique_address: 0
+// CHECK: no_unique_address: 201803L
 // CHECK: nodiscard: 201907L
 // CHECK: noreturn: 200809L
 // CHECK: unlikely: 201803L
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -1686,7 +1686,7 @@
   let Documentation = [ArmMveStrictPolymorphismDocs];
 }
 
-def NoUniqueAddress : InheritableAttr, TargetSpecificAttr {
+def NoUniqueAddress : InheritableAttr {
   let Spellings = [CXX11<"", "no_unique_address", 201803>];
   let Subjects = SubjectList<[NonBitField], ErrorDiag>;
   let Documentation = [NoUniqueAddressDocs];
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110485: Support [[no_unique_address]] for all targets.

2021-09-27 Thread cqwrteur via Phabricator via cfe-commits
expnkx updated this revision to Diff 375466.
expnkx added a comment.

itanium + microsoft test both


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110485/new/

https://reviews.llvm.org/D110485

Files:
  clang/include/clang/Basic/Attr.td
  clang/test/SemaCXX/cxx2a-no-unique-address.cpp


Index: clang/test/SemaCXX/cxx2a-no-unique-address.cpp
===
--- clang/test/SemaCXX/cxx2a-no-unique-address.cpp
+++ clang/test/SemaCXX/cxx2a-no-unique-address.cpp
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -std=c++2a %s -verify -triple x86_64-linux-gnu
-// RUN: %clang_cc1 -std=c++2a %s -verify=unsupported -triple x86_64-windows
 
 [[no_unique_address]] int a; // expected-error {{only applies to non-bit-field 
non-static data members}} unsupported-warning {{unknown}}
 [[no_unique_address]] void f(); // expected-error {{only applies to 
non-bit-field non-static data members}} unsupported-warning {{unknown}}
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -1686,7 +1686,7 @@
   let Documentation = [ArmMveStrictPolymorphismDocs];
 }
 
-def NoUniqueAddress : InheritableAttr, TargetSpecificAttr 
{
+def NoUniqueAddress : InheritableAttr {
   let Spellings = [CXX11<"", "no_unique_address", 201803>];
   let Subjects = SubjectList<[NonBitField], ErrorDiag>;
   let Documentation = [NoUniqueAddressDocs];


Index: clang/test/SemaCXX/cxx2a-no-unique-address.cpp
===
--- clang/test/SemaCXX/cxx2a-no-unique-address.cpp
+++ clang/test/SemaCXX/cxx2a-no-unique-address.cpp
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -std=c++2a %s -verify -triple x86_64-linux-gnu
-// RUN: %clang_cc1 -std=c++2a %s -verify=unsupported -triple x86_64-windows
 
 [[no_unique_address]] int a; // expected-error {{only applies to non-bit-field non-static data members}} unsupported-warning {{unknown}}
 [[no_unique_address]] void f(); // expected-error {{only applies to non-bit-field non-static data members}} unsupported-warning {{unknown}}
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -1686,7 +1686,7 @@
   let Documentation = [ArmMveStrictPolymorphismDocs];
 }
 
-def NoUniqueAddress : InheritableAttr, TargetSpecificAttr {
+def NoUniqueAddress : InheritableAttr {
   let Spellings = [CXX11<"", "no_unique_address", 201803>];
   let Subjects = SubjectList<[NonBitField], ErrorDiag>;
   let Documentation = [NoUniqueAddressDocs];
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110485: Support [[no_unique_address]] for all targets.

2021-09-27 Thread cqwrteur via Phabricator via cfe-commits
expnkx added a comment.

In D110485#3026533 , @rjmccall wrote:

> We should not add a standard feature with ABI impact if we aren't certain 
> we're going to match MSVC's ABI on it.  I'm sorry, but this needs to wait 
> until there's an MSVC release that officially supports this.

but how are you going to deal with [[msvc::no_unique_address]] that works?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110485/new/

https://reviews.llvm.org/D110485

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


[PATCH] D110485: Support [[no_unique_address]] for all targets.

2021-09-27 Thread cqwrteur via Phabricator via cfe-commits
expnkx added a comment.

In D110485#3026533 , @rjmccall wrote:

> We should not add a standard feature with ABI impact if we aren't certain 
> we're going to match MSVC's ABI on it.  I'm sorry, but this needs to wait 
> until there's an MSVC release that officially supports this.

You are not actually matching msvc abi's layout because msvc supports 
[[msvc::no_unique_address]]. That is an MSVC release that officially supports.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110485/new/

https://reviews.llvm.org/D110485

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


[PATCH] D110485: Support [[no_unique_address]] for all targets.

2021-09-27 Thread cqwrteur via Phabricator via cfe-commits
expnkx updated this revision to Diff 375468.
expnkx added a comment.

should be diff3


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110485/new/

https://reviews.llvm.org/D110485

Files:
  clang/include/clang/Basic/Attr.td
  clang/test/Preprocessor/has_attribute.cpp
  clang/test/SemaCXX/cxx2a-no-unique-address.cpp


Index: clang/test/SemaCXX/cxx2a-no-unique-address.cpp
===
--- clang/test/SemaCXX/cxx2a-no-unique-address.cpp
+++ clang/test/SemaCXX/cxx2a-no-unique-address.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -std=c++2a %s -verify -triple x86_64-linux-gnu
-// RUN: %clang_cc1 -std=c++2a %s -verify=unsupported -triple x86_64-windows
+// RUN: %clang_cc1 -std=c++2a %s -verify -triple x86_64-windows
 
 [[no_unique_address]] int a; // expected-error {{only applies to non-bit-field 
non-static data members}} unsupported-warning {{unknown}}
 [[no_unique_address]] void f(); // expected-error {{only applies to 
non-bit-field non-static data members}} unsupported-warning {{unknown}}
Index: clang/test/Preprocessor/has_attribute.cpp
===
--- clang/test/Preprocessor/has_attribute.cpp
+++ clang/test/Preprocessor/has_attribute.cpp
@@ -65,7 +65,7 @@
 // CHECK: likely: 201803L
 // CHECK: maybe_unused: 201603L
 // ITANIUM: no_unique_address: 201803L
-// WINDOWS: no_unique_address: 0
+// WINDOWS: no_unique_address: 201803L
 // CHECK: nodiscard: 201907L
 // CHECK: noreturn: 200809L
 // CHECK: unlikely: 201803L
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -1686,7 +1686,7 @@
   let Documentation = [ArmMveStrictPolymorphismDocs];
 }
 
-def NoUniqueAddress : InheritableAttr, TargetSpecificAttr 
{
+def NoUniqueAddress : InheritableAttr {
   let Spellings = [CXX11<"", "no_unique_address", 201803>];
   let Subjects = SubjectList<[NonBitField], ErrorDiag>;
   let Documentation = [NoUniqueAddressDocs];


Index: clang/test/SemaCXX/cxx2a-no-unique-address.cpp
===
--- clang/test/SemaCXX/cxx2a-no-unique-address.cpp
+++ clang/test/SemaCXX/cxx2a-no-unique-address.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -std=c++2a %s -verify -triple x86_64-linux-gnu
-// RUN: %clang_cc1 -std=c++2a %s -verify=unsupported -triple x86_64-windows
+// RUN: %clang_cc1 -std=c++2a %s -verify -triple x86_64-windows
 
 [[no_unique_address]] int a; // expected-error {{only applies to non-bit-field non-static data members}} unsupported-warning {{unknown}}
 [[no_unique_address]] void f(); // expected-error {{only applies to non-bit-field non-static data members}} unsupported-warning {{unknown}}
Index: clang/test/Preprocessor/has_attribute.cpp
===
--- clang/test/Preprocessor/has_attribute.cpp
+++ clang/test/Preprocessor/has_attribute.cpp
@@ -65,7 +65,7 @@
 // CHECK: likely: 201803L
 // CHECK: maybe_unused: 201603L
 // ITANIUM: no_unique_address: 201803L
-// WINDOWS: no_unique_address: 0
+// WINDOWS: no_unique_address: 201803L
 // CHECK: nodiscard: 201907L
 // CHECK: noreturn: 200809L
 // CHECK: unlikely: 201803L
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -1686,7 +1686,7 @@
   let Documentation = [ArmMveStrictPolymorphismDocs];
 }
 
-def NoUniqueAddress : InheritableAttr, TargetSpecificAttr {
+def NoUniqueAddress : InheritableAttr {
   let Spellings = [CXX11<"", "no_unique_address", 201803>];
   let Subjects = SubjectList<[NonBitField], ErrorDiag>;
   let Documentation = [NoUniqueAddressDocs];
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110485: Support [[no_unique_address]] for all targets.

2021-09-28 Thread cqwrteur via Phabricator via cfe-commits
expnkx updated this revision to Diff 375690.
expnkx added a comment.

I cannot find out where to add attribute that starts with msvc::x.

I am just applying this "potential" patch to the clang upstream. In the future 
we can just remove TargetItaniumCXXABI attr in the clang table gen file without 
worrying about too much. So it is a "noop".

So this patch changes nothing but it makes us be convenient to fix it in the 
future.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110485/new/

https://reviews.llvm.org/D110485

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp


Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -2919,6 +2919,10 @@
 layoutBitField(FD);
 return;
   }
+  auto *FieldClass = FD->getType()->getAsCXXRecordDecl();
+  bool PotentiallyOverlapping = FD->hasAttr() && 
FieldClass;
+  bool IsOverlappingEmptyField =
+  PotentiallyOverlapping && FieldClass->isEmpty();
   LastFieldIsNonZeroWidthBitfield = false;
   ElementInfo Info = getAdjustedElementInfo(FD);
   Alignment = std::max(Alignment, Info.Alignment);
@@ -2926,7 +2930,7 @@
   if (UseExternalLayout)
 FieldOffset =
 Context.toCharUnitsFromBits(External.getExternalFieldOffset(FD));
-  else if (IsUnion)
+  else if (IsUnion || IsOverlappingEmptyField)
 FieldOffset = CharUnits::Zero();
   else
 FieldOffset = Size.alignTo(Info.Alignment);


Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -2919,6 +2919,10 @@
 layoutBitField(FD);
 return;
   }
+  auto *FieldClass = FD->getType()->getAsCXXRecordDecl();
+  bool PotentiallyOverlapping = FD->hasAttr() && FieldClass;
+  bool IsOverlappingEmptyField =
+  PotentiallyOverlapping && FieldClass->isEmpty();
   LastFieldIsNonZeroWidthBitfield = false;
   ElementInfo Info = getAdjustedElementInfo(FD);
   Alignment = std::max(Alignment, Info.Alignment);
@@ -2926,7 +2930,7 @@
   if (UseExternalLayout)
 FieldOffset =
 Context.toCharUnitsFromBits(External.getExternalFieldOffset(FD));
-  else if (IsUnion)
+  else if (IsUnion || IsOverlappingEmptyField)
 FieldOffset = CharUnits::Zero();
   else
 FieldOffset = Size.alignTo(Info.Alignment);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110485: Support [[no_unique_address]] for all targets.

2021-09-28 Thread cqwrteur via Phabricator via cfe-commits
expnkx updated this revision to Diff 375720.
expnkx added a comment.

it should first update the field and then test no_unique_address


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110485/new/

https://reviews.llvm.org/D110485

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp


Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -2923,11 +2923,18 @@
   ElementInfo Info = getAdjustedElementInfo(FD);
   Alignment = std::max(Alignment, Info.Alignment);
   CharUnits FieldOffset;
+  auto *FieldClass = FD->getType()->getAsCXXRecordDecl();
+  bool PotentiallyOverlapping =
+  FD->hasAttr() && FieldClass;
+  bool IsOverlappingEmptyField =
+  PotentiallyOverlapping && FieldClass->isEmpty();
   if (UseExternalLayout)
 FieldOffset =
 Context.toCharUnitsFromBits(External.getExternalFieldOffset(FD));
-  else if (IsUnion)
+  else if (IsUnion || IsOverlappingEmptyField)
+  {
 FieldOffset = CharUnits::Zero();
+  }
   else
 FieldOffset = Size.alignTo(Info.Alignment);
   placeFieldAtOffset(FieldOffset);


Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -2923,11 +2923,18 @@
   ElementInfo Info = getAdjustedElementInfo(FD);
   Alignment = std::max(Alignment, Info.Alignment);
   CharUnits FieldOffset;
+  auto *FieldClass = FD->getType()->getAsCXXRecordDecl();
+  bool PotentiallyOverlapping =
+  FD->hasAttr() && FieldClass;
+  bool IsOverlappingEmptyField =
+  PotentiallyOverlapping && FieldClass->isEmpty();
   if (UseExternalLayout)
 FieldOffset =
 Context.toCharUnitsFromBits(External.getExternalFieldOffset(FD));
-  else if (IsUnion)
+  else if (IsUnion || IsOverlappingEmptyField)
+  {
 FieldOffset = CharUnits::Zero();
+  }
   else
 FieldOffset = Size.alignTo(Info.Alignment);
   placeFieldAtOffset(FieldOffset);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110485: Support [[no_unique_address]] for all targets.

2021-09-28 Thread cqwrteur via Phabricator via cfe-commits
expnkx updated this revision to Diff 375758.
expnkx added a comment.

fixing clang format


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110485/new/

https://reviews.llvm.org/D110485

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp


Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -2923,12 +2923,17 @@
   ElementInfo Info = getAdjustedElementInfo(FD);
   Alignment = std::max(Alignment, Info.Alignment);
   CharUnits FieldOffset;
+  auto *FieldClass = FD->getType()->getAsCXXRecordDecl();
+  bool PotentiallyOverlapping =
+  FD->hasAttr() && FieldClass;
+  bool IsOverlappingEmptyField =
+  PotentiallyOverlapping && FieldClass->isEmpty();
   if (UseExternalLayout)
 FieldOffset =
 Context.toCharUnitsFromBits(External.getExternalFieldOffset(FD));
-  else if (IsUnion)
+  else if (IsUnion || IsOverlappingEmptyField) {
 FieldOffset = CharUnits::Zero();
-  else
+  } else
 FieldOffset = Size.alignTo(Info.Alignment);
   placeFieldAtOffset(FieldOffset);
   Size = std::max(Size, FieldOffset + Info.Size);


Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -2923,12 +2923,17 @@
   ElementInfo Info = getAdjustedElementInfo(FD);
   Alignment = std::max(Alignment, Info.Alignment);
   CharUnits FieldOffset;
+  auto *FieldClass = FD->getType()->getAsCXXRecordDecl();
+  bool PotentiallyOverlapping =
+  FD->hasAttr() && FieldClass;
+  bool IsOverlappingEmptyField =
+  PotentiallyOverlapping && FieldClass->isEmpty();
   if (UseExternalLayout)
 FieldOffset =
 Context.toCharUnitsFromBits(External.getExternalFieldOffset(FD));
-  else if (IsUnion)
+  else if (IsUnion || IsOverlappingEmptyField) {
 FieldOffset = CharUnits::Zero();
-  else
+  } else
 FieldOffset = Size.alignTo(Info.Alignment);
   placeFieldAtOffset(FieldOffset);
   Size = std::max(Size, FieldOffset + Info.Size);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110485: Support [[no_unique_address]] for all targets.

2021-09-28 Thread cqwrteur via Phabricator via cfe-commits
expnkx updated this revision to Diff 375775.
expnkx added a comment.

clang format + clang tidy

all clang tests pass locally.

flang is bugged. Do not know why flang cannot find llvm-jxx


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110485/new/

https://reviews.llvm.org/D110485

Files:
  clang/include/clang/Basic/Attr.td
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/Preprocessor/has_attribute.cpp
  clang/test/SemaCXX/cxx2a-no-unique-address.cpp

Index: clang/test/SemaCXX/cxx2a-no-unique-address.cpp
===
--- clang/test/SemaCXX/cxx2a-no-unique-address.cpp
+++ clang/test/SemaCXX/cxx2a-no-unique-address.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -std=c++2a %s -verify -triple x86_64-linux-gnu
-// RUN: %clang_cc1 -std=c++2a %s -verify=unsupported -triple x86_64-windows
+// RUN: %clang_cc1 -std=c++2a %s -verify -triple x86_64-windows
+// RUN: %clang_cc1 -std=c++2a %s -verify -triple x86_64-windows-gnu
 
 [[no_unique_address]] int a; // expected-error {{only applies to non-bit-field non-static data members}} unsupported-warning {{unknown}}
 [[no_unique_address]] void f(); // expected-error {{only applies to non-bit-field non-static data members}} unsupported-warning {{unknown}}
Index: clang/test/Preprocessor/has_attribute.cpp
===
--- clang/test/Preprocessor/has_attribute.cpp
+++ clang/test/Preprocessor/has_attribute.cpp
@@ -65,7 +65,7 @@
 // CHECK: likely: 201803L
 // CHECK: maybe_unused: 201603L
 // ITANIUM: no_unique_address: 201803L
-// WINDOWS: no_unique_address: 0
+// WINDOWS: no_unique_address: 201803L
 // CHECK: nodiscard: 201907L
 // CHECK: noreturn: 200809L
 // CHECK: unlikely: 201803L
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -14,8 +14,8 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/Expr.h"
-#include "clang/AST/VTableBuilder.h"
 #include "clang/AST/RecordLayout.h"
+#include "clang/AST/VTableBuilder.h"
 #include "clang/Basic/TargetInfo.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/Support/Format.h"
@@ -44,7 +44,7 @@
   bool IsVirtual;
 
   /// Bases - Information about the base subobjects.
-  SmallVector Bases;
+  SmallVector Bases;
 
   /// PrimaryVirtualBaseInfo - Holds the base info for the primary virtual base
   /// of this base info (if one exists).
@@ -78,8 +78,7 @@
   /// Get the offset of the given field. The external source must provide
   /// entries for all fields in the record.
   uint64_t getExternalFieldOffset(const FieldDecl *FD) {
-assert(FieldOffsets.count(FD) &&
-   "Field does not have an external offset");
+assert(FieldOffsets.count(FD) && "Field does not have an external offset");
 return FieldOffsets[FD];
   }
 
@@ -139,8 +138,8 @@
 return Offset <= MaxEmptyClassOffset;
   }
 
-  CharUnits
-  getFieldOffset(const ASTRecordLayout &Layout, unsigned FieldNo) const {
+  CharUnits getFieldOffset(const ASTRecordLayout &Layout,
+   unsigned FieldNo) const {
 uint64_t FieldOffset = Layout.getFieldOffset(FieldNo);
 assert(FieldOffset % CharWidth == 0 &&
"Field offset not at char boundary!");
@@ -168,16 +167,15 @@
   CharUnits SizeOfLargestEmptySubobject;
 
   EmptySubobjectMap(const ASTContext &Context, const CXXRecordDecl *Class)
-  : Context(Context), CharWidth(Context.getCharWidth()), Class(Class) {
-  ComputeEmptySubobjectSizes();
+  : Context(Context), CharWidth(Context.getCharWidth()), Class(Class) {
+ComputeEmptySubobjectSizes();
   }
 
   /// CanPlaceBaseAtOffset - Return whether the given base class can be placed
   /// at the given offset.
   /// Returns false if placing the record will result in two components
   /// (direct or indirect) of the same type having the same offset.
-  bool CanPlaceBaseAtOffset(const BaseSubobjectInfo *Info,
-CharUnits Offset);
+  bool CanPlaceBaseAtOffset(const BaseSubobjectInfo *Info, CharUnits Offset);
 
   /// CanPlaceFieldAtOffset - Return whether a field can be placed at the given
   /// offset.
@@ -228,9 +226,8 @@
   }
 }
 
-bool
-EmptySubobjectMap::CanPlaceSubobjectAtOffset(const CXXRecordDecl *RD,
- CharUnits Offset) const {
+bool EmptySubobjectMap::CanPlaceSubobjectAtOffset(const CXXRecordDecl *RD,
+  CharUnits Offset) const {
   // We only need to check empty bases.
   if (!RD->isEmpty())
 return true;
@@ -266,9 +263,8 @@
 MaxEmptyClassOffset = Offset;
 }
 
-bool
-EmptySubobjectMap::CanPlaceBaseSubobjectAtOffset(const BaseSubobjectInfo *Info,
- CharUnits Offset) {
+bool EmptySubobjectMap::CanPlaceBaseSubobjectAtOffset(
+const BaseSubobjectInfo *

[PATCH] D110485: Support [[no_unique_address]] for all targets.

2021-09-29 Thread cqwrteur via Phabricator via cfe-commits
expnkx added a comment.

clang simply just does not truly support everything msvc supports. There are no 
things that deals [[msvc::]] attributes at all in the clang. In fact the point 
of using clang on windows is that we do not want to do the same as Microsoft 
does.

Support [[no_unique_address]] is nothing wrong tbh and that is what ISO C++ 
standard requires.

If we do not change, the Microsoft team won't wanna change either because they 
are afraid of breaking clang too.

I never understand why [[no_unique_address]] is a problem.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110485/new/

https://reviews.llvm.org/D110485

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


[PATCH] D110485: Support [[no_unique_address]] for all targets.

2021-09-30 Thread cqwrteur via Phabricator via cfe-commits
expnkx added a comment.

In D110485#3030874 , @erichkeane 
wrote:

> In D110485#3030853 , @expnkx wrote:
>
>> clang simply just does not truly support everything msvc supports. There are 
>> no things that deals [[msvc::]] attributes at all in the clang. In fact the 
>> point of using clang on windows is that we do not want to do the same as 
>> Microsoft does.
>>
>> Support [[no_unique_address]] is nothing wrong tbh and that is what ISO C++ 
>> standard requires.
>>
>> If we do not change, the Microsoft team won't wanna change either because 
>> they are afraid of breaking clang too.
>>
>> I never understand why [[no_unique_address]] is a problem.
>
> A requirement of Clang on Windows is that we are ABI compatible (so that we 
> can link between them!), the same way that Linux must match the Itanium ABI.  
> Allowing no_unique_address on Windows is an ABI compatibility issue.  In this 
> case, we have to pay attention to what the platform's ABI OWNERS define as 
> the ABI, which in this case is Microsoft.
>
> THAT is why this is a problem, and THAT is what is wrong with this change.
>
> If Microsoft defines an ABI for what this does, we can follow them and just 
> do that.

https://github.com/microsoft/STL/issues/1364

As Microsoft said, the reason why things like msvc::no_unique_address exist are 
because clang does not support it. In fact, it has become a vicious cycle. msvc 
waits clang, clang waits msvc.

It is a vicious cycle. I would argue it is LLVM's fault, not Microsoft's fault.

Sure you can add another attribute, i tried that, but adding another attribute 
for doing exactly the same thing through entire code base is just annoying and 
headache.

If clang does not support [[no_unique_address]], Microsoft is not going to 
support it either. Microsoft's own words.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110485/new/

https://reviews.llvm.org/D110485

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