[PATCH] D46805: If some platforms do not support an attribute, we should exclude the platform

2018-06-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from a nit with one of the tests. Once you've updated the patch and 
verified that check-clang passes all tests, I can commit for you next week when 
I'm back from meetings (unless someone else gets to it before me).




Comment at: include/clang/Basic/Attr.td:322
+def TargetSupportsAlias : TargetSpec {
+  let ObjectFormats = ["COFF", "ELF", "Wasm"];
+}

HLJ2009 wrote:
> aaron.ballman wrote:
> > Did you verify that Wasm supports the alias attribute? If it is supported, 
> > it might be nice to add a test to `CodeGen/alias.c` to demonstrate it. 
> > Similar for COFF.
> Yes, I used the following command line to test my test file.
> clang -cc1 -triple wasm32-unknown-unknown -fsyntax-only -verify 
> attr-alias-has.c
> clang -cc1 -triple wasm64-unknown-unknown -fsyntax-only -verify 
> attr-alias-has.c
> The test result is ok. 
> ok, I will update it.
That's perhaps not the "support" I was talking about. I didn't mean "are you 
sure the target spec on the attribute is doing what you expect", but "are you 
sure that alias works and has the expected semantics when the target is Wasm"?

However, @sunfish already said it's intended to be supported in Wasm, so I 
think that's fine.



Comment at: include/clang/Basic/Attr.td:564
   let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>;
   let Documentation = [Undocumented];
 }

Now that we're touching this attribute so that it no longer is available on 
some targets, it would be good to consider adding documentation for the 
attribute. That documentation isn't your responsibility and doesn't need to be 
part of this patch, but if it was something you wanted to tackle in a 
follow-up, that'd be appreciated (but not required).



Comment at: test/Sema/attr-alias-has.c:13
+#endif
\ No newline at end of file


Please add a newline to the end of the file.


Repository:
  rC Clang

https://reviews.llvm.org/D46805



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


[PATCH] D46805: If some platforms do not support an attribute, we should exclude the platform

2018-06-03 Thread Li Jia He via Phabricator via cfe-commits
HLJ2009 updated this revision to Diff 149665.
HLJ2009 added a comment.

update test case.


Repository:
  rC Clang

https://reviews.llvm.org/D46805

Files:
  include/clang/Basic/Attr.td
  test/Sema/attr-alias-has.c
  test/Sema/attr-alias.c


Index: test/Sema/attr-alias.c
===
--- test/Sema/attr-alias.c
+++ test/Sema/attr-alias.c
@@ -2,4 +2,4 @@
 
 void g() {}
 
-void f() __attribute__((alias("g"))); //expected-error {{aliases are not 
supported on darwin}}
+void f() __attribute__((alias("g"))); //expected-warning {{unknown attribute 
'alias' ignored}}
Index: test/Sema/attr-alias-has.c
===
--- /dev/null
+++ test/Sema/attr-alias-has.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple wasm64-unknown-unknown -fsyntax-only -verify %s
+
+void g() {}
+#if !__has_attribute(alias) 
+void f() __attribute__((alias("g"))); // expected-warning {{unknown attribute 
'alias' ignored}}
+#else
+void f() __attribute__((alias("g"))); // expected-no-diagnostics
+#endif
\ No newline at end of file
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -318,6 +318,9 @@
 def TargetELF : TargetSpec {
   let ObjectFormats = ["ELF"];
 }
+def TargetSupportsAlias : TargetSpec {
+  let ObjectFormats = ["COFF", "ELF", "Wasm"];
+}
 
 // Attribute subject match rules that are used for #pragma clang attribute.
 //
@@ -554,7 +557,7 @@
   let Documentation = [Undocumented];
 }
 
