Till created this revision. Till requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
When parsing unkown CXX11-style attributes, clang discards the argument lists, propably to skip over non-c++ expressions. However, it seems like this has not been updated for user-defined attributes using the ParsedAttrInfoRegistry (e.G. in clang/examples/Attribute/Attribute.cpp); clang::hasAttribute only returns a version number for builtin attributes. This uses ParsedAttrInfo::get to check if an attribute is known to the attribute registry, because this is currently the only place where these attributes are instanciated. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D102586 Files: clang/lib/Parse/ParseDeclCXX.cpp Index: clang/lib/Parse/ParseDeclCXX.cpp =================================================================== --- clang/lib/Parse/ParseDeclCXX.cpp +++ clang/lib/Parse/ParseDeclCXX.cpp @@ -4098,11 +4098,18 @@ const LangOptions &LO = getLangOpts(); ParsedAttr::Syntax Syntax = LO.CPlusPlus ? ParsedAttr::AS_CXX11 : ParsedAttr::AS_C2x; + bool IsKnownRegisteredAttribute = + ParsedAttrInfo::get(AttributeCommonInfo(AttrName, ScopeName, + SourceRange(LParenLoc, *EndLoc), + *EndLoc, + AttributeCommonInfo::AS_CXX11)) + .AttrKind != AttributeCommonInfo::UnknownAttribute; // If the attribute isn't known, we will not attempt to parse any // arguments. if (!hasAttribute(LO.CPlusPlus ? AttrSyntax::CXX : AttrSyntax::C, ScopeName, - AttrName, getTargetInfo(), getLangOpts())) { + AttrName, getTargetInfo(), getLangOpts()) && + !IsKnownRegisteredAttribute) { // Eat the left paren, then skip to the ending right paren. ConsumeParen(); SkipUntil(tok::r_paren);
Index: clang/lib/Parse/ParseDeclCXX.cpp =================================================================== --- clang/lib/Parse/ParseDeclCXX.cpp +++ clang/lib/Parse/ParseDeclCXX.cpp @@ -4098,11 +4098,18 @@ const LangOptions &LO = getLangOpts(); ParsedAttr::Syntax Syntax = LO.CPlusPlus ? ParsedAttr::AS_CXX11 : ParsedAttr::AS_C2x; + bool IsKnownRegisteredAttribute = + ParsedAttrInfo::get(AttributeCommonInfo(AttrName, ScopeName, + SourceRange(LParenLoc, *EndLoc), + *EndLoc, + AttributeCommonInfo::AS_CXX11)) + .AttrKind != AttributeCommonInfo::UnknownAttribute; // If the attribute isn't known, we will not attempt to parse any // arguments. if (!hasAttribute(LO.CPlusPlus ? AttrSyntax::CXX : AttrSyntax::C, ScopeName, - AttrName, getTargetInfo(), getLangOpts())) { + AttrName, getTargetInfo(), getLangOpts()) && + !IsKnownRegisteredAttribute) { // Eat the left paren, then skip to the ending right paren. ConsumeParen(); SkipUntil(tok::r_paren);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits