[clang] Match against all plugins when parsing microsoft attributes (PR #86426)
https://github.com/apache-hb updated https://github.com/llvm/llvm-project/pull/86426 >From 245a21512d8658225b17b91b8af4764f54084e01 Mon Sep 17 00:00:00 2001 From: Elliot <35050275+apache...@users.noreply.github.com> Date: Sun, 24 Mar 2024 03:03:47 -0400 Subject: [PATCH 1/8] Match against all plugins when parsing microsoft attributes fixes #86422 --- clang/lib/Parse/ParseDeclCXX.cpp | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 63fe678cbb29e2..d05b3a455f7f63 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -5061,11 +5061,12 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes ) { IdentifierInfo *II = Tok.getIdentifierInfo(); SourceLocation NameLoc = Tok.getLocation(); ConsumeToken(); -ParsedAttr::Kind AttrKind = -ParsedAttr::getParsedKind(II, nullptr, ParsedAttr::AS_Microsoft); + // For HLSL we want to handle all attributes, but for MSVC compat, we // silently ignore unknown Microsoft attributes. -if (getLangOpts().HLSL || AttrKind != ParsedAttr::UnknownAttribute) { +AttributeCommonInfo Info{II, NameLoc, AttributeCommonInfo::Form::Microsoft()}; +const ParsedAttrInfo& AttrInfo = ParsedAttrInfo::get(Info); +if (getLangOpts().HLSL || AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, II->getName())) { bool AttrParsed = false; if (Tok.is(tok::l_paren)) { CachedTokens OpenMPTokens; >From 4e47899a9fb17dec5931007b5025f6ce97dbe3eb Mon Sep 17 00:00:00 2001 From: Elliot <35050275+apache...@users.noreply.github.com> Date: Sun, 24 Mar 2024 03:05:54 -0400 Subject: [PATCH 2/8] Apply formatting --- clang/lib/Parse/ParseDeclCXX.cpp | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index d05b3a455f7f63..856ac11f7bb839 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -5064,9 +5064,12 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes ) { // For HLSL we want to handle all attributes, but for MSVC compat, we // silently ignore unknown Microsoft attributes. -AttributeCommonInfo Info{II, NameLoc, AttributeCommonInfo::Form::Microsoft()}; -const ParsedAttrInfo& AttrInfo = ParsedAttrInfo::get(Info); -if (getLangOpts().HLSL || AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, II->getName())) { +AttributeCommonInfo Info{II, NameLoc, + AttributeCommonInfo::Form::Microsoft()}; +const ParsedAttrInfo = ParsedAttrInfo::get(Info); +if (getLangOpts().HLSL || +AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, + II->getName())) { bool AttrParsed = false; if (Tok.is(tok::l_paren)) { CachedTokens OpenMPTokens; >From 8adb5bc07dd23afac4f66f6658a4197fb97f058f Mon Sep 17 00:00:00 2001 From: Elliot <35050275+apache...@users.noreply.github.com> Date: Mon, 25 Mar 2024 13:37:00 -0400 Subject: [PATCH 3/8] use hasAttribute instead of ParsedAttrInfo::get --- clang/lib/Parse/ParseDeclCXX.cpp | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 856ac11f7bb839..619f7f88bfdbfe 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -5064,12 +5064,9 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes ) { // For HLSL we want to handle all attributes, but for MSVC compat, we // silently ignore unknown Microsoft attributes. -AttributeCommonInfo Info{II, NameLoc, - AttributeCommonInfo::Form::Microsoft()}; -const ParsedAttrInfo = ParsedAttrInfo::get(Info); -if (getLangOpts().HLSL || -AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, - II->getName())) { +int Attr = hasAttribute(AttributeCommonInfo::Syntax::AS_Microsoft, nullptr, +II, getTargetInfo(), getLangOpts()); +if (getLangOpts().HLSL || Attr != 0) { bool AttrParsed = false; if (Tok.is(tok::l_paren)) { CachedTokens OpenMPTokens; >From b3f297eec02643452a8815d7d62b1b5a0f07760b Mon Sep 17 00:00:00 2001 From: Elliot <35050275+apache...@users.noreply.github.com> Date: Mon, 25 Mar 2024 13:54:27 -0400 Subject: [PATCH 4/8] Update ReleaseNotes.rst --- clang/docs/ReleaseNotes.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 8054d90fc70f93..df73abb12e89fa 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -345,6 +345,9 @@ Bug Fixes to Compiler Builtins
[clang] Match against all plugins when parsing microsoft attributes (PR #86426)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 5d7fd6a04a6748936dece9d90481b2ba4ec97e53 6ba913fb0d3efdb17ae481ccad63ccde2170d4e2 -- clang/examples/MicrosoftAttributes/MicrosoftAttributes.cpp clang/test/Frontend/ms-attributes.cpp clang/lib/Parse/ParseDeclCXX.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/examples/MicrosoftAttributes/MicrosoftAttributes.cpp b/clang/examples/MicrosoftAttributes/MicrosoftAttributes.cpp index 571d6f8624..dd252f7d5b 100644 --- a/clang/examples/MicrosoftAttributes/MicrosoftAttributes.cpp +++ b/clang/examples/MicrosoftAttributes/MicrosoftAttributes.cpp @@ -25,34 +25,35 @@ using namespace clang; namespace { struct ExampleAttrInfo : public ParsedAttrInfo { -ExampleAttrInfo() { -// Can take up to 1 optional argument. -OptArgs = 1; - -// Only Microsoft-style [ms_example] supported. -// e.g.: -// [ms_example] class C {}; -// [ms_example] void f() {} -static constexpr Spelling S[] = { -{ParsedAttr::AS_Microsoft, "ms_example"} -}; -Spellings = S; -} - -bool diagAppertainsToDecl(Sema , const ParsedAttr , const Decl *D) const override { -// This attribute can be applied to any declaration. -if (!isa(D)) { -S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) -<< Attr << Attr.isRegularKeywordAttribute() << "classes"; -} -return true; -} - -AttrHandling handleDeclAttribute(Sema , Decl *D, const ParsedAttr ) const override { -// Add an annotation to the declaration. -D->addAttr(AnnotateAttr::Create(S.Context, "ms_example", nullptr, 0, Attr.getRange())); -return AttributeApplied; + ExampleAttrInfo() { +// Can take up to 1 optional argument. +OptArgs = 1; + +// Only Microsoft-style [ms_example] supported. +// e.g.: +// [ms_example] class C {}; +// [ms_example] void f() {} +static constexpr Spelling S[] = {{ParsedAttr::AS_Microsoft, "ms_example"}}; +Spellings = S; + } + + bool diagAppertainsToDecl(Sema , const ParsedAttr , +const Decl *D) const override { +// This attribute can be applied to any declaration. +if (!isa(D)) { + S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) + << Attr << Attr.isRegularKeywordAttribute() << "classes"; } +return true; + } + + AttrHandling handleDeclAttribute(Sema , Decl *D, + const ParsedAttr ) const override { +// Add an annotation to the declaration. +D->addAttr(AnnotateAttr::Create(S.Context, "ms_example", nullptr, 0, +Attr.getRange())); +return AttributeApplied; + } }; } // namespace diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 619f7f88bf..b323f053c4 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -5064,8 +5064,8 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes ) { // For HLSL we want to handle all attributes, but for MSVC compat, we // silently ignore unknown Microsoft attributes. -int Attr = hasAttribute(AttributeCommonInfo::Syntax::AS_Microsoft, nullptr, -II, getTargetInfo(), getLangOpts()); +int Attr = hasAttribute(AttributeCommonInfo::Syntax::AS_Microsoft, +nullptr, II, getTargetInfo(), getLangOpts()); if (getLangOpts().HLSL || Attr != 0) { bool AttrParsed = false; if (Tok.is(tok::l_paren)) { `` https://github.com/llvm/llvm-project/pull/86426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Match against all plugins when parsing microsoft attributes (PR #86426)
@@ -345,6 +345,9 @@ Bug Fixes to Compiler Builtins Bug Fixes to Attribute Support ^^ +- Clang now correctly matches plugin attributes with microsoft ``[attribute]`` syntax. erichkeane wrote: > Microsoft attributes use single brackets, c++11 attributes use `[[]]` Ah, woops! I saw that later on and fixed it in my suggestion, but not the message above. But please capitalize 'Microsoft' as suggested. https://github.com/llvm/llvm-project/pull/86426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Match against all plugins when parsing microsoft attributes (PR #86426)
@@ -345,6 +345,9 @@ Bug Fixes to Compiler Builtins Bug Fixes to Attribute Support ^^ +- Clang now correctly matches plugin attributes with microsoft ``[attribute]`` syntax. apache-hb wrote: Microsoft attributes use single brackets, c++11 attributes use `[[]]` https://github.com/llvm/llvm-project/pull/86426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Match against all plugins when parsing microsoft attributes (PR #86426)
https://github.com/apache-hb updated https://github.com/llvm/llvm-project/pull/86426 >From 245a21512d8658225b17b91b8af4764f54084e01 Mon Sep 17 00:00:00 2001 From: Elliot <35050275+apache...@users.noreply.github.com> Date: Sun, 24 Mar 2024 03:03:47 -0400 Subject: [PATCH 1/7] Match against all plugins when parsing microsoft attributes fixes #86422 --- clang/lib/Parse/ParseDeclCXX.cpp | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 63fe678cbb29e2..d05b3a455f7f63 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -5061,11 +5061,12 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes ) { IdentifierInfo *II = Tok.getIdentifierInfo(); SourceLocation NameLoc = Tok.getLocation(); ConsumeToken(); -ParsedAttr::Kind AttrKind = -ParsedAttr::getParsedKind(II, nullptr, ParsedAttr::AS_Microsoft); + // For HLSL we want to handle all attributes, but for MSVC compat, we // silently ignore unknown Microsoft attributes. -if (getLangOpts().HLSL || AttrKind != ParsedAttr::UnknownAttribute) { +AttributeCommonInfo Info{II, NameLoc, AttributeCommonInfo::Form::Microsoft()}; +const ParsedAttrInfo& AttrInfo = ParsedAttrInfo::get(Info); +if (getLangOpts().HLSL || AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, II->getName())) { bool AttrParsed = false; if (Tok.is(tok::l_paren)) { CachedTokens OpenMPTokens; >From 4e47899a9fb17dec5931007b5025f6ce97dbe3eb Mon Sep 17 00:00:00 2001 From: Elliot <35050275+apache...@users.noreply.github.com> Date: Sun, 24 Mar 2024 03:05:54 -0400 Subject: [PATCH 2/7] Apply formatting --- clang/lib/Parse/ParseDeclCXX.cpp | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index d05b3a455f7f63..856ac11f7bb839 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -5064,9 +5064,12 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes ) { // For HLSL we want to handle all attributes, but for MSVC compat, we // silently ignore unknown Microsoft attributes. -AttributeCommonInfo Info{II, NameLoc, AttributeCommonInfo::Form::Microsoft()}; -const ParsedAttrInfo& AttrInfo = ParsedAttrInfo::get(Info); -if (getLangOpts().HLSL || AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, II->getName())) { +AttributeCommonInfo Info{II, NameLoc, + AttributeCommonInfo::Form::Microsoft()}; +const ParsedAttrInfo = ParsedAttrInfo::get(Info); +if (getLangOpts().HLSL || +AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, + II->getName())) { bool AttrParsed = false; if (Tok.is(tok::l_paren)) { CachedTokens OpenMPTokens; >From 8adb5bc07dd23afac4f66f6658a4197fb97f058f Mon Sep 17 00:00:00 2001 From: Elliot <35050275+apache...@users.noreply.github.com> Date: Mon, 25 Mar 2024 13:37:00 -0400 Subject: [PATCH 3/7] use hasAttribute instead of ParsedAttrInfo::get --- clang/lib/Parse/ParseDeclCXX.cpp | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 856ac11f7bb839..619f7f88bfdbfe 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -5064,12 +5064,9 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes ) { // For HLSL we want to handle all attributes, but for MSVC compat, we // silently ignore unknown Microsoft attributes. -AttributeCommonInfo Info{II, NameLoc, - AttributeCommonInfo::Form::Microsoft()}; -const ParsedAttrInfo = ParsedAttrInfo::get(Info); -if (getLangOpts().HLSL || -AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, - II->getName())) { +int Attr = hasAttribute(AttributeCommonInfo::Syntax::AS_Microsoft, nullptr, +II, getTargetInfo(), getLangOpts()); +if (getLangOpts().HLSL || Attr != 0) { bool AttrParsed = false; if (Tok.is(tok::l_paren)) { CachedTokens OpenMPTokens; >From b3f297eec02643452a8815d7d62b1b5a0f07760b Mon Sep 17 00:00:00 2001 From: Elliot <35050275+apache...@users.noreply.github.com> Date: Mon, 25 Mar 2024 13:54:27 -0400 Subject: [PATCH 4/7] Update ReleaseNotes.rst --- clang/docs/ReleaseNotes.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 8054d90fc70f93..df73abb12e89fa 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -345,6 +345,9 @@ Bug Fixes to Compiler Builtins
[clang] Match against all plugins when parsing microsoft attributes (PR #86426)
https://github.com/erichkeane commented: This has enough to do with parsing that i think Aaron should take a look too. Also, this needs a parser test, not just the plugin test. The plugins/examples aren't built often enough, so this needs to be a full lit test. https://github.com/llvm/llvm-project/pull/86426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Match against all plugins when parsing microsoft attributes (PR #86426)
@@ -345,6 +345,9 @@ Bug Fixes to Compiler Builtins Bug Fixes to Attribute Support ^^ +- Clang now correctly matches plugin attributes with microsoft ``[attribute]`` syntax. erichkeane wrote: Should this be double-brackets? ```suggestion - Clang now correctly matches plugin attributes with Microsoft ``[attribute]`` syntax. ``` https://github.com/llvm/llvm-project/pull/86426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Match against all plugins when parsing microsoft attributes (PR #86426)
https://github.com/erichkeane edited https://github.com/llvm/llvm-project/pull/86426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Match against all plugins when parsing microsoft attributes (PR #86426)
to268 wrote: CC: @erichkeane, since it's a PR about attributes. I can't add the `extension::microsoft`label to the PR myself. https://github.com/llvm/llvm-project/pull/86426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Match against all plugins when parsing microsoft attributes (PR #86426)
https://github.com/apache-hb updated https://github.com/llvm/llvm-project/pull/86426 >From 245a21512d8658225b17b91b8af4764f54084e01 Mon Sep 17 00:00:00 2001 From: Elliot <35050275+apache...@users.noreply.github.com> Date: Sun, 24 Mar 2024 03:03:47 -0400 Subject: [PATCH 1/6] Match against all plugins when parsing microsoft attributes fixes #86422 --- clang/lib/Parse/ParseDeclCXX.cpp | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 63fe678cbb29e2..d05b3a455f7f63 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -5061,11 +5061,12 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes ) { IdentifierInfo *II = Tok.getIdentifierInfo(); SourceLocation NameLoc = Tok.getLocation(); ConsumeToken(); -ParsedAttr::Kind AttrKind = -ParsedAttr::getParsedKind(II, nullptr, ParsedAttr::AS_Microsoft); + // For HLSL we want to handle all attributes, but for MSVC compat, we // silently ignore unknown Microsoft attributes. -if (getLangOpts().HLSL || AttrKind != ParsedAttr::UnknownAttribute) { +AttributeCommonInfo Info{II, NameLoc, AttributeCommonInfo::Form::Microsoft()}; +const ParsedAttrInfo& AttrInfo = ParsedAttrInfo::get(Info); +if (getLangOpts().HLSL || AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, II->getName())) { bool AttrParsed = false; if (Tok.is(tok::l_paren)) { CachedTokens OpenMPTokens; >From 4e47899a9fb17dec5931007b5025f6ce97dbe3eb Mon Sep 17 00:00:00 2001 From: Elliot <35050275+apache...@users.noreply.github.com> Date: Sun, 24 Mar 2024 03:05:54 -0400 Subject: [PATCH 2/6] Apply formatting --- clang/lib/Parse/ParseDeclCXX.cpp | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index d05b3a455f7f63..856ac11f7bb839 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -5064,9 +5064,12 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes ) { // For HLSL we want to handle all attributes, but for MSVC compat, we // silently ignore unknown Microsoft attributes. -AttributeCommonInfo Info{II, NameLoc, AttributeCommonInfo::Form::Microsoft()}; -const ParsedAttrInfo& AttrInfo = ParsedAttrInfo::get(Info); -if (getLangOpts().HLSL || AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, II->getName())) { +AttributeCommonInfo Info{II, NameLoc, + AttributeCommonInfo::Form::Microsoft()}; +const ParsedAttrInfo = ParsedAttrInfo::get(Info); +if (getLangOpts().HLSL || +AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, + II->getName())) { bool AttrParsed = false; if (Tok.is(tok::l_paren)) { CachedTokens OpenMPTokens; >From 8adb5bc07dd23afac4f66f6658a4197fb97f058f Mon Sep 17 00:00:00 2001 From: Elliot <35050275+apache...@users.noreply.github.com> Date: Mon, 25 Mar 2024 13:37:00 -0400 Subject: [PATCH 3/6] use hasAttribute instead of ParsedAttrInfo::get --- clang/lib/Parse/ParseDeclCXX.cpp | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 856ac11f7bb839..619f7f88bfdbfe 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -5064,12 +5064,9 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes ) { // For HLSL we want to handle all attributes, but for MSVC compat, we // silently ignore unknown Microsoft attributes. -AttributeCommonInfo Info{II, NameLoc, - AttributeCommonInfo::Form::Microsoft()}; -const ParsedAttrInfo = ParsedAttrInfo::get(Info); -if (getLangOpts().HLSL || -AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, - II->getName())) { +int Attr = hasAttribute(AttributeCommonInfo::Syntax::AS_Microsoft, nullptr, +II, getTargetInfo(), getLangOpts()); +if (getLangOpts().HLSL || Attr != 0) { bool AttrParsed = false; if (Tok.is(tok::l_paren)) { CachedTokens OpenMPTokens; >From b3f297eec02643452a8815d7d62b1b5a0f07760b Mon Sep 17 00:00:00 2001 From: Elliot <35050275+apache...@users.noreply.github.com> Date: Mon, 25 Mar 2024 13:54:27 -0400 Subject: [PATCH 4/6] Update ReleaseNotes.rst --- clang/docs/ReleaseNotes.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 8054d90fc70f93..df73abb12e89fa 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -345,6 +345,9 @@ Bug Fixes to Compiler Builtins
[clang] Match against all plugins when parsing microsoft attributes (PR #86426)
https://github.com/apache-hb updated https://github.com/llvm/llvm-project/pull/86426 >From 245a21512d8658225b17b91b8af4764f54084e01 Mon Sep 17 00:00:00 2001 From: Elliot <35050275+apache...@users.noreply.github.com> Date: Sun, 24 Mar 2024 03:03:47 -0400 Subject: [PATCH 1/5] Match against all plugins when parsing microsoft attributes fixes #86422 --- clang/lib/Parse/ParseDeclCXX.cpp | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 63fe678cbb29e2..d05b3a455f7f63 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -5061,11 +5061,12 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes ) { IdentifierInfo *II = Tok.getIdentifierInfo(); SourceLocation NameLoc = Tok.getLocation(); ConsumeToken(); -ParsedAttr::Kind AttrKind = -ParsedAttr::getParsedKind(II, nullptr, ParsedAttr::AS_Microsoft); + // For HLSL we want to handle all attributes, but for MSVC compat, we // silently ignore unknown Microsoft attributes. -if (getLangOpts().HLSL || AttrKind != ParsedAttr::UnknownAttribute) { +AttributeCommonInfo Info{II, NameLoc, AttributeCommonInfo::Form::Microsoft()}; +const ParsedAttrInfo& AttrInfo = ParsedAttrInfo::get(Info); +if (getLangOpts().HLSL || AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, II->getName())) { bool AttrParsed = false; if (Tok.is(tok::l_paren)) { CachedTokens OpenMPTokens; >From 4e47899a9fb17dec5931007b5025f6ce97dbe3eb Mon Sep 17 00:00:00 2001 From: Elliot <35050275+apache...@users.noreply.github.com> Date: Sun, 24 Mar 2024 03:05:54 -0400 Subject: [PATCH 2/5] Apply formatting --- clang/lib/Parse/ParseDeclCXX.cpp | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index d05b3a455f7f63..856ac11f7bb839 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -5064,9 +5064,12 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes ) { // For HLSL we want to handle all attributes, but for MSVC compat, we // silently ignore unknown Microsoft attributes. -AttributeCommonInfo Info{II, NameLoc, AttributeCommonInfo::Form::Microsoft()}; -const ParsedAttrInfo& AttrInfo = ParsedAttrInfo::get(Info); -if (getLangOpts().HLSL || AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, II->getName())) { +AttributeCommonInfo Info{II, NameLoc, + AttributeCommonInfo::Form::Microsoft()}; +const ParsedAttrInfo = ParsedAttrInfo::get(Info); +if (getLangOpts().HLSL || +AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, + II->getName())) { bool AttrParsed = false; if (Tok.is(tok::l_paren)) { CachedTokens OpenMPTokens; >From 8adb5bc07dd23afac4f66f6658a4197fb97f058f Mon Sep 17 00:00:00 2001 From: Elliot <35050275+apache...@users.noreply.github.com> Date: Mon, 25 Mar 2024 13:37:00 -0400 Subject: [PATCH 3/5] use hasAttribute instead of ParsedAttrInfo::get --- clang/lib/Parse/ParseDeclCXX.cpp | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 856ac11f7bb839..619f7f88bfdbfe 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -5064,12 +5064,9 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes ) { // For HLSL we want to handle all attributes, but for MSVC compat, we // silently ignore unknown Microsoft attributes. -AttributeCommonInfo Info{II, NameLoc, - AttributeCommonInfo::Form::Microsoft()}; -const ParsedAttrInfo = ParsedAttrInfo::get(Info); -if (getLangOpts().HLSL || -AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, - II->getName())) { +int Attr = hasAttribute(AttributeCommonInfo::Syntax::AS_Microsoft, nullptr, +II, getTargetInfo(), getLangOpts()); +if (getLangOpts().HLSL || Attr != 0) { bool AttrParsed = false; if (Tok.is(tok::l_paren)) { CachedTokens OpenMPTokens; >From b3f297eec02643452a8815d7d62b1b5a0f07760b Mon Sep 17 00:00:00 2001 From: Elliot <35050275+apache...@users.noreply.github.com> Date: Mon, 25 Mar 2024 13:54:27 -0400 Subject: [PATCH 4/5] Update ReleaseNotes.rst --- clang/docs/ReleaseNotes.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 8054d90fc70f93..df73abb12e89fa 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -345,6 +345,9 @@ Bug Fixes to Compiler Builtins
[clang] Match against all plugins when parsing microsoft attributes (PR #86426)
https://github.com/apache-hb updated https://github.com/llvm/llvm-project/pull/86426 >From 245a21512d8658225b17b91b8af4764f54084e01 Mon Sep 17 00:00:00 2001 From: Elliot <35050275+apache...@users.noreply.github.com> Date: Sun, 24 Mar 2024 03:03:47 -0400 Subject: [PATCH 1/4] Match against all plugins when parsing microsoft attributes fixes #86422 --- clang/lib/Parse/ParseDeclCXX.cpp | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 63fe678cbb29e2..d05b3a455f7f63 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -5061,11 +5061,12 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes ) { IdentifierInfo *II = Tok.getIdentifierInfo(); SourceLocation NameLoc = Tok.getLocation(); ConsumeToken(); -ParsedAttr::Kind AttrKind = -ParsedAttr::getParsedKind(II, nullptr, ParsedAttr::AS_Microsoft); + // For HLSL we want to handle all attributes, but for MSVC compat, we // silently ignore unknown Microsoft attributes. -if (getLangOpts().HLSL || AttrKind != ParsedAttr::UnknownAttribute) { +AttributeCommonInfo Info{II, NameLoc, AttributeCommonInfo::Form::Microsoft()}; +const ParsedAttrInfo& AttrInfo = ParsedAttrInfo::get(Info); +if (getLangOpts().HLSL || AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, II->getName())) { bool AttrParsed = false; if (Tok.is(tok::l_paren)) { CachedTokens OpenMPTokens; >From 4e47899a9fb17dec5931007b5025f6ce97dbe3eb Mon Sep 17 00:00:00 2001 From: Elliot <35050275+apache...@users.noreply.github.com> Date: Sun, 24 Mar 2024 03:05:54 -0400 Subject: [PATCH 2/4] Apply formatting --- clang/lib/Parse/ParseDeclCXX.cpp | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index d05b3a455f7f63..856ac11f7bb839 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -5064,9 +5064,12 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes ) { // For HLSL we want to handle all attributes, but for MSVC compat, we // silently ignore unknown Microsoft attributes. -AttributeCommonInfo Info{II, NameLoc, AttributeCommonInfo::Form::Microsoft()}; -const ParsedAttrInfo& AttrInfo = ParsedAttrInfo::get(Info); -if (getLangOpts().HLSL || AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, II->getName())) { +AttributeCommonInfo Info{II, NameLoc, + AttributeCommonInfo::Form::Microsoft()}; +const ParsedAttrInfo = ParsedAttrInfo::get(Info); +if (getLangOpts().HLSL || +AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, + II->getName())) { bool AttrParsed = false; if (Tok.is(tok::l_paren)) { CachedTokens OpenMPTokens; >From 8adb5bc07dd23afac4f66f6658a4197fb97f058f Mon Sep 17 00:00:00 2001 From: Elliot <35050275+apache...@users.noreply.github.com> Date: Mon, 25 Mar 2024 13:37:00 -0400 Subject: [PATCH 3/4] use hasAttribute instead of ParsedAttrInfo::get --- clang/lib/Parse/ParseDeclCXX.cpp | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 856ac11f7bb839..619f7f88bfdbfe 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -5064,12 +5064,9 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes ) { // For HLSL we want to handle all attributes, but for MSVC compat, we // silently ignore unknown Microsoft attributes. -AttributeCommonInfo Info{II, NameLoc, - AttributeCommonInfo::Form::Microsoft()}; -const ParsedAttrInfo = ParsedAttrInfo::get(Info); -if (getLangOpts().HLSL || -AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, - II->getName())) { +int Attr = hasAttribute(AttributeCommonInfo::Syntax::AS_Microsoft, nullptr, +II, getTargetInfo(), getLangOpts()); +if (getLangOpts().HLSL || Attr != 0) { bool AttrParsed = false; if (Tok.is(tok::l_paren)) { CachedTokens OpenMPTokens; >From b3f297eec02643452a8815d7d62b1b5a0f07760b Mon Sep 17 00:00:00 2001 From: Elliot <35050275+apache...@users.noreply.github.com> Date: Mon, 25 Mar 2024 13:54:27 -0400 Subject: [PATCH 4/4] Update ReleaseNotes.rst --- clang/docs/ReleaseNotes.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 8054d90fc70f93..df73abb12e89fa 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -345,6 +345,9 @@ Bug Fixes to Compiler Builtins
[clang] Match against all plugins when parsing microsoft attributes (PR #86426)
@@ -5061,11 +5061,15 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes ) { IdentifierInfo *II = Tok.getIdentifierInfo(); SourceLocation NameLoc = Tok.getLocation(); ConsumeToken(); -ParsedAttr::Kind AttrKind = -ParsedAttr::getParsedKind(II, nullptr, ParsedAttr::AS_Microsoft); + // For HLSL we want to handle all attributes, but for MSVC compat, we // silently ignore unknown Microsoft attributes. -if (getLangOpts().HLSL || AttrKind != ParsedAttr::UnknownAttribute) { +AttributeCommonInfo Info{II, NameLoc, + AttributeCommonInfo::Form::Microsoft()}; +const ParsedAttrInfo = ParsedAttrInfo::get(Info); +if (getLangOpts().HLSL || +AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, + II->getName())) { AaronBallman wrote: Yeah, something seems off here. If the plugin registers the attribute properly, I think the attribute kind won't be `UnknownAttribute` (IIRC it defaults to `NoSemaHandlerAttribute` unless you specify your own kind) so I would have expected to enter this block anyway. https://github.com/llvm/llvm-project/pull/86426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Match against all plugins when parsing microsoft attributes (PR #86426)
https://github.com/Sirraide edited https://github.com/llvm/llvm-project/pull/86426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Match against all plugins when parsing microsoft attributes (PR #86426)
@@ -5061,11 +5061,15 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes ) { IdentifierInfo *II = Tok.getIdentifierInfo(); SourceLocation NameLoc = Tok.getLocation(); ConsumeToken(); -ParsedAttr::Kind AttrKind = -ParsedAttr::getParsedKind(II, nullptr, ParsedAttr::AS_Microsoft); + // For HLSL we want to handle all attributes, but for MSVC compat, we // silently ignore unknown Microsoft attributes. -if (getLangOpts().HLSL || AttrKind != ParsedAttr::UnknownAttribute) { +AttributeCommonInfo Info{II, NameLoc, + AttributeCommonInfo::Form::Microsoft()}; +const ParsedAttrInfo = ParsedAttrInfo::get(Info); +if (getLangOpts().HLSL || +AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, + II->getName())) { Sirraide wrote: Hmm, I can’t find a place where we’re doing anything like this here for the other syntaxes, so I’m not sure this is the right approach. `hasAttribute()` from `clang/Basic/Attributes.h` seems to do what you’re trying to do here; have you tried using that one? https://github.com/llvm/llvm-project/pull/86426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Match against all plugins when parsing microsoft attributes (PR #86426)
https://github.com/Sirraide edited https://github.com/llvm/llvm-project/pull/86426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Match against all plugins when parsing microsoft attributes (PR #86426)
https://github.com/Sirraide commented: In addition to the comment above, this also needs a release note as well as some tests. Also, as the bot has already pointed out, you need to set your email address to public. https://github.com/llvm/llvm-project/pull/86426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Match against all plugins when parsing microsoft attributes (PR #86426)
https://github.com/apache-hb updated https://github.com/llvm/llvm-project/pull/86426 >From 245a21512d8658225b17b91b8af4764f54084e01 Mon Sep 17 00:00:00 2001 From: Elliot <35050275+apache...@users.noreply.github.com> Date: Sun, 24 Mar 2024 03:03:47 -0400 Subject: [PATCH 1/2] Match against all plugins when parsing microsoft attributes fixes #86422 --- clang/lib/Parse/ParseDeclCXX.cpp | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 63fe678cbb29e2..d05b3a455f7f63 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -5061,11 +5061,12 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes ) { IdentifierInfo *II = Tok.getIdentifierInfo(); SourceLocation NameLoc = Tok.getLocation(); ConsumeToken(); -ParsedAttr::Kind AttrKind = -ParsedAttr::getParsedKind(II, nullptr, ParsedAttr::AS_Microsoft); + // For HLSL we want to handle all attributes, but for MSVC compat, we // silently ignore unknown Microsoft attributes. -if (getLangOpts().HLSL || AttrKind != ParsedAttr::UnknownAttribute) { +AttributeCommonInfo Info{II, NameLoc, AttributeCommonInfo::Form::Microsoft()}; +const ParsedAttrInfo& AttrInfo = ParsedAttrInfo::get(Info); +if (getLangOpts().HLSL || AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, II->getName())) { bool AttrParsed = false; if (Tok.is(tok::l_paren)) { CachedTokens OpenMPTokens; >From 4e47899a9fb17dec5931007b5025f6ce97dbe3eb Mon Sep 17 00:00:00 2001 From: Elliot <35050275+apache...@users.noreply.github.com> Date: Sun, 24 Mar 2024 03:05:54 -0400 Subject: [PATCH 2/2] Apply formatting --- clang/lib/Parse/ParseDeclCXX.cpp | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index d05b3a455f7f63..856ac11f7bb839 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -5064,9 +5064,12 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes ) { // For HLSL we want to handle all attributes, but for MSVC compat, we // silently ignore unknown Microsoft attributes. -AttributeCommonInfo Info{II, NameLoc, AttributeCommonInfo::Form::Microsoft()}; -const ParsedAttrInfo& AttrInfo = ParsedAttrInfo::get(Info); -if (getLangOpts().HLSL || AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, II->getName())) { +AttributeCommonInfo Info{II, NameLoc, + AttributeCommonInfo::Form::Microsoft()}; +const ParsedAttrInfo = ParsedAttrInfo::get(Info); +if (getLangOpts().HLSL || +AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, + II->getName())) { bool AttrParsed = false; if (Tok.is(tok::l_paren)) { CachedTokens OpenMPTokens; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Match against all plugins when parsing microsoft attributes (PR #86426)
github-actions[bot] wrote: ⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo. Please turn off [Keep my email addresses private](https://github.com/settings/emails) setting in your account. See [LLVM Discourse](https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it) for more information. https://github.com/llvm/llvm-project/pull/86426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Match against all plugins when parsing microsoft attributes (PR #86426)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Elliot (apache-hb) Changes Fixes #86422 --- Full diff: https://github.com/llvm/llvm-project/pull/86426.diff 1 Files Affected: - (modified) clang/lib/Parse/ParseDeclCXX.cpp (+4-3) ``diff diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 63fe678cbb29e2..d05b3a455f7f63 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -5061,11 +5061,12 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes ) { IdentifierInfo *II = Tok.getIdentifierInfo(); SourceLocation NameLoc = Tok.getLocation(); ConsumeToken(); -ParsedAttr::Kind AttrKind = -ParsedAttr::getParsedKind(II, nullptr, ParsedAttr::AS_Microsoft); + // For HLSL we want to handle all attributes, but for MSVC compat, we // silently ignore unknown Microsoft attributes. -if (getLangOpts().HLSL || AttrKind != ParsedAttr::UnknownAttribute) { +AttributeCommonInfo Info{II, NameLoc, AttributeCommonInfo::Form::Microsoft()}; +const ParsedAttrInfo& AttrInfo = ParsedAttrInfo::get(Info); +if (getLangOpts().HLSL || AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, II->getName())) { bool AttrParsed = false; if (Tok.is(tok::l_paren)) { CachedTokens OpenMPTokens; `` https://github.com/llvm/llvm-project/pull/86426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Match against all plugins when parsing microsoft attributes (PR #86426)
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using `@` followed by their GitHub username. If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the [LLVM GitHub User Guide](https://llvm.org/docs/GitHub.html). You can also ask questions in a comment on this PR, on the [LLVM Discord](https://discord.com/invite/xS7Z362) or on the [forums](https://discourse.llvm.org/). https://github.com/llvm/llvm-project/pull/86426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Match against all plugins when parsing microsoft attributes (PR #86426)
https://github.com/apache-hb created https://github.com/llvm/llvm-project/pull/86426 Fixes #86422 >From 245a21512d8658225b17b91b8af4764f54084e01 Mon Sep 17 00:00:00 2001 From: Elliot <35050275+apache...@users.noreply.github.com> Date: Sun, 24 Mar 2024 03:03:47 -0400 Subject: [PATCH] Match against all plugins when parsing microsoft attributes fixes #86422 --- clang/lib/Parse/ParseDeclCXX.cpp | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 63fe678cbb29e2..d05b3a455f7f63 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -5061,11 +5061,12 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes ) { IdentifierInfo *II = Tok.getIdentifierInfo(); SourceLocation NameLoc = Tok.getLocation(); ConsumeToken(); -ParsedAttr::Kind AttrKind = -ParsedAttr::getParsedKind(II, nullptr, ParsedAttr::AS_Microsoft); + // For HLSL we want to handle all attributes, but for MSVC compat, we // silently ignore unknown Microsoft attributes. -if (getLangOpts().HLSL || AttrKind != ParsedAttr::UnknownAttribute) { +AttributeCommonInfo Info{II, NameLoc, AttributeCommonInfo::Form::Microsoft()}; +const ParsedAttrInfo& AttrInfo = ParsedAttrInfo::get(Info); +if (getLangOpts().HLSL || AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, II->getName())) { bool AttrParsed = false; if (Tok.is(tok::l_paren)) { CachedTokens OpenMPTokens; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits