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 &Attrs) { 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 &Attrs) { // 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 &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 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 &Attrs) { // 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())) { + 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 Bug Fixes to Attribute Support ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- Clang now correctly matches plugin attributes with microsoft ``[attribute]`` syntax. + (#GH86422) + Bug Fixes to C++ Support ^^^^^^^^^^^^^^^^^^^^^^^^ _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits