@@ -314,64 +314,92 @@ void Parser::ParseGNUAttributes(ParsedAttributes &Attrs,
314
314
}
315
315
316
316
// / 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);
318
322
#define CLANG_ATTR_IDENTIFIER_ARG_LIST
319
- return llvm::StringSwitch<bool >(normalizeAttrName (II. getName ()) )
323
+ return llvm::StringSwitch<bool >(FullName )
320
324
#include " clang/Parse/AttrParserStringSwitches.inc"
321
- .Default (false );
325
+ .Default (false );
322
326
#undef CLANG_ATTR_IDENTIFIER_ARG_LIST
323
327
}
324
328
325
329
// / Determine whether the given attribute has an identifier argument.
326
330
static 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);
328
336
#define CLANG_ATTR_STRING_LITERAL_ARG_LIST
329
- return llvm::StringSwitch<uint32_t >(normalizeAttrName (II. getName ()) )
337
+ return llvm::StringSwitch<uint32_t >(FullName )
330
338
#include " clang/Parse/AttrParserStringSwitches.inc"
331
339
.Default (0 );
332
340
#undef CLANG_ATTR_STRING_LITERAL_ARG_LIST
333
341
}
334
342
335
343
// / 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);
337
349
#define CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST
338
- return llvm::StringSwitch<bool >(normalizeAttrName (II. getName ()) )
350
+ return llvm::StringSwitch<bool >(FullName )
339
351
#include " clang/Parse/AttrParserStringSwitches.inc"
340
- .Default (false );
352
+ .Default (false );
341
353
#undef CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST
342
354
}
343
355
344
356
// / 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);
346
362
#define CLANG_ATTR_THIS_ISA_IDENTIFIER_ARG_LIST
347
- return llvm::StringSwitch<bool >(normalizeAttrName (II. getName ()) )
363
+ return llvm::StringSwitch<bool >(FullName )
348
364
#include " clang/Parse/AttrParserStringSwitches.inc"
349
- .Default (false );
365
+ .Default (false );
350
366
#undef CLANG_ATTR_THIS_ISA_IDENTIFIER_ARG_LIST
351
367
}
352
368
353
369
// / 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);
355
375
#define CLANG_ATTR_ACCEPTS_EXPR_PACK
356
- return llvm::StringSwitch<bool >(normalizeAttrName (II. getName ()) )
376
+ return llvm::StringSwitch<bool >(FullName )
357
377
#include " clang/Parse/AttrParserStringSwitches.inc"
358
378
.Default (false );
359
379
#undef CLANG_ATTR_ACCEPTS_EXPR_PACK
360
380
}
361
381
362
382
// / 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);
364
388
#define CLANG_ATTR_TYPE_ARG_LIST
365
- return llvm::StringSwitch<bool >(normalizeAttrName (II. getName ()) )
389
+ return llvm::StringSwitch<bool >(FullName )
366
390
#include " clang/Parse/AttrParserStringSwitches.inc"
367
- .Default (false );
391
+ .Default (false );
368
392
#undef CLANG_ATTR_TYPE_ARG_LIST
369
393
}
370
394
371
395
// / 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);
373
401
#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 )
375
403
#include " clang/Parse/AttrParserStringSwitches.inc"
376
404
.Default (0 )) != 0 ;
377
405
#undef CLANG_ATTR_STRICT_IDENTIFIER_ARG_AT_INDEX_LIST
@@ -380,9 +408,13 @@ static bool attributeHasStrictIdentifierArgs(const IdentifierInfo &II) {
380
408
// / Determine whether the given attribute takes an identifier argument at a
381
409
// / specific index
382
410
static bool attributeHasStrictIdentifierArgAtIndex (const IdentifierInfo &II,
411
+ ParsedAttr::Syntax Syntax,
412
+ IdentifierInfo *ScopeName,
383
413
size_t argIndex) {
414
+ std::string FullName =
415
+ AttributeCommonInfo::normalizeFullNameWithSyntax (&II, ScopeName, Syntax);
384
416
#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 )
386
418
#include " clang/Parse/AttrParserStringSwitches.inc"
387
419
.Default (0 )) &
388
420
(1ull << argIndex);
@@ -391,11 +423,15 @@ static bool attributeHasStrictIdentifierArgAtIndex(const IdentifierInfo &II,
391
423
392
424
// / Determine whether the given attribute requires parsing its arguments
393
425
// / 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);
395
431
#define CLANG_ATTR_ARG_CONTEXT_LIST
396
- return llvm::StringSwitch<bool >(normalizeAttrName (II. getName ()) )
432
+ return llvm::StringSwitch<bool >(FullName )
397
433
#include " clang/Parse/AttrParserStringSwitches.inc"
398
- .Default (false );
434
+ .Default (false );
399
435
#undef CLANG_ATTR_ARG_CONTEXT_LIST
400
436
}
401
437
@@ -523,10 +559,12 @@ unsigned Parser::ParseAttributeArgsCommon(
523
559
// Ignore the left paren location for now.
524
560
ConsumeParen ();
525
561
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);
528
566
bool AttributeHasVariadicIdentifierArg =
529
- attributeHasVariadicIdentifierArg (*AttrName);
567
+ attributeHasVariadicIdentifierArg (*AttrName, Form. getSyntax (), ScopeName );
530
568
531
569
// Interpret "kw_this" as an identifier if the attributed requests it.
532
570
if (ChangeKWThisToIdent && Tok.is (tok::kw_this))
@@ -535,8 +573,9 @@ unsigned Parser::ParseAttributeArgsCommon(
535
573
ArgsVector ArgExprs;
536
574
if (Tok.is (tok::identifier)) {
537
575
// 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);
540
579
ParsedAttr::Kind AttrKind =
541
580
ParsedAttr::getParsedKind (AttrName, ScopeName, Form.getSyntax ());
542
581
@@ -568,7 +607,8 @@ unsigned Parser::ParseAttributeArgsCommon(
568
607
if (T.isUsable ())
569
608
TheParsedType = T.get ();
570
609
} else if (AttributeHasVariadicIdentifierArg ||
571
- attributeHasStrictIdentifierArgs (*AttrName)) {
610
+ attributeHasStrictIdentifierArgs (*AttrName, Form.getSyntax (),
611
+ ScopeName)) {
572
612
// Parse variadic identifier arg. This can either consume identifiers or
573
613
// expressions. Variadic identifier args do not support parameter packs
574
614
// because those are typically used for attributes with enumeration
@@ -579,8 +619,9 @@ unsigned Parser::ParseAttributeArgsCommon(
579
619
if (ChangeKWThisToIdent && Tok.is (tok::kw_this))
580
620
Tok.setKind (tok::identifier);
581
621
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 ())) {
584
625
ArgExprs.push_back (ParseIdentifierLoc ());
585
626
continue ;
586
627
}
@@ -589,7 +630,8 @@ unsigned Parser::ParseAttributeArgsCommon(
589
630
if (Tok.is (tok::identifier)) {
590
631
ArgExprs.push_back (ParseIdentifierLoc ());
591
632
} else {
592
- bool Uneval = attributeParsedArgsUnevaluated (*AttrName);
633
+ bool Uneval = attributeParsedArgsUnevaluated (
634
+ *AttrName, Form.getSyntax (), ScopeName);
593
635
EnterExpressionEvaluationContext Unevaluated (
594
636
Actions,
595
637
Uneval ? Sema::ExpressionEvaluationContext::Unevaluated
@@ -610,7 +652,8 @@ unsigned Parser::ParseAttributeArgsCommon(
610
652
} while (TryConsumeToken (tok::comma));
611
653
} else {
612
654
// General case. Parse all available expressions.
613
- bool Uneval = attributeParsedArgsUnevaluated (*AttrName);
655
+ bool Uneval = attributeParsedArgsUnevaluated (*AttrName, Form.getSyntax (),
656
+ ScopeName);
614
657
EnterExpressionEvaluationContext Unevaluated (
615
658
Actions,
616
659
Uneval ? Sema::ExpressionEvaluationContext::Unevaluated
@@ -621,7 +664,8 @@ unsigned Parser::ParseAttributeArgsCommon(
621
664
622
665
ExprVector ParsedExprs;
623
666
ParsedAttributeArgumentsProperties ArgProperties =
624
- attributeStringLiteralListArg (getTargetInfo ().getTriple (), *AttrName);
667
+ attributeStringLiteralListArg (getTargetInfo ().getTriple (), *AttrName,
668
+ Form.getSyntax (), ScopeName);
625
669
if (ParseAttributeArgumentList (*AttrName, ParsedExprs, ArgProperties)) {
626
670
SkipUntil (tok::r_paren, StopAtSemi);
627
671
return 0 ;
@@ -632,7 +676,7 @@ unsigned Parser::ParseAttributeArgsCommon(
632
676
if (!isa<PackExpansionExpr>(ParsedExprs[I]))
633
677
continue ;
634
678
635
- if (!attributeAcceptsExprPack (*AttrName)) {
679
+ if (!attributeAcceptsExprPack (*AttrName, Form. getSyntax (), ScopeName )) {
636
680
Diag (Tok.getLocation (),
637
681
diag::err_attribute_argument_parm_pack_not_supported)
638
682
<< AttrName;
@@ -696,7 +740,7 @@ void Parser::ParseGNUAttributeArgs(
696
740
ParseTypeTagForDatatypeAttribute (*AttrName, AttrNameLoc, Attrs, EndLoc,
697
741
ScopeName, ScopeLoc, Form);
698
742
return ;
699
- } else if (attributeIsTypeArgAttr (*AttrName)) {
743
+ } else if (attributeIsTypeArgAttr (*AttrName, Form. getSyntax (), ScopeName )) {
700
744
ParseAttributeWithTypeArg (*AttrName, AttrNameLoc, Attrs, ScopeName,
701
745
ScopeLoc, Form);
702
746
return ;
0 commit comments