-def Alias : Attr {
+def Alias : Attr, TargetSpecificAttr {
   let Spellings = [GCC<"alias">];
   let Args = [StringArgument<"Aliasee">];
   let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>;


Index: test/Sema/attr-alias.c
===
--- test/Sema/attr-alias.c
+++ test/Sema/attr-alias.c
@@ -2,4 +2,4 @@
 
 void g() {}
 
-void f() __attribute__((alias("g"))); //expected-error {{aliases are not supported on darwin}}
+void f() __attribute__((alias("g"))); //expected-warning {{unknown attribute 'alias' ignored}}
Index: test/Sema/attr-alias-has.c
===
--- /dev/null
+++ test/Sema/attr-alias-has.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple wasm64-unknown-unknown -fsyntax-only -verify %s
+
+void g() {}
+#if !__has_attribute(alias) 
+void f() __attribute__((alias("g"))); // expected-warning {{unknown attribute 'alias' ignored}}
+#else
+void f() __attribute__((alias("g"))); // expected-no-diagnostics
+#endif
\ No newline at end of file
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -318,6 +318,9 @@
 def TargetELF : TargetSpec {
   let ObjectFormats = ["ELF"];
 }
+def TargetSupportsAlias : TargetSpec {
+  let ObjectFormats = ["COFF", "ELF", "Wasm"];
+}
 
 // Attribute subject match rules that are used for #pragma clang attribute.
 //
@@ -554,7 +557,7 @@
   let Documentation = [Undocumented];
 }
 
-def Alias : Attr {
+def Alias : Attr, TargetSpecificAttr {
   let Spellings = [GCC<"alias">];
   let Args = [StringArgument<"Aliasee">];
   let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46805: If some platforms do not support an attribute, we should exclude the platform

2018-06-02 Thread Li Jia He via Phabricator via cfe-commits
HLJ2009 added a comment.

In https://reviews.llvm.org/D46805#1117091, @sunfish wrote:

> In https://reviews.llvm.org/D46805#1115681, @rsmith wrote:
>
> > In https://reviews.llvm.org/D46805#1113358, @aaron.ballman wrote:
> >
> > > @rsmith -- do the object file formats listed look correct to you?
> >
> >
> > They look at least plausible. We should be able to test whether LLVM can 
> > actually emit aliases on each of these targets easily enough...
> >
> > However, I get this error for any WAsm compilation I try:
> >
> >   fatal error: error in backend: section size does not fit in a uint32_t
> >
> > ... so I have no idea if aliases are/will be supported there. Perhaps 
> > @sunfish can tell us :)
>
>
> Yes, they are intended to be supported. It sounds like you found a bug, 
> though I've not been able to reproduce it in simple tests.





Comment at: include/clang/Basic/Attr.td:322
+def TargetSupportsAlias : TargetSpec {
+  let ObjectFormats = ["COFF", "ELF", "Wasm"];
+}

aaron.ballman wrote:
> Did you verify that Wasm supports the alias attribute? If it is supported, it 
> might be nice to add a test to `CodeGen/alias.c` to demonstrate it. Similar 
> for COFF.
Yes, I used the following command line to test my test file.
clang -cc1 -triple wasm32-unknown-unknown -fsyntax-only -verify attr-alias-has.c
clang -cc1 -triple wasm64-unknown-unknown -fsyntax-only -verify attr-alias-has.c
The test result is ok. 
ok, I will update it.



Comment at: test/Sema/attr-alias-has.c:5
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple wasm64-unknown-unknown -fsyntax-only -verify %s
+

aaron.ballman wrote:
> I'd like to see a test that the "attribute not supported on target" 
> diagnostic is being generated. I'd recommend something along these lines:
> ```
> void g() {}
> void f() __attribute__((alias("g")));
> #if !__has_attribute(alias)
> // expected-error@-2{{expected diagnostic text}}
> #else
> // expected-no-diagnostics
> #endif
> ```
ok, I will update it.


Repository:
  rC Clang

https://reviews.llvm.org/D46805



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


[PATCH] D46805: If some platforms do not support an attribute, we should exclude the platform

2018-05-30 Thread Dan Gohman via Phabricator via cfe-commits
sunfish added a comment.

In https://reviews.llvm.org/D46805#1115681, @rsmith wrote:

> In https://reviews.llvm.org/D46805#1113358, @aaron.ballman wrote:
>
> > @rsmith -- do the object file formats listed look correct to you?
>
>
> They look at least plausible. We should be able to test whether LLVM can 
> actually emit aliases on each of these targets easily enough...
>
> However, I get this error for any WAsm compilation I try:
>
>   fatal error: error in backend: section size does not fit in a uint32_t
>
> ... so I have no idea if aliases are/will be supported there. Perhaps 
> @sunfish can tell us :)


Yes, they are intended to be supported. It sounds like you found a bug, though 
I've not been able to reproduce it in simple tests.


Repository:
  rC Clang

https://reviews.llvm.org/D46805



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


[PATCH] D46805: If some platforms do not support an attribute, we should exclude the platform

2018-05-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D46805#1113358, @aaron.ballman wrote:

> @rsmith -- do the object file formats listed look correct to you?


They look at least plausible. We should be able to test whether LLVM can 
actually emit aliases on each of these targets easily enough...

However, I get this error for any WAsm compilation I try:

  fatal error: error in backend: section size does not fit in a uint32_t

... so I have no idea if aliases are/will be supported there. Perhaps @sunfish 
can tell us :)


