@@ -314,27 +314,24 @@ 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 llvm::Triple &T,
318
+ const IdentifierInfo &II,
318
319
ParsedAttr::Syntax Syntax,
319
320
IdentifierInfo *ScopeName) {
320
- std::string FullName =
321
- AttributeCommonInfo::normalizeFullNameWithSyntax (&II, ScopeName, Syntax);
322
321
#define CLANG_ATTR_IDENTIFIER_ARG_LIST
323
- return llvm::StringSwitch<bool >(FullName )
322
+ return llvm::StringSwitch<bool >(normalizeAttrName (II. getName ()) )
324
323
#include " clang/Parse/AttrParserStringSwitches.inc"
325
324
.Default (false );
326
325
#undef CLANG_ATTR_IDENTIFIER_ARG_LIST
327
326
}
328
327
329
- // / Determine whether the given attribute has an identifier argument .
328
+ // / Determine whether the given attribute has string arguments .
330
329
static ParsedAttributeArgumentsProperties
331
330
attributeStringLiteralListArg (const llvm::Triple &T, const IdentifierInfo &II,
332
331
ParsedAttr::Syntax Syntax,
333
332
IdentifierInfo *ScopeName) {
334
- std::string FullName =
335
- AttributeCommonInfo::normalizeFullNameWithSyntax (&II, ScopeName, Syntax);
336
333
#define CLANG_ATTR_STRING_LITERAL_ARG_LIST
337
- return llvm::StringSwitch<uint32_t >(FullName )
334
+ return llvm::StringSwitch<uint32_t >(normalizeAttrName (II. getName ()) )
338
335
#include " clang/Parse/AttrParserStringSwitches.inc"
339
336
.Default (0 );
340
337
#undef CLANG_ATTR_STRING_LITERAL_ARG_LIST
@@ -344,10 +341,8 @@ attributeStringLiteralListArg(const llvm::Triple &T, const IdentifierInfo &II,
344
341
static bool attributeHasVariadicIdentifierArg (const IdentifierInfo &II,
345
342
ParsedAttr::Syntax Syntax,
346
343
IdentifierInfo *ScopeName) {
347
- std::string FullName =
348
- AttributeCommonInfo::normalizeFullNameWithSyntax (&II, ScopeName, Syntax);
349
344
#define CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST
350
- return llvm::StringSwitch<bool >(FullName )
345
+ return llvm::StringSwitch<bool >(normalizeAttrName (II. getName ()) )
351
346
#include " clang/Parse/AttrParserStringSwitches.inc"
352
347
.Default (false );
353
348
#undef CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST
@@ -357,10 +352,8 @@ static bool attributeHasVariadicIdentifierArg(const IdentifierInfo &II,
357
352
static bool attributeTreatsKeywordThisAsIdentifier (const IdentifierInfo &II,
358
353
ParsedAttr::Syntax Syntax,
359
354
IdentifierInfo *ScopeName) {
360
- std::string FullName =
361
- AttributeCommonInfo::normalizeFullNameWithSyntax (&II, ScopeName, Syntax);
362
355
#define CLANG_ATTR_THIS_ISA_IDENTIFIER_ARG_LIST
363
- return llvm::StringSwitch<bool >(FullName )
356
+ return llvm::StringSwitch<bool >(normalizeAttrName (II. getName ()) )
364
357
#include " clang/Parse/AttrParserStringSwitches.inc"
365
358
.Default (false );
366
359
#undef CLANG_ATTR_THIS_ISA_IDENTIFIER_ARG_LIST
@@ -370,10 +363,8 @@ static bool attributeTreatsKeywordThisAsIdentifier(const IdentifierInfo &II,
370
363
static bool attributeAcceptsExprPack (const IdentifierInfo &II,
371
364
ParsedAttr::Syntax Syntax,
372
365
IdentifierInfo *ScopeName) {
373
- std::string FullName =
374
- AttributeCommonInfo::normalizeFullNameWithSyntax (&II, ScopeName, Syntax);
375
366
#define CLANG_ATTR_ACCEPTS_EXPR_PACK
376
- return llvm::StringSwitch<bool >(FullName )
367
+ return llvm::StringSwitch<bool >(normalizeAttrName (II. getName ()) )
377
368
#include " clang/Parse/AttrParserStringSwitches.inc"
378
369
.Default (false );
379
370
#undef CLANG_ATTR_ACCEPTS_EXPR_PACK
@@ -383,53 +374,31 @@ static bool attributeAcceptsExprPack(const IdentifierInfo &II,
383
374
static bool attributeIsTypeArgAttr (const IdentifierInfo &II,
384
375
ParsedAttr::Syntax Syntax,
385
376
IdentifierInfo *ScopeName) {
386
- std::string FullName =
387
- AttributeCommonInfo::normalizeFullNameWithSyntax (&II, ScopeName, Syntax);
388
377
#define CLANG_ATTR_TYPE_ARG_LIST
389
- return llvm::StringSwitch<bool >(FullName )
378
+ return llvm::StringSwitch<bool >(normalizeAttrName (II. getName ()) )
390
379
#include " clang/Parse/AttrParserStringSwitches.inc"
391
380
.Default (false );
392
381
#undef CLANG_ATTR_TYPE_ARG_LIST
393
382
}
394
383
395
- // / Determine whether the given attribute takes identifier arguments .
384
+ // / Determine whether the given attribute takes a strict identifier argument .
396
385
static bool attributeHasStrictIdentifierArgs (const IdentifierInfo &II,
397
386
ParsedAttr::Syntax Syntax,
398
387
IdentifierInfo *ScopeName) {
399
- std::string FullName =
400
- AttributeCommonInfo::normalizeFullNameWithSyntax (&II, ScopeName, Syntax);
401
- #define CLANG_ATTR_STRICT_IDENTIFIER_ARG_AT_INDEX_LIST
402
- return (llvm::StringSwitch<uint64_t >(FullName)
403
- #include " clang/Parse/AttrParserStringSwitches.inc"
404
- .Default (0 )) != 0 ;
405
- #undef CLANG_ATTR_STRICT_IDENTIFIER_ARG_AT_INDEX_LIST
406
- }
407
-
408
- // / Determine whether the given attribute takes an identifier argument at a
409
- // / specific index
410
- static bool attributeHasStrictIdentifierArgAtIndex (const IdentifierInfo &II,
411
- ParsedAttr::Syntax Syntax,
412
- IdentifierInfo *ScopeName,
413
- size_t argIndex) {
414
- std::string FullName =
415
- AttributeCommonInfo::normalizeFullNameWithSyntax (&II, ScopeName, Syntax);
416
- #define CLANG_ATTR_STRICT_IDENTIFIER_ARG_AT_INDEX_LIST
417
- return (llvm::StringSwitch<uint64_t >(FullName)
388
+ #define CLANG_ATTR_STRICT_IDENTIFIER_ARG_LIST
389
+ return llvm::StringSwitch<bool >(normalizeAttrName (II.getName ()))
418
390
#include " clang/Parse/AttrParserStringSwitches.inc"
419
- .Default (0 )) &
420
- (1ull << argIndex);
421
- #undef CLANG_ATTR_STRICT_IDENTIFIER_ARG_AT_INDEX_LIST
391
+ .Default (false );
392
+ #undef CLANG_ATTR_STRICT_IDENTIFIER_ARG_LIST
422
393
}
423
394
424
395
// / Determine whether the given attribute requires parsing its arguments
425
396
// / in an unevaluated context or not.
426
397
static bool attributeParsedArgsUnevaluated (const IdentifierInfo &II,
427
398
ParsedAttr::Syntax Syntax,
428
399
IdentifierInfo *ScopeName) {
429
- std::string FullName =
430
- AttributeCommonInfo::normalizeFullNameWithSyntax (&II, ScopeName, Syntax);
431
400
#define CLANG_ATTR_ARG_CONTEXT_LIST
432
- return llvm::StringSwitch<bool >(FullName )
401
+ return llvm::StringSwitch<bool >(normalizeAttrName (II. getName ()) )
433
402
#include " clang/Parse/AttrParserStringSwitches.inc"
434
403
.Default (false );
435
404
#undef CLANG_ATTR_ARG_CONTEXT_LIST
@@ -575,7 +544,8 @@ unsigned Parser::ParseAttributeArgsCommon(
575
544
// If this attribute wants an 'identifier' argument, make it so.
576
545
bool IsIdentifierArg =
577
546
AttributeHasVariadicIdentifierArg ||
578
- attributeHasIdentifierArg (*AttrName, Form.getSyntax (), ScopeName);
547
+ attributeHasIdentifierArg (getTargetInfo ().getTriple (), *AttrName,
548
+ Form.getSyntax (), ScopeName);
579
549
ParsedAttr::Kind AttrKind =
580
550
ParsedAttr::getParsedKind (AttrName, ScopeName, Form.getSyntax ());
581
551
@@ -619,13 +589,6 @@ unsigned Parser::ParseAttributeArgsCommon(
619
589
if (ChangeKWThisToIdent && Tok.is (tok::kw_this))
620
590
Tok.setKind (tok::identifier);
621
591
622
- if (Tok.is (tok::identifier) &&
623
- attributeHasStrictIdentifierArgAtIndex (
624
- *AttrName, Form.getSyntax (), ScopeName, ArgExprs.size ())) {
625
- ArgExprs.push_back (ParseIdentifierLoc ());
626
- continue ;
627
- }
628
-
629
592
ExprResult ArgExpr;
630
593
if (Tok.is (tok::identifier)) {
631
594
ArgExprs.push_back (ParseIdentifierLoc ());
0 commit comments