@@ -1417,53 +1417,47 @@ bool Parser::HandlePragmaMSAllocText(StringRef PragmaName,
14171417 return true ;
14181418}
14191419
1420- NestedNameSpecifier *Parser::zOSParseIdentifier (StringRef PragmaName,
1421- const IdentifierInfo *IdentName ,
1422- SourceLocation &PrevLoc ) {
1420+ NestedNameSpecifier *
1421+ Parser::zOSParseIdentifier (StringRef PragmaName ,
1422+ const IdentifierInfo *IdentName ) {
14231423 NestedNameSpecifier *NestedId = nullptr ;
14241424 if (PP.getLangOpts ().CPlusPlus ) {
14251425 if (Tok.is (tok::coloncolon)) {
1426+ // Nothing to do.
14261427 } else if (Actions.CurContext ->isNamespace ()) {
14271428 auto *NS = cast<NamespaceDecl>(Actions.CurContext );
14281429 NestedId =
14291430 NestedNameSpecifier::Create (Actions.Context , NS->getIdentifier ());
14301431 NestedId =
14311432 NestedNameSpecifier::Create (Actions.Context , NestedId, IdentName);
1432- PrevLoc = Tok.getLocation ();
14331433 PP.Lex (Tok);
14341434 } else {
14351435 NestedId = NestedNameSpecifier::Create (Actions.Context , IdentName);
1436- PrevLoc = Tok.getLocation ();
14371436 PP.Lex (Tok);
14381437 }
14391438 while (Tok.is (tok::coloncolon)) {
1440- PrevLoc = Tok.getLocation ();
14411439 PP.Lex (Tok);
14421440 if (Tok.isNot (tok::identifier)) {
1443- PP.Diag (Tok.getLocation ().isValid () ? Tok.getLocation () : PrevLoc,
1444- diag::warn_pragma_expected_identifier)
1441+ PP.Diag (Tok.getLocation (), diag::warn_pragma_expected_identifier)
14451442 << PragmaName;
14461443 return nullptr ;
14471444 }
14481445 IdentifierInfo *II = Tok.getIdentifierInfo ();
14491446 NestedId = NestedNameSpecifier::Create (Actions.Context , NestedId, II);
1450- PrevLoc = Tok.getLocation ();
14511447 PP.Lex (Tok);
14521448 }
14531449 } else {
14541450 NestedId = NestedNameSpecifier::Create (Actions.Context , IdentName);
1455- PrevLoc = Tok.getLocation ();
14561451 PP.Lex (Tok);
14571452 }
14581453 return NestedId;
14591454}
14601455
14611456bool Parser::zOSParseParameterList (
14621457 StringRef PragmaName, std::optional<SmallVector<QualType, 4 >> &TypeList,
1463- Qualifiers &CVQual, SourceLocation &PrevLoc ) {
1458+ Qualifiers &CVQual) {
14641459 if (Tok.is (tok::l_paren)) {
14651460 TypeList = SmallVector<QualType, 4 >();
1466- PrevLoc = Tok.getLocation ();
14671461 PP.Lex (Tok);
14681462 while (Tok.isNot (tok::eof) && !Tok.is (tok::r_paren)) {
14691463 TypeResult TResult = ParseTypeName (nullptr );
@@ -1473,18 +1467,16 @@ bool Parser::zOSParseParameterList(
14731467 TypeList->push_back (QT);
14741468 }
14751469 }
1476- if (Tok.is (tok::comma) || Tok.is (tok::identifier)) {
1477- PrevLoc = Tok.getLocation ();
1470+ if (Tok.is (tok::comma) || Tok.is (tok::identifier))
14781471 PP.Lex (Tok);
1479- }
14801472 }
1481- if (Tok.is (tok::r_paren)) {
1482- PrevLoc = Tok.getLocation ();
1473+ if (Tok.is (tok::r_paren))
14831474 PP.Lex (Tok);
1484- } else {
1475+ else {
14851476 // We ate the whole line trying to find the right paren of the parameter
1486- // list
1487- PP.Diag (PrevLoc, diag::warn_pragma_expected_identifier) << PragmaName;
1477+ // list.
1478+ PP.Diag (Tok.getLocation (), diag::warn_pragma_expected_identifier)
1479+ << PragmaName;
14881480 return false ;
14891481 }
14901482
@@ -1496,7 +1488,6 @@ bool Parser::zOSParseParameterList(
14961488 assert (Tok.is (tok::kw_volatile));
14971489 CVQual.addVolatile ();
14981490 }
1499- PrevLoc = Tok.getLocation ();
15001491 PP.Lex (Tok);
15011492 }
15021493 }
@@ -1515,34 +1506,28 @@ bool Parser::zOSHandlePragmaHelper(tok::TokenKind PragmaKind) {
15151506 (std::pair<std::unique_ptr<Token[]>, size_t > *)Tok.getAnnotationValue ();
15161507 PP.EnterTokenStream (std::move (TheTokens->first ), TheTokens->second , true ,
15171508 false );
1518- ConsumeAnnotationToken (); // The annotation token.
1509+ ConsumeAnnotationToken ();
15191510
15201511 do {
1521- SourceLocation PrevTokLocation = Tok.getLocation ();
1522-
15231512 PP.Lex (Tok);
15241513 if (Tok.isNot (tok::l_paren)) {
1525- PP.Diag (Tok.getLocation ().isValid () ? Tok.getLocation () : PrevTokLocation,
1526- diag::warn_pragma_expected_lparen)
1514+ PP.Diag (Tok.getLocation (), diag::warn_pragma_expected_lparen)
15271515 << PragmaName;
15281516 return false ;
15291517 }
15301518
15311519 // C++ could have a nested name, or be qualified with ::.
1532- PrevTokLocation = Tok.getLocation ();
15331520 PP.Lex (Tok);
15341521 if (Tok.isNot (tok::identifier) &&
15351522 !(PP.getLangOpts ().CPlusPlus && Tok.is (tok::coloncolon))) {
1536- PP.Diag (Tok.getLocation ().isValid () ? Tok.getLocation () : PrevTokLocation,
1537- diag::warn_pragma_expected_identifier)
1523+ PP.Diag (Tok.getLocation (), diag::warn_pragma_expected_identifier)
15381524 << PragmaName;
15391525 return false ;
15401526 }
15411527
15421528 IdentifierInfo *IdentName = Tok.getIdentifierInfo ();
15431529 SourceLocation IdentNameLoc = Tok.getLocation ();
1544- NestedNameSpecifier *NestedId =
1545- zOSParseIdentifier (PragmaName, IdentName, PrevTokLocation);
1530+ NestedNameSpecifier *NestedId = zOSParseIdentifier (PragmaName, IdentName);
15461531 if (!NestedId)
15471532 return false ;
15481533
@@ -1552,13 +1537,12 @@ bool Parser::zOSHandlePragmaHelper(tok::TokenKind PragmaKind) {
15521537 Qualifiers CVQual;
15531538
15541539 if (PP.getLangOpts ().CPlusPlus && Tok.is (tok::l_paren)) {
1555- if (!zOSParseParameterList (PragmaName, TypeList, CVQual, PrevTokLocation ))
1540+ if (!zOSParseParameterList (PragmaName, TypeList, CVQual))
15561541 return false ;
15571542 }
15581543
15591544 if (Tok.isNot (tok::r_paren)) {
1560- PP.Diag (Tok.getLocation ().isValid () ? Tok.getLocation () : PrevTokLocation,
1561- diag::warn_pragma_expected_rparen)
1545+ PP.Diag (Tok.getLocation (), diag::warn_pragma_expected_rparen)
15621546 << PragmaName;
15631547 return false ;
15641548 }
@@ -1567,7 +1551,7 @@ bool Parser::zOSHandlePragmaHelper(tok::TokenKind PragmaKind) {
15671551 Actions.ActOnPragmaExport (NestedId, IdentNameLoc, std::move (TypeList),
15681552 CVQual);
15691553
1570- // Because export is also a C++ keyword, we also check for that
1554+ // Because export is also a C++ keyword, we also check for that.
15711555 if (Tok.is (tok::identifier) || Tok.is (tok::kw_export)) {
15721556 IsPragmaExport = false ;
15731557 PragmaName = Tok.getIdentifierInfo ()->getName ();
@@ -4363,6 +4347,7 @@ static void zOSPragmaHandlerHelper(Preprocessor &PP, Token &Tok,
43634347 AnnotTok.setAnnotationEndLoc (Tok.getLocation ());
43644348 }
43654349 // Add a sentinel EoF token to the end of the list.
4350+ EoF.setLocation (Tok.getLocation ());
43664351 TokenVector.push_back (EoF);
43674352 // We must allocate this array with new because EnterTokenStream is going to
43684353 // delete it later.
0 commit comments