Repository:
  rC Clang

https://reviews.llvm.org/D46805



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


[PATCH] D46805: If some platforms do not support an attribute, we should exclude the platform

2018-05-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

@rsmith -- do the object file formats listed look correct to you?




Comment at: include/clang/Basic/Attr.td:322
+def TargetSupportsAlias : TargetSpec {
+  let ObjectFormats = ["COFF", "ELF", "Wasm"];
+}

Did you verify that Wasm supports the alias attribute? If it is supported, it 
might be nice to add a test to `CodeGen/alias.c` to demonstrate it. Similar for 
COFF.



Comment at: test/Sema/attr-alias-has.c:5
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple wasm64-unknown-unknown -fsyntax-only -verify %s
+

I'd like to see a test that the "attribute not supported on target" diagnostic 
is being generated. I'd recommend something along these lines:
```
void g() {}
void f() __attribute__((alias("g")));
#if !__has_attribute(alias)
// expected-error@-2{{expected diagnostic text}}
#else
// expected-no-diagnostics
#endif
```


Repository:
  rC Clang

https://reviews.llvm.org/D46805



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


[PATCH] D46805: If some platforms do not support an attribute, we should exclude the platform

2018-05-21 Thread Li Jia He via Phabricator via cfe-commits
HLJ2009 updated this revision to Diff 147773.
HLJ2009 added a comment.
Herald added a subscriber: aheejin.

listing the object formats that *do* support aliases seems reasonable


Repository:
  rC Clang

https://reviews.llvm.org/D46805

Files:
  include/clang/Basic/Attr.td
  test/Sema/attr-alias-has.c


Index: test/Sema/attr-alias-has.c
===
--- /dev/null
+++ test/Sema/attr-alias-has.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple wasm64-unknown-unknown -fsyntax-only -verify %s
+
+#if __has_attribute(alias)
+
+void g() {}
+
+void f() __attribute__((alias("g"))); //expected-no-diagnostics 
+
+#else
+
+//expected-no-diagnostics
+
+#endif
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -318,6 +318,9 @@
 def TargetELF : TargetSpec {
   let ObjectFormats = ["ELF"];
 }
+def TargetSupportsAlias : TargetSpec {
+  let ObjectFormats = ["COFF", "ELF", "Wasm"];
+}
 
 // Attribute subject match rules that are used for #pragma clang attribute.
 //
@@ -554,7 +557,7 @@
   let Documentation = [Undocumented];
 }
 
