[clang] Parse attribute [[gnu::no_stack_protector]] (#75289)

This commit adds relative TableGen definitions to parse the
`[[gnu::no_stack_protector]]` attribute.

This PR addresses issue #75235.
This commit is contained in:
Sirui Mu 2023-12-14 11:31:17 +08:00 committed by GitHub
parent b07aaf8d3b
commit 9d02770832
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View File

@ -2212,7 +2212,8 @@ def NotTailCalled : InheritableAttr {
def : MutualExclusions<[AlwaysInline, NotTailCalled]>;
def NoStackProtector : InheritableAttr {
let Spellings = [Clang<"no_stack_protector">, Declspec<"safebuffers">];
let Spellings = [Clang<"no_stack_protector">, CXX11<"gnu", "no_stack_protector">,
C23<"gnu", "no_stack_protector">, Declspec<"safebuffers">];
let Subjects = SubjectList<[Function]>;
let Documentation = [NoStackProtectorDocs];
let SimpleHandler = 1;

View File

@ -1,4 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c23 %s
[[gnu::no_stack_protector]] void test1(void) {}
[[clang::no_stack_protector]] void test2(void) {}
void __attribute__((no_stack_protector)) foo(void) {}
int __attribute__((no_stack_protector)) var; // expected-warning {{'no_stack_protector' attribute only applies to functions}}

View File

@ -0,0 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
// expected-no-diagnostics
[[gnu::no_stack_protector]] void test1() {}
[[clang::no_stack_protector]] void test2() {}