diff options
author | Egor Zhdan <e_zhdan@apple.com> | 2022-03-08 22:45:28 +0000 |
---|---|---|
committer | Egor Zhdan <e_zhdan@apple.com> | 2022-03-18 12:20:41 +0000 |
commit | 33a9eac6aaa495fce6fd9b17cd48aa57a95461e6 (patch) | |
tree | a899b1c33aca914c1391f21a82d2344bd9c66c4e /clang/lib/Parse/ParseDecl.cpp | |
parent | 62c481542e63a9019aa469c70cb228fe90ce7ece (diff) | |
download | llvm-33a9eac6aaa495fce6fd9b17cd48aa57a95461e6.zip llvm-33a9eac6aaa495fce6fd9b17cd48aa57a95461e6.tar.gz llvm-33a9eac6aaa495fce6fd9b17cd48aa57a95461e6.tar.bz2 |
[Clang] Support multiple attributes in a single pragma
This adds support for multiple attributes in `#pragma clang attribute push`, for example:
```
```
or
```
```
Related attributes can now be applied with a single pragma, which makes it harder for developers to make an accidental error later when editing the code.
rdar://78269653
Differential Revision: https://reviews.llvm.org/D121283
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 44a05ee..135b2df 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -600,6 +600,8 @@ unsigned Parser::ParseClangAttributeArgs( bool Parser::ParseMicrosoftDeclSpecArgs(IdentifierInfo *AttrName, SourceLocation AttrNameLoc, ParsedAttributes &Attrs) { + unsigned ExistingAttrs = Attrs.size(); + // If the attribute isn't known, we will not attempt to parse any // arguments. if (!hasAttribute(AttrSyntax::Declspec, nullptr, AttrName, @@ -732,7 +734,7 @@ bool Parser::ParseMicrosoftDeclSpecArgs(IdentifierInfo *AttrName, // If this attribute's args were parsed, and it was expected to have // arguments but none were provided, emit a diagnostic. - if (!Attrs.empty() && Attrs.begin()->getMaxArgs() && !NumArgs) { + if (ExistingAttrs < Attrs.size() && Attrs.back().getMaxArgs() && !NumArgs) { Diag(OpenParenLoc, diag::err_attribute_requires_arguments) << AttrName; return false; } |