@@ -314,64 +314,92 @@ void Parser::ParseGNUAttributes(ParsedAttributes &Attrs,
314314}
315315
316316// / Determine whether the given attribute has an identifier argument.
317- static bool attributeHasIdentifierArg (const IdentifierInfo &II) {
317+ static bool attributeHasIdentifierArg (const IdentifierInfo &II,
318+ ParsedAttr::Syntax Syntax,
319+ IdentifierInfo *ScopeName) {
320+ std::string FullName =
321+ AttributeCommonInfo::normalizeFullNameWithSyntax (&II, ScopeName, Syntax);
318322#define CLANG_ATTR_IDENTIFIER_ARG_LIST
319- return llvm::StringSwitch<bool >(normalizeAttrName (II. getName ()) )
323+ return llvm::StringSwitch<bool >(FullName )
320324#include " clang/Parse/AttrParserStringSwitches.inc"
321- .Default (false );
325+ .Default (false );
322326#undef CLANG_ATTR_IDENTIFIER_ARG_LIST
323327}
324328
325329// / Determine whether the given attribute has an identifier argument.
326330static ParsedAttributeArgumentsProperties
327- attributeStringLiteralListArg (const llvm::Triple &T, const IdentifierInfo &II) {
331+ attributeStringLiteralListArg (const llvm::Triple &T, const IdentifierInfo &II,
332+ ParsedAttr::Syntax Syntax,
333+ IdentifierInfo *ScopeName) {
334+ std::string FullName =
335+ AttributeCommonInfo::normalizeFullNameWithSyntax (&II, ScopeName, Syntax);
328336#define CLANG_ATTR_STRING_LITERAL_ARG_LIST
329- return llvm::StringSwitch<uint32_t >(normalizeAttrName (II. getName ()) )
337+ return llvm::StringSwitch<uint32_t >(FullName )
330338#include " clang/Parse/AttrParserStringSwitches.inc"
331339 .Default (0 );
332340#undef CLANG_ATTR_STRING_LITERAL_ARG_LIST
333341}
334342
335343// / Determine whether the given attribute has a variadic identifier argument.
336- static bool attributeHasVariadicIdentifierArg (const IdentifierInfo &II) {
344+ static bool attributeHasVariadicIdentifierArg (const IdentifierInfo &II,
345+ ParsedAttr::Syntax Syntax,
346+ IdentifierInfo *ScopeName) {
347+ std::string FullName =
348+ AttributeCommonInfo::normalizeFullNameWithSyntax (&II, ScopeName, Syntax);
337349#define CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST
338- return llvm::StringSwitch<bool >(normalizeAttrName (II. getName ()) )
350+ return llvm::StringSwitch<bool >(FullName )
339351#include " clang/Parse/AttrParserStringSwitches.inc"
340- .Default (false );
352+ .Default (false );
341353#undef CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST
342354}
343355
344356// / Determine whether the given attribute treats kw_this as an identifier.
345- static bool attributeTreatsKeywordThisAsIdentifier (const IdentifierInfo &II) {
357+ static bool attributeTreatsKeywordThisAsIdentifier (const IdentifierInfo &II,
358+ ParsedAttr::Syntax Syntax,
359+ IdentifierInfo *ScopeName) {
360+ std::string FullName =
361+ AttributeCommonInfo::normalizeFullNameWithSyntax (&II, ScopeName, Syntax);
346362#define CLANG_ATTR_THIS_ISA_IDENTIFIER_ARG_LIST
347- return llvm::StringSwitch<bool >(normalizeAttrName (II. getName ()) )
363+ return llvm::StringSwitch<bool >(FullName )
348364#include " clang/Parse/AttrParserStringSwitches.inc"
349- .Default (false );
365+ .Default (false );
350366#undef CLANG_ATTR_THIS_ISA_IDENTIFIER_ARG_LIST
351367}
352368
353369// / Determine if an attribute accepts parameter packs.
354- static bool attributeAcceptsExprPack (const IdentifierInfo &II) {
370+ static bool attributeAcceptsExprPack (const IdentifierInfo &II,
371+ ParsedAttr::Syntax Syntax,
372+ IdentifierInfo *ScopeName) {
373+ std::string FullName =
374+ AttributeCommonInfo::normalizeFullNameWithSyntax (&II, ScopeName, Syntax);
355375#define CLANG_ATTR_ACCEPTS_EXPR_PACK
356- return llvm::StringSwitch<bool >(normalizeAttrName (II. getName ()) )
376+ return llvm::StringSwitch<bool >(FullName )
357377#include " clang/Parse/AttrParserStringSwitches.inc"
358378 .Default (false );
359379#undef CLANG_ATTR_ACCEPTS_EXPR_PACK
360380}
361381
362382// / Determine whether the given attribute parses a type argument.
363- static bool attributeIsTypeArgAttr (const IdentifierInfo &II) {
383+ static bool attributeIsTypeArgAttr (const IdentifierInfo &II,
384+ ParsedAttr::Syntax Syntax,
385+ IdentifierInfo *ScopeName) {
386+ std::string FullName =
387+ AttributeCommonInfo::normalizeFullNameWithSyntax (&II, ScopeName, Syntax);
364388#define CLANG_ATTR_TYPE_ARG_LIST
365- return llvm::StringSwitch<bool >(normalizeAttrName (II. getName ()) )
389+ return llvm::StringSwitch<bool >(FullName )
366390#include " clang/Parse/AttrParserStringSwitches.inc"
367- .Default (false );
391+ .Default (false );
368392#undef CLANG_ATTR_TYPE_ARG_LIST
369393}
370394
371395// / Determine whether the given attribute takes identifier arguments.
372- static bool attributeHasStrictIdentifierArgs (const IdentifierInfo &II) {
396+ static bool attributeHasStrictIdentifierArgs (const IdentifierInfo &II,
397+ ParsedAttr::Syntax Syntax,
398+ IdentifierInfo *ScopeName) {
399+ std::string FullName =
400+ AttributeCommonInfo::normalizeFullNameWithSyntax (&II, ScopeName, Syntax);
373401#define CLANG_ATTR_STRICT_IDENTIFIER_ARG_AT_INDEX_LIST
374- return (llvm::StringSwitch<uint64_t >(normalizeAttrName (II. getName ()) )
402+ return (llvm::StringSwitch<uint64_t >(FullName )
375403#include " clang/Parse/AttrParserStringSwitches.inc"
376404 .Default (0 )) != 0 ;
377405#undef CLANG_ATTR_STRICT_IDENTIFIER_ARG_AT_INDEX_LIST
@@ -380,9 +408,13 @@ static bool attributeHasStrictIdentifierArgs(const IdentifierInfo &II) {
380408// / Determine whether the given attribute takes an identifier argument at a
381409// / specific index
382410static bool attributeHasStrictIdentifierArgAtIndex (const IdentifierInfo &II,
411+ ParsedAttr::Syntax Syntax,
412+ IdentifierInfo *ScopeName,
383413 size_t argIndex) {
414+ std::string FullName =
415+ AttributeCommonInfo::normalizeFullNameWithSyntax (&II, ScopeName, Syntax);
384416#define CLANG_ATTR_STRICT_IDENTIFIER_ARG_AT_INDEX_LIST
385- return (llvm::StringSwitch<uint64_t >(normalizeAttrName (II. getName ()) )
417+ return (llvm::StringSwitch<uint64_t >(FullName )
386418#include " clang/Parse/AttrParserStringSwitches.inc"
387419 .Default (0 )) &
388420 (1ull << argIndex);
@@ -391,11 +423,15 @@ static bool attributeHasStrictIdentifierArgAtIndex(const IdentifierInfo &II,
391423
392424// / Determine whether the given attribute requires parsing its arguments
393425// / in an unevaluated context or not.
394- static bool attributeParsedArgsUnevaluated (const IdentifierInfo &II) {
426+ static bool attributeParsedArgsUnevaluated (const IdentifierInfo &II,
427+ ParsedAttr::Syntax Syntax,
428+ IdentifierInfo *ScopeName) {
429+ std::string FullName =
430+ AttributeCommonInfo::normalizeFullNameWithSyntax (&II, ScopeName, Syntax);
395431#define CLANG_ATTR_ARG_CONTEXT_LIST
396- return llvm::StringSwitch<bool >(normalizeAttrName (II. getName ()) )
432+ return llvm::StringSwitch<bool >(FullName )
397433#include " clang/Parse/AttrParserStringSwitches.inc"
398- .Default (false );
434+ .Default (false );
399435#undef CLANG_ATTR_ARG_CONTEXT_LIST
400436}
401437
@@ -523,10 +559,12 @@ unsigned Parser::ParseAttributeArgsCommon(
523559 // Ignore the left paren location for now.
524560 ConsumeParen ();
525561
526- bool ChangeKWThisToIdent = attributeTreatsKeywordThisAsIdentifier (*AttrName);
527- bool AttributeIsTypeArgAttr = attributeIsTypeArgAttr (*AttrName);
562+ bool ChangeKWThisToIdent = attributeTreatsKeywordThisAsIdentifier (
563+ *AttrName, Form.getSyntax (), ScopeName);
564+ bool AttributeIsTypeArgAttr =
565+ attributeIsTypeArgAttr (*AttrName, Form.getSyntax (), ScopeName);
528566 bool AttributeHasVariadicIdentifierArg =
529- attributeHasVariadicIdentifierArg (*AttrName);
567+ attributeHasVariadicIdentifierArg (*AttrName, Form. getSyntax (), ScopeName );
530568
531569 // Interpret "kw_this" as an identifier if the attributed requests it.
532570 if (ChangeKWThisToIdent && Tok.is (tok::kw_this))
@@ -535,8 +573,9 @@ unsigned Parser::ParseAttributeArgsCommon(
535573 ArgsVector ArgExprs;
536574 if (Tok.is (tok::identifier)) {
537575 // If this attribute wants an 'identifier' argument, make it so.
538- bool IsIdentifierArg = AttributeHasVariadicIdentifierArg ||
539- attributeHasIdentifierArg (*AttrName);
576+ bool IsIdentifierArg =
577+ AttributeHasVariadicIdentifierArg ||
578+ attributeHasIdentifierArg (*AttrName, Form.getSyntax (), ScopeName);
540579 ParsedAttr::Kind AttrKind =
541580 ParsedAttr::getParsedKind (AttrName, ScopeName, Form.getSyntax ());
542581
@@ -568,7 +607,8 @@ unsigned Parser::ParseAttributeArgsCommon(
568607 if (T.isUsable ())
569608 TheParsedType = T.get ();
570609 } else if (AttributeHasVariadicIdentifierArg ||
571- attributeHasStrictIdentifierArgs (*AttrName)) {
610+ attributeHasStrictIdentifierArgs (*AttrName, Form.getSyntax (),
611+ ScopeName)) {
572612 // Parse variadic identifier arg. This can either consume identifiers or
573613 // expressions. Variadic identifier args do not support parameter packs
574614 // because those are typically used for attributes with enumeration
@@ -579,8 +619,9 @@ unsigned Parser::ParseAttributeArgsCommon(
579619 if (ChangeKWThisToIdent && Tok.is (tok::kw_this))
580620 Tok.setKind (tok::identifier);
581621
582- if (Tok.is (tok::identifier) && attributeHasStrictIdentifierArgAtIndex (
583- *AttrName, ArgExprs.size ())) {
622+ if (Tok.is (tok::identifier) &&
623+ attributeHasStrictIdentifierArgAtIndex (
624+ *AttrName, Form.getSyntax (), ScopeName, ArgExprs.size ())) {
584625 ArgExprs.push_back (ParseIdentifierLoc ());
585626 continue ;
586627 }
@@ -589,7 +630,8 @@ unsigned Parser::ParseAttributeArgsCommon(
589630 if (Tok.is (tok::identifier)) {
590631 ArgExprs.push_back (ParseIdentifierLoc ());
591632 } else {
592- bool Uneval = attributeParsedArgsUnevaluated (*AttrName);
633+ bool Uneval = attributeParsedArgsUnevaluated (
634+ *AttrName, Form.getSyntax (), ScopeName);
593635 EnterExpressionEvaluationContext Unevaluated (
594636 Actions,
595637 Uneval ? Sema::ExpressionEvaluationContext::Unevaluated
@@ -610,7 +652,8 @@ unsigned Parser::ParseAttributeArgsCommon(
610652 } while (TryConsumeToken (tok::comma));
611653 } else {
612654 // General case. Parse all available expressions.
613- bool Uneval = attributeParsedArgsUnevaluated (*AttrName);
655+ bool Uneval = attributeParsedArgsUnevaluated (*AttrName, Form.getSyntax (),
656+ ScopeName);
614657 EnterExpressionEvaluationContext Unevaluated (
615658 Actions,
616659 Uneval ? Sema::ExpressionEvaluationContext::Unevaluated
@@ -621,7 +664,8 @@ unsigned Parser::ParseAttributeArgsCommon(
621664
622665 ExprVector ParsedExprs;
623666 ParsedAttributeArgumentsProperties ArgProperties =
624- attributeStringLiteralListArg (getTargetInfo ().getTriple (), *AttrName);
667+ attributeStringLiteralListArg (getTargetInfo ().getTriple (), *AttrName,
668+ Form.getSyntax (), ScopeName);
625669 if (ParseAttributeArgumentList (*AttrName, ParsedExprs, ArgProperties)) {
626670 SkipUntil (tok::r_paren, StopAtSemi);
627671 return 0 ;
@@ -632,7 +676,7 @@ unsigned Parser::ParseAttributeArgsCommon(
632676 if (!isa<PackExpansionExpr>(ParsedExprs[I]))
633677 continue ;
634678
635- if (!attributeAcceptsExprPack (*AttrName)) {
679+ if (!attributeAcceptsExprPack (*AttrName, Form. getSyntax (), ScopeName )) {
636680 Diag (Tok.getLocation (),
637681 diag::err_attribute_argument_parm_pack_not_supported)
638682 << AttrName;
@@ -696,7 +740,7 @@ void Parser::ParseGNUAttributeArgs(
696740 ParseTypeTagForDatatypeAttribute (*AttrName, AttrNameLoc, Attrs, EndLoc,
697741 ScopeName, ScopeLoc, Form);
698742 return ;
699- } else if (attributeIsTypeArgAttr (*AttrName)) {
743+ } else if (attributeIsTypeArgAttr (*AttrName, Form. getSyntax (), ScopeName )) {
700744 ParseAttributeWithTypeArg (*AttrName, AttrNameLoc, Attrs, ScopeName,
701745 ScopeLoc, Form);
702746 return ;
0 commit comments