@@ -282,42 +282,6 @@ class AsmParser : public MCAsmParser {
282
282
283
283
void checkForValidSection () override ;
284
284
285
- bool getTokenLoc (SMLoc &Loc) {
286
- Loc = getTok ().getLoc ();
287
- return false ;
288
- }
289
-
290
- bool parseEOL (const Twine &ErrMsg) {
291
- if (getTok ().getKind () == AsmToken::Hash) {
292
- StringRef CommentStr = parseStringToEndOfStatement ();
293
- Lexer.Lex ();
294
- Lexer.UnLex (AsmToken (AsmToken::EndOfStatement, CommentStr));
295
- }
296
- if (getTok ().getKind () != AsmToken::EndOfStatement)
297
- return TokError (ErrMsg);
298
- Lex ();
299
- return false ;
300
- }
301
-
302
- // / parseToken - If current token has the specified kind, eat it and
303
- // / return success. Otherwise, emit the specified error and return failure.
304
- bool parseToken (AsmToken::TokenKind T, const Twine &ErrMsg) {
305
- if (T == AsmToken::EndOfStatement)
306
- return parseEOL (ErrMsg);
307
- if (getTok ().getKind () != T)
308
- return TokError (ErrMsg);
309
- Lex ();
310
- return false ;
311
- }
312
-
313
- bool parseIntToken (int64_t &V, const Twine &ErrMsg) {
314
- if (getTok ().getKind () != AsmToken::Integer)
315
- return TokError (ErrMsg);
316
- V = getTok ().getIntVal ();
317
- Lex ();
318
- return false ;
319
- }
320
-
321
285
// / }
322
286
323
287
private:
@@ -375,18 +339,6 @@ class AsmParser : public MCAsmParser {
375
339
}
376
340
static void DiagHandler (const SMDiagnostic &Diag, void *Context);
377
341
378
- bool check (bool P, SMLoc Loc, const Twine &Msg) {
379
- if (P)
380
- return Error (Loc, Msg);
381
- return false ;
382
- }
383
-
384
- bool check (bool P, const Twine &Msg) {
385
- if (P)
386
- return TokError (Msg);
387
- return false ;
388
- }
389
-
390
342
// / \brief Enter the specified file. This returns true on failure.
391
343
bool enterIncludeFile (const std::string &Filename);
392
344
@@ -2932,13 +2884,13 @@ bool AsmParser::parseDirectiveFill() {
2932
2884
if (getLexer ().isNot (AsmToken::EndOfStatement)) {
2933
2885
2934
2886
if (parseToken (AsmToken::Comma, " unexpected token in '.fill' directive" ) ||
2935
- getTokenLoc (SizeLoc) || parseAbsoluteExpression (FillSize))
2887
+ parseTokenLoc (SizeLoc) || parseAbsoluteExpression (FillSize))
2936
2888
return true ;
2937
2889
2938
2890
if (getLexer ().isNot (AsmToken::EndOfStatement)) {
2939
2891
if (parseToken (AsmToken::Comma,
2940
2892
" unexpected token in '.fill' directive" ) ||
2941
- getTokenLoc (ExprLoc) || parseAbsoluteExpression (FillExpr) ||
2893
+ parseTokenLoc (ExprLoc) || parseAbsoluteExpression (FillExpr) ||
2942
2894
parseToken (AsmToken::EndOfStatement,
2943
2895
" unexpected token in '.fill' directive" ))
2944
2896
return true ;
@@ -3016,7 +2968,7 @@ bool AsmParser::parseDirectiveAlign(bool IsPow2, unsigned ValueSize) {
3016
2968
3017
2969
if (getTok ().isNot (AsmToken::EndOfStatement)) {
3018
2970
if (parseToken (AsmToken::Comma, " unexpected token in directive" ) ||
3019
- getTokenLoc (MaxBytesLoc) || parseAbsoluteExpression (MaxBytesToFill))
2971
+ parseTokenLoc (MaxBytesLoc) || parseAbsoluteExpression (MaxBytesToFill))
3020
2972
return true ;
3021
2973
}
3022
2974
}
@@ -3295,11 +3247,11 @@ bool AsmParser::parseDirectiveCVFile() {
3295
3247
bool AsmParser::parseDirectiveCVLoc () {
3296
3248
SMLoc Loc;
3297
3249
int64_t FunctionId, FileNumber;
3298
- if (getTokenLoc (Loc) ||
3250
+ if (parseTokenLoc (Loc) ||
3299
3251
parseIntToken (FunctionId, " unexpected token in '.cv_loc' directive" ) ||
3300
3252
check (FunctionId < 0 , Loc,
3301
3253
" function id less than zero in '.cv_loc' directive" ) ||
3302
- getTokenLoc (Loc) ||
3254
+ parseTokenLoc (Loc) ||
3303
3255
parseIntToken (FileNumber, " expected integer in '.cv_loc' directive" ) ||
3304
3256
check (FileNumber < 1 , Loc,
3305
3257
" file number less than one in '.cv_loc' directive" ) ||
@@ -3368,12 +3320,12 @@ bool AsmParser::parseDirectiveCVLinetable() {
3368
3320
" function id less than zero in '.cv_linetable' directive" ) ||
3369
3321
parseToken (AsmToken::Comma,
3370
3322
" unexpected token in '.cv_linetable' directive" ) ||
3371
- getTokenLoc (Loc) || check (parseIdentifier (FnStartName), Loc,
3372
- " expected identifier in directive" ) ||
3323
+ parseTokenLoc (Loc) || check (parseIdentifier (FnStartName), Loc,
3324
+ " expected identifier in directive" ) ||
3373
3325
parseToken (AsmToken::Comma,
3374
3326
" unexpected token in '.cv_linetable' directive" ) ||
3375
- getTokenLoc (Loc) || check (parseIdentifier (FnEndName), Loc,
3376
- " expected identifier in directive" ))
3327
+ parseTokenLoc (Loc) || check (parseIdentifier (FnEndName), Loc,
3328
+ " expected identifier in directive" ))
3377
3329
return true ;
3378
3330
3379
3331
MCSymbol *FnStartSym = getContext ().getOrCreateSymbol (FnStartName);
@@ -3395,22 +3347,22 @@ bool AsmParser::parseDirectiveCVInlineLinetable() {
3395
3347
" expected PrimaryFunctionId in '.cv_inline_linetable' directive" ) ||
3396
3348
check (PrimaryFunctionId < 0 , Loc,
3397
3349
" function id less than zero in '.cv_inline_linetable' directive" ) ||
3398
- getTokenLoc (Loc) ||
3350
+ parseTokenLoc (Loc) ||
3399
3351
parseIntToken (
3400
3352
SourceFileId,
3401
3353
" expected SourceField in '.cv_inline_linetable' directive" ) ||
3402
3354
check (SourceFileId <= 0 , Loc,
3403
3355
" File id less than zero in '.cv_inline_linetable' directive" ) ||
3404
- getTokenLoc (Loc) ||
3356
+ parseTokenLoc (Loc) ||
3405
3357
parseIntToken (
3406
3358
SourceLineNum,
3407
3359
" expected SourceLineNum in '.cv_inline_linetable' directive" ) ||
3408
3360
check (SourceLineNum < 0 , Loc,
3409
3361
" Line number less than zero in '.cv_inline_linetable' directive" ) ||
3410
- getTokenLoc (Loc) || check (parseIdentifier (FnStartName), Loc,
3411
- " expected identifier in directive" ) ||
3412
- getTokenLoc (Loc) || check (parseIdentifier (FnEndName), Loc,
3413
- " expected identifier in directive" ))
3362
+ parseTokenLoc (Loc) || check (parseIdentifier (FnStartName), Loc,
3363
+ " expected identifier in directive" ) ||
3364
+ parseTokenLoc (Loc) || check (parseIdentifier (FnEndName), Loc,
3365
+ " expected identifier in directive" ))
3414
3366
return true ;
3415
3367
3416
3368
SmallVector<unsigned , 8 > SecondaryFunctionIds;
@@ -4057,8 +4009,9 @@ bool AsmParser::parseDirectiveEndMacro(StringRef Directive) {
4057
4009
bool AsmParser::parseDirectivePurgeMacro (SMLoc DirectiveLoc) {
4058
4010
StringRef Name;
4059
4011
SMLoc Loc;
4060
- if (getTokenLoc (Loc) || check (parseIdentifier (Name), Loc,
4061
- " expected identifier in '.purgem' directive" ) ||
4012
+ if (parseTokenLoc (Loc) ||
4013
+ check (parseIdentifier (Name), Loc,
4014
+ " expected identifier in '.purgem' directive" ) ||
4062
4015
parseToken (AsmToken::EndOfStatement,
4063
4016
" unexpected token in '.purgem' directive" ))
4064
4017
return true ;
0 commit comments