@@ -155,15 +155,6 @@ static bool isLabelChar(char C) {
155
155
C == ' .' || C == ' _' ;
156
156
}
157
157
158
- // / isLabelTail - Return true if this pointer points to a valid end of a label.
159
- static const char *isLabelTail (const char *CurPtr) {
160
- while (true ) {
161
- if (CurPtr[0 ] == ' :' ) return CurPtr+1 ;
162
- if (!isLabelChar (CurPtr[0 ])) return nullptr ;
163
- ++CurPtr;
164
- }
165
- }
166
-
167
158
// ===----------------------------------------------------------------------===//
168
159
// Lexer definition.
169
160
// ===----------------------------------------------------------------------===//
@@ -174,20 +165,22 @@ LLLexer::LLLexer(StringRef StartBuf, SourceMgr &SM, SMDiagnostic &Err,
174
165
CurPtr = CurBuf.begin ();
175
166
}
176
167
168
+ // / getLabelTail - Return true if this pointer points to a valid end of a label.
169
+ const char *LLLexer::getLabelTail (const char *Ptr) {
170
+ while (Ptr != CurBuf.end ()) {
171
+ if (Ptr[0 ] == ' :' )
172
+ return Ptr + 1 ;
173
+ if (!isLabelChar (Ptr[0 ]))
174
+ return nullptr ;
175
+ ++Ptr;
176
+ }
177
+ return nullptr ;
178
+ }
179
+
177
180
int LLLexer::getNextChar () {
178
- char CurChar = *CurPtr++;
179
- switch (CurChar) {
180
- default : return (unsigned char )CurChar;
181
- case 0 :
182
- // A nul character in the stream is either the end of the current buffer or
183
- // a random nul in the file. Disambiguate that here.
184
- if (CurPtr-1 != CurBuf.end ())
185
- return 0 ; // Just whitespace.
186
-
187
- // Otherwise, return end of file.
188
- --CurPtr; // Another call to lex will return EOF again.
181
+ if (CurPtr == CurBuf.end ())
189
182
return EOF;
190
- }
183
+ return *CurPtr++;
191
184
}
192
185
193
186
const char *LLLexer::skipNChars (unsigned N) {
@@ -230,7 +223,7 @@ lltok::Kind LLLexer::LexToken() {
230
223
case ' %' : return LexPercent ();
231
224
case ' "' : return LexQuote ();
232
225
case ' .' :
233
- if (const char *Ptr = isLabelTail (CurPtr)) {
226
+ if (const char *Ptr = getLabelTail (CurPtr)) {
234
227
advancePositionTo (Ptr);
235
228
StrVal.assign (TokStart, CurPtr-1 );
236
229
return lltok::LabelStr;
@@ -313,7 +306,7 @@ lltok::Kind LLLexer::LexAt() {
313
306
}
314
307
315
308
lltok::Kind LLLexer::LexDollar () {
316
- if (const char *Ptr = isLabelTail (TokStart)) {
309
+ if (const char *Ptr = getLabelTail (TokStart)) {
317
310
advancePositionTo (Ptr);
318
311
StrVal.assign (TokStart, CurPtr - 1 );
319
312
return lltok::LabelStr;
@@ -1163,7 +1156,7 @@ lltok::Kind LLLexer::LexDigitOrNegative() {
1163
1156
if (!isdigit (static_cast <unsigned char >(TokStart[0 ])) &&
1164
1157
!isdigit (static_cast <unsigned char >(CurPtr[0 ]))) {
1165
1158
// Okay, this is not a number after the -, it's probably a label.
1166
- if (const char *End = isLabelTail (CurPtr)) {
1159
+ if (const char *End = getLabelTail (CurPtr)) {
1167
1160
StrVal.assign (TokStart, End-1 );
1168
1161
advancePositionTo (End);
1169
1162
return lltok::LabelStr;
@@ -1190,7 +1183,7 @@ lltok::Kind LLLexer::LexDigitOrNegative() {
1190
1183
1191
1184
// Check to see if this really is a string label, e.g. "-1:".
1192
1185
if (isLabelChar (CurPtr[0 ]) || CurPtr[0 ] == ' :' ) {
1193
- if (const char *End = isLabelTail (CurPtr)) {
1186
+ if (const char *End = getLabelTail (CurPtr)) {
1194
1187
StrVal.assign (TokStart, End-1 );
1195
1188
advancePositionTo (End);
1196
1189
return lltok::LabelStr;
0 commit comments