-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[Clang] restrict use of attribute names reserved by the C++ standard #106036
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ef0f355
[Clang] restrict use of attribute names reserved by the C++ standard
a-tarasyuk 593cc60
update tests
a-tarasyuk d89c879
handle function like attr names
a-tarasyuk 2b468af
improve attribute checking with a simplified helper
a-tarasyuk e73f6b5
add reserved attribute identifier to reserved identifier group
a-tarasyuk bfd7f9a
add hasAttribute overload
a-tarasyuk 2bbaddd
update arg comment
a-tarasyuk 6deba51
Merge branch 'main' into feat/92196
a-tarasyuk a7873c3
Merge branch 'main' into feat/92196
a-tarasyuk ee7a610
Merge branch 'main' into feat/92196
a-tarasyuk 8a5b3e1
prevent default throw warning for reserved attribute names
a-tarasyuk fbbe9ae
Merge branch 'feat/92196' of https://github.com/a-tarasyuk/llvm-proje…
a-tarasyuk cf61459
Merge branch 'main' of https://github.com/llvm/llvm-project into feat…
a-tarasyuk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -Wreserved-attribute-identifier -fsyntax-only -verify %s -DTEST1 | ||
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -Wreserved-attribute-identifier -fsyntax-only -verify %s -DTEST2 | ||
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -Wreserved-attribute-identifier -fsyntax-only -verify %s -DTEST3 | ||
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -Wreserved-attribute-identifier -fsyntax-only -verify %s -DTEST4 | ||
|
||
#ifdef TEST1 | ||
|
||
#define assume | ||
#undef assume | ||
|
||
#define noreturn // expected-warning {{noreturn is a reserved attribute identifier}} | ||
#undef noreturn // expected-warning {{noreturn is a reserved attribute identifier}} | ||
|
||
#define carries_dependency // expected-warning {{carries_dependency is a reserved attribute identifier}} | ||
#undef carries_dependency // expected-warning {{carries_dependency is a reserved attribute identifier}} | ||
|
||
#define deprecated // expected-warning {{deprecated is a reserved attribute identifier}} | ||
#undef deprecated // expected-warning {{deprecated is a reserved attribute identifier}} | ||
|
||
#define fallthrough // expected-warning {{fallthrough is a reserved attribute identifier}} | ||
#undef fallthrough // expected-warning {{fallthrough is a reserved attribute identifier}} | ||
|
||
#define likely // expected-warning {{likely is a reserved attribute identifier}} | ||
#undef likely // expected-warning {{likely is a reserved attribute identifier}} | ||
|
||
#define no_unique_address // expected-warning {{no_unique_address is a reserved attribute identifier}} | ||
#undef no_unique_address // expected-warning {{no_unique_address is a reserved attribute identifier}} | ||
|
||
#define unlikely // expected-warning {{unlikely is a reserved attribute identifier}} | ||
#undef unlikely // expected-warning {{unlikely is a reserved attribute identifier}} | ||
|
||
#define maybe_unused // expected-warning {{maybe_unused is a reserved attribute identifier}} | ||
#undef maybe_unused // expected-warning {{maybe_unused is a reserved attribute identifier}} | ||
|
||
#define nodiscard // expected-warning {{nodiscard is a reserved attribute identifier}} | ||
#undef nodiscard // expected-warning {{nodiscard is a reserved attribute identifier}} | ||
|
||
#elif TEST2 | ||
|
||
#define assume "test" | ||
#undef assume | ||
|
||
#define noreturn "test" // expected-warning {{noreturn is a reserved attribute identifier}} | ||
#undef noreturn // expected-warning {{noreturn is a reserved attribute identifier}} | ||
|
||
#define carries_dependency "test" // expected-warning {{carries_dependency is a reserved attribute identifier}} | ||
#undef carries_dependency // expected-warning {{carries_dependency is a reserved attribute identifier}} | ||
|
||
#define deprecated "test" // expected-warning {{deprecated is a reserved attribute identifier}} | ||
#undef deprecated // expected-warning {{deprecated is a reserved attribute identifier}} | ||
|
||
#define fallthrough "test" // expected-warning {{fallthrough is a reserved attribute identifier}} | ||
#undef fallthrough // expected-warning {{fallthrough is a reserved attribute identifier}} | ||
|
||
#define likely "test" // expected-warning {{likely is a reserved attribute identifier}} | ||
#undef likely // expected-warning {{likely is a reserved attribute identifier}} | ||
|
||
#define no_unique_address "test" // expected-warning {{no_unique_address is a reserved attribute identifier}} | ||
#undef no_unique_address // expected-warning {{no_unique_address is a reserved attribute identifier}} | ||
|
||
#define unlikely "test" // expected-warning {{unlikely is a reserved attribute identifier}} | ||
#undef unlikely // expected-warning {{unlikely is a reserved attribute identifier}} | ||
|
||
#define maybe_unused "test" // expected-warning {{maybe_unused is a reserved attribute identifier}} | ||
#undef maybe_unused // expected-warning {{maybe_unused is a reserved attribute identifier}} | ||
|
||
#define nodiscard "test" // expected-warning {{nodiscard is a reserved attribute identifier}} | ||
#undef nodiscard // expected-warning {{nodiscard is a reserved attribute identifier}} | ||
|
||
#elif TEST3 | ||
|
||
#define assume() "test" // expected-warning {{assume is a reserved attribute identifier}} | ||
#define deprecated() "test" // expected-warning {{deprecated is a reserved attribute identifier}} | ||
#define nodiscard() "test" // expected-warning {{nodiscard is a reserved attribute identifier}} | ||
#define noreturn() "test" | ||
#define carries_dependency() "test" | ||
#define fallthrough() "test" | ||
#define likely() "test" | ||
#define no_unique_address() "test" | ||
#define unlikely() "test" | ||
#define maybe_unused() "test" | ||
|
||
#elif TEST4 | ||
|
||
#define assume() // expected-warning {{assume is a reserved attribute identifier}} | ||
#define deprecated() // expected-warning {{deprecated is a reserved attribute identifier}} | ||
#define nodiscard() // expected-warning {{nodiscard is a reserved attribute identifier}} | ||
#define noreturn() | ||
#define carries_dependency() | ||
#define fallthrough() | ||
#define likely() | ||
#define no_unique_address() | ||
#define unlikely() | ||
#define maybe_unused() | ||
|
||
#else | ||
|
||
#error Unknown test | ||
|
||
#endif |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.