@@ -293,13 +293,11 @@ bool COFFAsmParser::parseDirectiveSymbolAttribute(StringRef Directive, SMLoc) {
293293 assert (Attr != MCSA_Invalid && " unexpected symbol attribute directive!" );
294294 if (getLexer ().isNot (AsmToken::EndOfStatement)) {
295295 while (true ) {
296- StringRef Name ;
296+ MCSymbol *Sym ;
297297
298- if (getParser ().parseIdentifier (Name ))
298+ if (getParser ().parseSymbol (Sym ))
299299 return TokError (" expected identifier in directive" );
300300
301- MCSymbol *Sym = getContext ().getOrCreateSymbol (Name);
302-
303301 getStreamer ().emitSymbolAttribute (Sym, Attr);
304302
305303 if (getLexer ().is (AsmToken::EndOfStatement))
@@ -450,13 +448,11 @@ bool COFFAsmParser::parseDirectivePopSection(StringRef, SMLoc) {
450448}
451449
452450bool COFFAsmParser::parseDirectiveDef (StringRef, SMLoc) {
453- StringRef SymbolName ;
451+ MCSymbol *Sym ;
454452
455- if (getParser ().parseIdentifier (SymbolName ))
453+ if (getParser ().parseSymbol (Sym ))
456454 return TokError (" expected identifier in directive" );
457455
458- MCSymbol *Sym = getContext ().getOrCreateSymbol (SymbolName);
459-
460456 getStreamer ().beginCOFFSymbolDef (Sym);
461457
462458 Lex ();
@@ -496,8 +492,8 @@ bool COFFAsmParser::parseDirectiveEndef(StringRef, SMLoc) {
496492}
497493
498494bool COFFAsmParser::parseDirectiveSecRel32 (StringRef, SMLoc) {
499- StringRef SymbolID ;
500- if (getParser ().parseIdentifier (SymbolID ))
495+ MCSymbol *Symbol ;
496+ if (getParser ().parseSymbol (Symbol ))
501497 return TokError (" expected identifier in directive" );
502498
503499 int64_t Offset = 0 ;
@@ -517,17 +513,15 @@ bool COFFAsmParser::parseDirectiveSecRel32(StringRef, SMLoc) {
517513 " invalid '.secrel32' directive offset, can't be less "
518514 " than zero or greater than std::numeric_limits<uint32_t>::max()" );
519515
520- MCSymbol *Symbol = getContext ().getOrCreateSymbol (SymbolID);
521-
522516 Lex ();
523517 getStreamer ().emitCOFFSecRel32 (Symbol, Offset);
524518 return false ;
525519}
526520
527521bool COFFAsmParser::parseDirectiveRVA (StringRef, SMLoc) {
528522 auto parseOp = [&]() -> bool {
529- StringRef SymbolID ;
530- if (getParser ().parseIdentifier (SymbolID ))
523+ MCSymbol *Symbol ;
524+ if (getParser ().parseSymbol (Symbol ))
531525 return TokError (" expected identifier in directive" );
532526
533527 int64_t Offset = 0 ;
@@ -544,8 +538,6 @@ bool COFFAsmParser::parseDirectiveRVA(StringRef, SMLoc) {
544538 " than -2147483648 or greater than "
545539 " 2147483647" );
546540
547- MCSymbol *Symbol = getContext ().getOrCreateSymbol (SymbolID);
548-
549541 getStreamer ().emitCOFFImgRel32 (Symbol, Offset);
550542 return false ;
551543 };
@@ -556,75 +548,65 @@ bool COFFAsmParser::parseDirectiveRVA(StringRef, SMLoc) {
556548}
557549
558550bool COFFAsmParser::parseDirectiveSafeSEH (StringRef, SMLoc) {
559- StringRef SymbolID ;
560- if (getParser ().parseIdentifier (SymbolID ))
551+ MCSymbol *Symbol ;
552+ if (getParser ().parseSymbol (Symbol ))
561553 return TokError (" expected identifier in directive" );
562554
563555 if (getLexer ().isNot (AsmToken::EndOfStatement))
564556 return TokError (" unexpected token in directive" );
565557
566- MCSymbol *Symbol = getContext ().getOrCreateSymbol (SymbolID);
567-
568558 Lex ();
569559 getStreamer ().emitCOFFSafeSEH (Symbol);
570560 return false ;
571561}
572562
573563bool COFFAsmParser::parseDirectiveSecIdx (StringRef, SMLoc) {
574- StringRef SymbolID ;
575- if (getParser ().parseIdentifier (SymbolID ))
564+ MCSymbol *Symbol ;
565+ if (getParser ().parseSymbol (Symbol ))
576566 return TokError (" expected identifier in directive" );
577567
578568 if (getLexer ().isNot (AsmToken::EndOfStatement))
579569 return TokError (" unexpected token in directive" );
580570
581- MCSymbol *Symbol = getContext ().getOrCreateSymbol (SymbolID);
582-
583571 Lex ();
584572 getStreamer ().emitCOFFSectionIndex (Symbol);
585573 return false ;
586574}
587575
588576bool COFFAsmParser::parseDirectiveSymIdx (StringRef, SMLoc) {
589- StringRef SymbolID ;
590- if (getParser ().parseIdentifier (SymbolID ))
577+ MCSymbol *Symbol ;
578+ if (getParser ().parseSymbol (Symbol ))
591579 return TokError (" expected identifier in directive" );
592580
593581 if (getLexer ().isNot (AsmToken::EndOfStatement))
594582 return TokError (" unexpected token in directive" );
595583
596- MCSymbol *Symbol = getContext ().getOrCreateSymbol (SymbolID);
597-
598584 Lex ();
599585 getStreamer ().emitCOFFSymbolIndex (Symbol);
600586 return false ;
601587}
602588
603589bool COFFAsmParser::parseDirectiveSecNum (StringRef, SMLoc) {
604- StringRef SymbolID ;
605- if (getParser ().parseIdentifier (SymbolID ))
590+ MCSymbol *Symbol ;
591+ if (getParser ().parseSymbol (Symbol ))
606592 return TokError (" expected identifier in directive" );
607593
608594 if (getLexer ().isNot (AsmToken::EndOfStatement))
609595 return TokError (" unexpected token in directive" );
610596
611- MCSymbol *Symbol = getContext ().getOrCreateSymbol (SymbolID);
612-
613597 Lex ();
614598 getStreamer ().emitCOFFSecNumber (Symbol);
615599 return false ;
616600}
617601
618602bool COFFAsmParser::parseDirectiveSecOffset (StringRef, SMLoc) {
619- StringRef SymbolID ;
620- if (getParser ().parseIdentifier (SymbolID ))
603+ MCSymbol *Symbol ;
604+ if (getParser ().parseSymbol (Symbol ))
621605 return TokError (" expected identifier in directive" );
622606
623607 if (getLexer ().isNot (AsmToken::EndOfStatement))
624608 return TokError (" unexpected token in directive" );
625609
626- MCSymbol *Symbol = getContext ().getOrCreateSymbol (SymbolID);
627-
628610 Lex ();
629611 getStreamer ().emitCOFFSecOffset (Symbol);
630612 return false ;
@@ -679,15 +661,13 @@ bool COFFAsmParser::parseDirectiveLinkOnce(StringRef, SMLoc Loc) {
679661}
680662
681663bool COFFAsmParser::parseSEHDirectiveStartProc (StringRef, SMLoc Loc) {
682- StringRef SymbolID ;
683- if (getParser ().parseIdentifier (SymbolID ))
664+ MCSymbol *Symbol ;
665+ if (getParser ().parseSymbol (Symbol ))
684666 return true ;
685667
686668 if (getLexer ().isNot (AsmToken::EndOfStatement))
687669 return TokError (" unexpected token in directive" );
688670
689- MCSymbol *Symbol = getContext ().getOrCreateSymbol (SymbolID);
690-
691671 Lex ();
692672 getStreamer ().emitWinCFIStartProc (Symbol, Loc);
693673 return false ;
@@ -718,8 +698,8 @@ bool COFFAsmParser::parseSEHDirectiveEndChained(StringRef, SMLoc Loc) {
718698}
719699
720700bool COFFAsmParser::parseSEHDirectiveHandler (StringRef, SMLoc Loc) {
721- StringRef SymbolID ;
722- if (getParser ().parseIdentifier (SymbolID ))
701+ MCSymbol *handler ;
702+ if (getParser ().parseSymbol (handler ))
723703 return true ;
724704
725705 if (getLexer ().isNot (AsmToken::Comma))
@@ -736,8 +716,6 @@ bool COFFAsmParser::parseSEHDirectiveHandler(StringRef, SMLoc Loc) {
736716 if (getLexer ().isNot (AsmToken::EndOfStatement))
737717 return TokError (" unexpected token in directive" );
738718
739- MCSymbol *handler = getContext ().getOrCreateSymbol (SymbolID);
740-
741719 Lex ();
742720 getStreamer ().emitWinEHHandler (handler, unwind, except, Loc);
743721 return false ;
0 commit comments