-def Alias : Attr {
+def Alias : Attr, TargetSpecificAttr {
   let Spellings = [GCC<"alias">];
   let Args = [StringArgument<"Aliasee">];
   let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>;


Index: test/Sema/attr-alias-has.c
===
--- /dev/null
+++ test/Sema/attr-alias-has.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple wasm64-unknown-unknown -fsyntax-only -verify %s
+
+#if __has_attribute(alias)
+
+void g() {}
+
+void f() __attribute__((alias("g"))); //expected-no-diagnostics 
+
+#else
+
+//expected-no-diagnostics
+
+#endif
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -318,6 +318,9 @@
 def TargetELF : TargetSpec {
   let ObjectFormats = ["ELF"];
 }
+def TargetSupportsAlias : TargetSpec {
+  let ObjectFormats = ["COFF", "ELF", "Wasm"];
+}
 
 // Attribute subject match rules that are used for #pragma clang attribute.
 //
@@ -554,7 +557,7 @@
   let Documentation = [Undocumented];
 }
 
-def Alias : Attr {
+def Alias : Attr, TargetSpecificAttr {
   let Spellings = [GCC<"alias">];
   let Args = [StringArgument<"Aliasee">];
   let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46805: If some platforms do not support an attribute, we should exclude the platform

2018-05-14 Thread Li Jia He via Phabricator via cfe-commits
HLJ2009 added inline comments.



Comment at: include/clang/Basic/Attr.td:566-567
 
-def Alias : Attr {
+// We do not support alias attribute on Apple platform, so we exclude the 
platform.
+def Alias : Attr, TargetSpecificAttr {
   let Spellings = [GCC<"alias">];

rsmith wrote:
> Is this really specific to Darwin? I would expect it instead to be specific 
> to the `ObjectFormat`. And I think listing the object formats that *do* 
> support aliases seems reasonable (as there's only three of them to list -- 
> assuming that WAsm actually supports aliases, which I don't know -- and we'd 
> probably want future object file formats to opt in rather than opting out).
Hi,
   If using this program, we need to define a support alias platform, is not 
it? This platform needs to include the ArchType in the Triple.h file for the 
most part, and we need to set the ObjectFormatType to COFF, ELF, and Wasm. But 
we only want to exclude the few unsupported platforms. If my understanding is 
not right, please told me.


Repository:
  rC Clang

https://reviews.llvm.org/D46805



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


[PATCH] D46805: If some platforms do not support an attribute, we should exclude the platform

2018-05-14 Thread Li Jia He via Phabricator via cfe-commits
HLJ2009 marked 4 inline comments as done.
HLJ2009 added inline comments.



Comment at: include/clang/Basic/Attr.td:327
+def TargetDarwinNegative : TargetArch<["x86", "x86_64"]> {
+  let OSes = ["MacOSX"];
+  let Negated = 1;

aaron.ballman wrote:
> I would expect the OS would be named "Darwin" and not "MacOSX" given the name 
> of the target. Which flavor should be used, or should both be used?
hi,Aaron
   First, I set OSType to Darwin,but it does not work on my own machine. so I 
set OSType to MacOSX,and it is ok.Yes, I thought about adding two at the same 
time, but this needs to modify list OSes to list OSes[].


Repository:
  rC Clang

https://reviews.llvm.org/D46805



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


[PATCH] D46805: If some platforms do not support an attribute, we should exclude the platform

2018-05-13 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: include/clang/Basic/Attr.td:566-567
 
-def Alias : Attr {
+// We do not support alias attribute on Apple platform, so we exclude the 
platform.
+def Alias : Attr, TargetSpecificAttr {
   let Spellings = [GCC<"alias">];

Is this really specific to Darwin? I would expect it instead to be specific to 
the `ObjectFormat`. And I think listing the object formats that *do* support 
aliases seems reasonable (as there's only three of them to list -- assuming 
that WAsm actually supports aliases, which I don't know -- and we'd probably 
want future object file formats to opt in rather than opting out).


Repository:
  rC Clang

https://reviews.llvm.org/D46805



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


[PATCH] D46805: If some platforms do not support an attribute, we should exclude the platform

2018-05-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for working on this patch -- be sure to add tests that ensure the 
attribute is properly prohibited on the expected targets.




Comment at: include/clang/Basic/Attr.td:299-300
   list ObjectFormats;
+  // It indicates that a certain attribute is not supported on a specific
+  // platform, turn on support for this attribute by default
+  bit Negated = 0;

How about: `If set to false, indicates the attribute is supported only on the 
given target. If set to true, indicates the attribute is supported on all 
targets except the given target.`



Comment at: include/clang/Basic/Attr.td:324-325
 
+// We do not support the alias attribute on Apple platforms,
+// so I define a platform other than the Apple platform.
+def TargetDarwinNegative : TargetArch<["x86", "x86_64"]> {

This comment is a bit too specific, I'd probably drop the comment entirely as 
the code is sufficiently clear.



Comment at: include/clang/Basic/Attr.td:326
+// so I define a platform other than the Apple platform.
+def TargetDarwinNegative : TargetArch<["x86", "x86_64"]> {
+  let OSes = ["MacOSX"];

I think we'll want to pattern the names like `TargetNotFoo`.

One other thing is: this isn't really Darwin -- for instance, there's ARM and 
AArch64 variants, not just x86-based targets.



Comment at: include/clang/Basic/Attr.td:327
+def TargetDarwinNegative : TargetArch<["x86", "x86_64"]> {
+  let OSes = ["MacOSX"];
+  let Negated = 1;

I would expect the OS would be named "Darwin" and not "MacOSX" given the name 
of the target. Which flavor should be used, or should both be used?



Comment at: utils/TableGen/ClangAttrEmitter.cpp:2789
+  // is not supported on this platform
+  if(R->getValueAsBit("Negated"))
+Test = "!(" + Test + ")";

The formatting is off here -- there should be a space after the `if`. I would 
recommend running your patch through clang-format 
(https://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting).


Repository:
  rC Clang

https://reviews.llvm.org/D46805



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


[PATCH] D46805: If some platforms do not support an attribute, we should exclude the platform

2018-05-13 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

1. Please always upload all patches with full context.
2. tests?


Repository:
  rC Clang

https://reviews.llvm.org/D46805



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


[PATCH] D46805: If some platforms do not support an attribute, we should exclude the platform

2018-05-13 Thread Li Jia He via Phabricator via cfe-commits
HLJ2009 created this revision.
HLJ2009 added a reviewer: aaron.ballman.
Herald added a subscriber: cfe-commits.

I tested the alias attribute on my own Apple laptop (Target: 
x86_64-apple-darwin17.5.0). First, I use __has_attribute to test that the alias 
is usable or not. The test code is as follows:
#include 
void print() {
#if __has_attribute(alias)

  printf("has attribute");

#else

  printf("has not attribute");

#endif
}
int main() {

  print();
  return 0;

}
Compiled using clang, the output result is has attribute, but when i use the 
following code to verify
#include 
int oldname = 1;
extern int newname __attribute__((alias("oldname"))); // declaration
void foo(void)
{

  printf("newname = %d\n", newname); // prints 1

}
int main() {

  foo();
  return 0;

}
It told me alias.c:3:35: error: aliases are not supported on darwin.so we 
should exclude the platform.


Repository:
  rC Clang

https://reviews.llvm.org/D46805

Files:
  include/clang/Basic/Attr.td
  utils/TableGen/ClangAttrEmitter.cpp


Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -2784,6 +2784,11 @@
   GenerateTargetSpecificAttrCheck(R, Test, FnName, "OSes", "T.getOS()",
   "llvm::Triple::");
 
+  // If the Negated is 1 in specific, it indicates that the attribute
+  // is not supported on this platform
+  if(R->getValueAsBit("Negated"))
+Test = "!(" + Test + ")";
+
   // If one or more CXX ABIs are specified, check those as well.
   GenerateTargetSpecificAttrCheck(R, Test, FnName, "CXXABIs",
   "Target.getCXXABI().getKind()",
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -296,6 +296,9 @@
   // Specifies Object Formats for which the target applies, based off the
   // ObjectFormatType enumeration in Triple.h
   list ObjectFormats;
+  // It indicates that a certain attribute is not supported on a specific
+  // platform, turn on support for this attribute by default
+  bit Negated = 0;
 }
 
 class TargetArch : TargetSpec {
@@ -318,6 +321,13 @@
   let ObjectFormats = ["ELF"];
 }
 
+// We do not support the alias attribute on Apple platforms,
+// so I define a platform other than the Apple platform.
+def TargetDarwinNegative : TargetArch<["x86", "x86_64"]> {
+  let OSes = ["MacOSX"];
+  let Negated = 1;
+}
+
 // Attribute subject match rules that are used for #pragma clang attribute.
 //
 // A instance of AttrSubjectMatcherRule represents an individual match rule.
@@ -553,7 +563,8 @@
   let Documentation = [Undocumented];
 }
 
-def Alias : Attr {
+// We do not support alias attribute on Apple platform, so we exclude the 
platform.
+def Alias : Attr, TargetSpecificAttr {
   let Spellings = [GCC<"alias">];
   let Args = [StringArgument<"Aliasee">];
   let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>;


Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -2784,6 +2784,11 @@
   GenerateTargetSpecificAttrCheck(R, Test, FnName, "OSes", "T.getOS()",
   "llvm::Triple::");
 
+  // If the Negated is 1 in specific, it indicates that the attribute
+  // is not supported on this platform
+  if(R->getValueAsBit("Negated"))
+Test = "!(" + Test + ")";
+
   // If one or more CXX ABIs are specified, check those as well.
   GenerateTargetSpecificAttrCheck(R, Test, FnName, "CXXABIs",
   "Target.getCXXABI().getKind()",
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -296,6 +296,9 @@
   // Specifies Object Formats for which the target applies, based off the
   // ObjectFormatType enumeration in Triple.h
   list ObjectFormats;
+  // It indicates that a certain attribute is not supported on a specific
+  // platform, turn on support for this attribute by default
+  bit Negated = 0;
 }
 
 class TargetArch : TargetSpec {
@@ -318,6 +321,13 @@
   let ObjectFormats = ["ELF"];
 }
 
+// We do not support the alias attribute on Apple platforms,
+// so I define a platform other than the Apple platform.
+def TargetDarwinNegative : TargetArch<["x86", "x86_64"]> {
+  let OSes = ["MacOSX"];
+  let Negated = 1;
+}
+
 // Attribute subject match rules that are used for #pragma clang attribute.
 //
 // A instance of AttrSubjectMatcherRule represents an individual match rule.
@@ -553,7 +563,8 @@
   let Documentation = [Undocumented];
 }
 
-def Alias : Attr {
+// We do not support alias attribute on Apple platform, so we exclude the platform.
+def Alias : Attr, TargetSpecificAttr {