@@ -93,9 +93,7 @@ TGLexer::TGLexer(SourceMgr &SM, ArrayRef<std::string> Macros) : SrcMgr(SM) {
9393 }
9494}
9595
96- SMLoc TGLexer::getLoc () const {
97- return SMLoc::getFromPointer (TokStart);
98- }
96+ SMLoc TGLexer::getLoc () const { return SMLoc::getFromPointer (TokStart); }
9997
10098SMRange TGLexer::getLocRange () const {
10199 return {getLoc (), SMLoc::getFromPointer (CurPtr)};
@@ -162,16 +160,13 @@ int TGLexer::getNextChar() {
162160 // Handle the newline character by ignoring it and incrementing the line
163161 // count. However, be careful about 'dos style' files with \n\r in them.
164162 // Only treat a \n\r or \r\n as a single line.
165- if ((*CurPtr == ' \n ' || (*CurPtr == ' \r ' )) &&
166- *CurPtr != CurChar)
167- ++CurPtr; // Eat the two char newline sequence.
163+ if ((*CurPtr == ' \n ' || (*CurPtr == ' \r ' )) && *CurPtr != CurChar)
164+ ++CurPtr; // Eat the two char newline sequence.
168165 return ' \n ' ;
169166 }
170167}
171168
172- int TGLexer::peekNextChar (int Index) const {
173- return *(CurPtr + Index);
174- }
169+ int TGLexer::peekNextChar (int Index) const { return *(CurPtr + Index); }
175170
176171tgtok::TokKind TGLexer::LexToken (bool FileOrLineStart) {
177172 while (true ) {
@@ -367,7 +362,9 @@ tgtok::TokKind TGLexer::LexString() {
367362 ++CurPtr;
368363
369364 switch (*CurPtr) {
370- case ' \\ ' : case ' \' ' : case ' "' :
365+ case ' \\ ' :
366+ case ' \' ' :
367+ case ' "' :
371368 // These turn into their literal character.
372369 CurStrVal += *CurPtr++;
373370 break ;
@@ -421,7 +418,7 @@ tgtok::TokKind TGLexer::LexIdentifier() {
421418 ++CurPtr;
422419
423420 // Check to see if this identifier is a reserved keyword.
424- StringRef Str (IdentStart, CurPtr- IdentStart);
421+ StringRef Str (IdentStart, CurPtr - IdentStart);
425422
426423 tgtok::TokKind Kind = StringSwitch<tgtok::TokKind>(Str)
427424 .Case (" int" , tgtok::Int)
@@ -454,14 +451,15 @@ tgtok::TokKind TGLexer::LexIdentifier() {
454451
455452 // A couple of tokens require special processing.
456453 switch (Kind) {
457- case tgtok::Include:
458- if (LexInclude ()) return tgtok::Error;
459- return Lex ();
460- case tgtok::Id:
461- CurStrVal.assign (Str.begin (), Str.end ());
462- break ;
463- default :
464- break ;
454+ case tgtok::Include:
455+ if (LexInclude ())
456+ return tgtok::Error;
457+ return Lex ();
458+ case tgtok::Id:
459+ CurStrVal.assign (Str.begin (), Str.end ());
460+ break ;
461+ default :
462+ break ;
465463 }
466464
467465 return Kind;
@@ -472,7 +470,8 @@ tgtok::TokKind TGLexer::LexIdentifier() {
472470bool TGLexer::LexInclude () {
473471 // The token after the include must be a string.
474472 tgtok::TokKind Tok = LexToken ();
475- if (Tok == tgtok::Error) return true ;
473+ if (Tok == tgtok::Error)
474+ return true ;
476475 if (Tok != tgtok::StrVal) {
477476 PrintError (getLoc (), " expected filename after include" );
478477 return true ;
@@ -501,15 +500,15 @@ bool TGLexer::LexInclude() {
501500// / SkipBCPLComment - Skip over the comment by finding the next CR or LF.
502501// / Or we may end up at the end of the buffer.
503502void TGLexer::SkipBCPLComment () {
504- ++CurPtr; // skip the second slash.
503+ ++CurPtr; // skip the second slash.
505504 auto EOLPos = CurBuf.find_first_of (" \r\n " , CurPtr - CurBuf.data ());
506505 CurPtr = (EOLPos == StringRef::npos) ? CurBuf.end () : CurBuf.data () + EOLPos;
507506}
508507
509508// / SkipCComment - This skips C-style /**/ comments. The only difference from C
510509// / is that we allow nesting.
511510bool TGLexer::SkipCComment () {
512- ++CurPtr; // skip the star.
511+ ++CurPtr; // skip the star.
513512 unsigned CommentDepth = 1 ;
514513
515514 while (true ) {
@@ -520,15 +519,17 @@ bool TGLexer::SkipCComment() {
520519 return true ;
521520 case ' *' :
522521 // End of the comment?
523- if (CurPtr[0 ] != ' /' ) break ;
522+ if (CurPtr[0 ] != ' /' )
523+ break ;
524524
525- ++CurPtr; // End the */.
525+ ++CurPtr; // End the */.
526526 if (--CommentDepth == 0 )
527527 return false ;
528528 break ;
529529 case ' /' :
530530 // Start of a nested comment?
531- if (CurPtr[0 ] != ' *' ) break ;
531+ if (CurPtr[0 ] != ' *' )
532+ break ;
532533 ++CurPtr;
533534 ++CommentDepth;
534535 break ;
@@ -608,14 +609,17 @@ tgtok::TokKind TGLexer::LexBracket() {
608609 const char *CodeStart = CurPtr;
609610 while (true ) {
610611 int Char = getNextChar ();
611- if (Char == EOF) break ;
612+ if (Char == EOF)
613+ break ;
612614
613- if (Char != ' }' ) continue ;
615+ if (Char != ' }' )
616+ continue ;
614617
615618 Char = getNextChar ();
616- if (Char == EOF) break ;
619+ if (Char == EOF)
620+ break ;
617621 if (Char == ' ]' ) {
618- CurStrVal.assign (CodeStart, CurPtr- 2 );
622+ CurStrVal.assign (CodeStart, CurPtr - 2 );
619623 return tgtok::CodeFragment;
620624 }
621625 }
0 commit comments