Skip to content

Commit a18af41

Browse files
authored
[LLVM] Change error messages to start with lower case (#113748)
Change LLVM Asm and TableGen Lexer/Parser error messages to begin with lower case.
1 parent 9cc5a4b commit a18af41

23 files changed

+81
-80
lines changed

llvm/lib/AsmParser/LLLexer.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ uint64_t LLLexer::atoull(const char *Buffer, const char *End) {
6060
uint64_t OldRes = Result;
6161
Result *= 10;
6262
Result += *Buffer-'0';
63-
if (Result < OldRes) { // Uh, oh, overflow detected!!!
64-
LexError("constant bigger than 64 bits detected!");
63+
if (Result < OldRes) { // overflow detected.
64+
LexError("constant bigger than 64 bits detected");
6565
return 0;
6666
}
6767
}
@@ -75,8 +75,8 @@ uint64_t LLLexer::HexIntToVal(const char *Buffer, const char *End) {
7575
Result *= 16;
7676
Result += hexDigitValue(*Buffer);
7777

78-
if (Result < OldRes) { // Uh, oh, overflow detected!!!
79-
LexError("constant bigger than 64 bits detected!");
78+
if (Result < OldRes) { // overflow detected.
79+
LexError("constant bigger than 64 bits detected");
8080
return 0;
8181
}
8282
}
@@ -99,7 +99,7 @@ void LLLexer::HexToIntPair(const char *Buffer, const char *End,
9999
Pair[1] += hexDigitValue(*Buffer);
100100
}
101101
if (Buffer != End)
102-
LexError("constant bigger than 128 bits detected!");
102+
LexError("constant bigger than 128 bits detected");
103103
}
104104

105105
/// FP80HexToIntPair - translate an 80 bit FP80 number (20 hexits) into
@@ -118,7 +118,7 @@ void LLLexer::FP80HexToIntPair(const char *Buffer, const char *End,
118118
Pair[0] += hexDigitValue(*Buffer);
119119
}
120120
if (Buffer != End)
121-
LexError("constant bigger than 128 bits detected!");
121+
LexError("constant bigger than 128 bits detected");
122122
}
123123

124124
// UnEscapeLexed - Run through the specified buffer and change \xx codes to the
@@ -292,7 +292,7 @@ lltok::Kind LLLexer::LexDollar() {
292292
StrVal.assign(TokStart + 2, CurPtr - 1);
293293
UnEscapeLexed(StrVal);
294294
if (StringRef(StrVal).contains(0)) {
295-
LexError("Null bytes are not allowed in names");
295+
LexError("NUL character is not allowed in names");
296296
return lltok::Error;
297297
}
298298
return lltok::ComdatVar;
@@ -354,7 +354,7 @@ lltok::Kind LLLexer::LexUIntID(lltok::Kind Token) {
354354

355355
uint64_t Val = atoull(TokStart + 1, CurPtr);
356356
if ((unsigned)Val != Val)
357-
LexError("invalid value number (too large)!");
357+
LexError("invalid value number (too large)");
358358
UIntVal = unsigned(Val);
359359
return Token;
360360
}
@@ -375,7 +375,7 @@ lltok::Kind LLLexer::LexVar(lltok::Kind Var, lltok::Kind VarID) {
375375
StrVal.assign(TokStart+2, CurPtr-1);
376376
UnEscapeLexed(StrVal);
377377
if (StringRef(StrVal).contains(0)) {
378-
LexError("Null bytes are not allowed in names");
378+
LexError("NUL character is not allowed in names");
379379
return lltok::Error;
380380
}
381381
return Var;
@@ -410,7 +410,7 @@ lltok::Kind LLLexer::LexQuote() {
410410
if (CurPtr[0] == ':') {
411411
++CurPtr;
412412
if (StringRef(StrVal).contains(0)) {
413-
LexError("Null bytes are not allowed in names");
413+
LexError("NUL character is not allowed in names");
414414
kind = lltok::Error;
415415
} else {
416416
kind = lltok::LabelStr;
@@ -492,7 +492,7 @@ lltok::Kind LLLexer::LexIdentifier() {
492492
uint64_t NumBits = atoull(StartChar, CurPtr);
493493
if (NumBits < IntegerType::MIN_INT_BITS ||
494494
NumBits > IntegerType::MAX_INT_BITS) {
495-
LexError("bitwidth for integer type out of range!");
495+
LexError("bitwidth for integer type out of range");
496496
return lltok::Error;
497497
}
498498
TyVal = IntegerType::get(Context, NumBits);
@@ -1122,7 +1122,7 @@ lltok::Kind LLLexer::LexDigitOrNegative() {
11221122
uint64_t Val = atoull(TokStart, CurPtr);
11231123
++CurPtr; // Skip the colon.
11241124
if ((unsigned)Val != Val)
1125-
LexError("invalid value number (too large)!");
1125+
LexError("invalid value number (too large)");
11261126
UIntVal = unsigned(Val);
11271127
return lltok::LabelID;
11281128
}

llvm/lib/TableGen/TGLexer.cpp

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ TGLexer::TGLexer(SourceMgr &SM, ArrayRef<std::string> Macros) : SrcMgr(SM) {
8989
for (StringRef MacroName : Macros) {
9090
const char *End = lexMacroName(MacroName);
9191
if (End != MacroName.end())
92-
PrintFatalError("Invalid macro name `" + MacroName +
92+
PrintFatalError("invalid macro name `" + MacroName +
9393
"` specified on command line");
9494

9595
DefinedMacros.insert(MacroName);
@@ -188,7 +188,7 @@ tgtok::TokKind TGLexer::LexToken(bool FileOrLineStart) {
188188
return LexIdentifier();
189189

190190
// Unknown character, emit an error.
191-
return ReturnError(TokStart, "Unexpected character");
191+
return ReturnError(TokStart, "unexpected character");
192192
case EOF:
193193
// Lex next token, if we just left an include file.
194194
// Note that leaving an include file means that the next
@@ -231,7 +231,7 @@ tgtok::TokKind TGLexer::LexToken(bool FileOrLineStart) {
231231
++CurPtr; // Eat third dot.
232232
return tgtok::dotdotdot;
233233
}
234-
return ReturnError(TokStart, "Invalid '..' punctuation");
234+
return ReturnError(TokStart, "invalid '..' punctuation");
235235
}
236236
return tgtok::dot;
237237

@@ -255,7 +255,7 @@ tgtok::TokKind TGLexer::LexToken(bool FileOrLineStart) {
255255
if (SkipCComment())
256256
return tgtok::Error;
257257
} else // Otherwise, this is an error.
258-
return ReturnError(TokStart, "Unexpected character");
258+
return ReturnError(TokStart, "unexpected character");
259259
return LexToken(FileOrLineStart);
260260
case '-': case '+':
261261
case '0': case '1': case '2': case '3': case '4': case '5': case '6':
@@ -313,10 +313,10 @@ tgtok::TokKind TGLexer::LexString() {
313313
while (*CurPtr != '"') {
314314
// If we hit the end of the buffer, report an error.
315315
if (*CurPtr == 0 && CurPtr == CurBuf.end())
316-
return ReturnError(StrStart, "End of file in string literal");
316+
return ReturnError(StrStart, "end of file in string literal");
317317

318318
if (*CurPtr == '\n' || *CurPtr == '\r')
319-
return ReturnError(StrStart, "End of line in string literal");
319+
return ReturnError(StrStart, "end of line in string literal");
320320

321321
if (*CurPtr != '\\') {
322322
CurStrVal += *CurPtr++;
@@ -346,7 +346,7 @@ tgtok::TokKind TGLexer::LexString() {
346346
// If we hit the end of the buffer, report an error.
347347
case '\0':
348348
if (CurPtr == CurBuf.end())
349-
return ReturnError(StrStart, "End of file in string literal");
349+
return ReturnError(StrStart, "end of file in string literal");
350350
[[fallthrough]];
351351
default:
352352
return ReturnError(CurPtr, "invalid escape in string literal");
@@ -359,7 +359,7 @@ tgtok::TokKind TGLexer::LexString() {
359359

360360
tgtok::TokKind TGLexer::LexVarName() {
361361
if (!isValidIDChar(CurPtr[0], /*First=*/true))
362-
return ReturnError(TokStart, "Invalid variable name");
362+
return ReturnError(TokStart, "invalid variable name");
363363

364364
// Otherwise, we're ok, consume the rest of the characters.
365365
const char *VarNameStart = CurPtr++;
@@ -433,7 +433,7 @@ bool TGLexer::LexInclude() {
433433
tgtok::TokKind Tok = LexToken();
434434
if (Tok == tgtok::Error) return true;
435435
if (Tok != tgtok::StrVal) {
436-
PrintError(getLoc(), "Expected filename after include");
436+
PrintError(getLoc(), "expected filename after include");
437437
return true;
438438
}
439439

@@ -444,7 +444,7 @@ bool TGLexer::LexInclude() {
444444
CurBuffer = SrcMgr.AddIncludeFile(Filename, SMLoc::getFromPointer(CurPtr),
445445
IncludedFile);
446446
if (!CurBuffer) {
447-
PrintError(getLoc(), "Could not find include file '" + Filename + "'");
447+
PrintError(getLoc(), "could not find include file '" + Filename + "'");
448448
return true;
449449
}
450450

@@ -476,7 +476,7 @@ bool TGLexer::SkipCComment() {
476476
int CurChar = getNextChar();
477477
switch (CurChar) {
478478
case EOF:
479-
PrintError(TokStart, "Unterminated comment!");
479+
PrintError(TokStart, "unterminated comment");
480480
return true;
481481
case '*':
482482
// End of the comment?
@@ -543,7 +543,7 @@ tgtok::TokKind TGLexer::LexNumber() {
543543

544544
// Requires at least one digit.
545545
if (CurPtr == NumStart)
546-
return ReturnError(TokStart, "Invalid number");
546+
return ReturnError(TokStart, "invalid number");
547547

548548
errno = 0;
549549
if (IsMinus)
@@ -552,9 +552,9 @@ tgtok::TokKind TGLexer::LexNumber() {
552552
CurIntVal = strtoull(NumStart, nullptr, Base);
553553

554554
if (errno == EINVAL)
555-
return ReturnError(TokStart, "Invalid number");
555+
return ReturnError(TokStart, "invalid number");
556556
if (errno == ERANGE)
557-
return ReturnError(TokStart, "Number out of range");
557+
return ReturnError(TokStart, "number out of range");
558558

559559
return Base == 2 ? tgtok::BinaryIntVal : tgtok::IntVal;
560560
}
@@ -580,13 +580,13 @@ tgtok::TokKind TGLexer::LexBracket() {
580580
}
581581
}
582582

583-
return ReturnError(CodeStart - 2, "Unterminated code block");
583+
return ReturnError(CodeStart - 2, "unterminated code block");
584584
}
585585

586586
/// LexExclaim - Lex '!' and '![a-zA-Z]+'.
587587
tgtok::TokKind TGLexer::LexExclaim() {
588588
if (!isAlpha(*CurPtr))
589-
return ReturnError(CurPtr - 1, "Invalid \"!operator\"");
589+
return ReturnError(CurPtr - 1, "invalid \"!operator\"");
590590

591591
const char *Start = CurPtr++;
592592
while (isAlpha(*CurPtr))
@@ -648,7 +648,8 @@ tgtok::TokKind TGLexer::LexExclaim() {
648648
.Case("repr", tgtok::XRepr)
649649
.Default(tgtok::Error);
650650

651-
return Kind != tgtok::Error ? Kind : ReturnError(Start-1, "Unknown operator");
651+
return Kind != tgtok::Error ? Kind
652+
: ReturnError(Start - 1, "unknown operator");
652653
}
653654

654655
bool TGLexer::prepExitInclude(bool IncludeStackMustBeEmpty) {
@@ -662,17 +663,17 @@ bool TGLexer::prepExitInclude(bool IncludeStackMustBeEmpty) {
662663

663664
// Pop the preprocessing controls from the include stack.
664665
if (PrepIncludeStack.empty()) {
665-
PrintFatalError("Preprocessor include stack is empty");
666+
PrintFatalError("preprocessor include stack is empty");
666667
}
667668

668669
PrepIncludeStack.pop_back();
669670

670671
if (IncludeStackMustBeEmpty) {
671672
if (!PrepIncludeStack.empty())
672-
PrintFatalError("Preprocessor include stack is not empty");
673+
PrintFatalError("preprocessor include stack is not empty");
673674
} else {
674675
if (PrepIncludeStack.empty())
675-
PrintFatalError("Preprocessor include stack is empty");
676+
PrintFatalError("preprocessor include stack is empty");
676677
}
677678

678679
return true;
@@ -732,7 +733,7 @@ bool TGLexer::prepEatPreprocessorDirective(tgtok::TokKind Kind) {
732733
return true;
733734
}
734735

735-
PrintFatalError("Unsupported preprocessing token in "
736+
PrintFatalError("unsupported preprocessing token in "
736737
"prepEatPreprocessorDirective()");
737738
return false;
738739
}
@@ -748,7 +749,7 @@ tgtok::TokKind TGLexer::lexPreprocessor(tgtok::TokKind Kind,
748749
StringRef MacroName = prepLexMacroName();
749750
StringRef IfTokName = Kind == tgtok::Ifdef ? "#ifdef" : "#ifndef";
750751
if (MacroName.empty())
751-
return ReturnError(TokStart, "Expected macro name after " + IfTokName);
752+
return ReturnError(TokStart, "expected macro name after " + IfTokName);
752753

753754
bool MacroIsDefined = DefinedMacros.count(MacroName) != 0;
754755

@@ -763,7 +764,7 @@ tgtok::TokKind TGLexer::lexPreprocessor(tgtok::TokKind Kind,
763764
{tgtok::Ifdef, MacroIsDefined, SMLoc::getFromPointer(TokStart)});
764765

765766
if (!prepSkipDirectiveEnd())
766-
return ReturnError(CurPtr, "Only comments are supported after " +
767+
return ReturnError(CurPtr, "only comments are supported after " +
767768
IfTokName + " NAME");
768769

769770
// If we were not processing tokens before this #ifdef,
@@ -794,7 +795,7 @@ tgtok::TokKind TGLexer::lexPreprocessor(tgtok::TokKind Kind,
794795

795796
if (IfdefEntry.Kind != tgtok::Ifdef) {
796797
PrintError(TokStart, "double #else");
797-
return ReturnError(IfdefEntry.SrcPos, "Previous #else is here");
798+
return ReturnError(IfdefEntry.SrcPos, "previous #else is here");
798799
}
799800

800801
// Replace the corresponding #ifdef's control with its negation
@@ -804,7 +805,7 @@ tgtok::TokKind TGLexer::lexPreprocessor(tgtok::TokKind Kind,
804805
{Kind, !IfdefEntry.IsDefined, SMLoc::getFromPointer(TokStart)});
805806

806807
if (!prepSkipDirectiveEnd())
807-
return ReturnError(CurPtr, "Only comments are supported after #else");
808+
return ReturnError(CurPtr, "only comments are supported after #else");
808809

809810
// If we were processing tokens before this #else,
810811
// we have to start skipping lines until the matching #endif.
@@ -827,12 +828,12 @@ tgtok::TokKind TGLexer::lexPreprocessor(tgtok::TokKind Kind,
827828

828829
if (IfdefOrElseEntry.Kind != tgtok::Ifdef &&
829830
IfdefOrElseEntry.Kind != tgtok::Else) {
830-
PrintFatalError("Invalid preprocessor control on the stack");
831+
PrintFatalError("invalid preprocessor control on the stack");
831832
return tgtok::Error;
832833
}
833834

834835
if (!prepSkipDirectiveEnd())
835-
return ReturnError(CurPtr, "Only comments are supported after #endif");
836+
return ReturnError(CurPtr, "only comments are supported after #endif");
836837

837838
PrepIncludeStack.back()->pop_back();
838839

@@ -847,15 +848,15 @@ tgtok::TokKind TGLexer::lexPreprocessor(tgtok::TokKind Kind,
847848
} else if (Kind == tgtok::Define) {
848849
StringRef MacroName = prepLexMacroName();
849850
if (MacroName.empty())
850-
return ReturnError(TokStart, "Expected macro name after #define");
851+
return ReturnError(TokStart, "expected macro name after #define");
851852

852853
if (!DefinedMacros.insert(MacroName).second)
853854
PrintWarning(getLoc(),
854-
"Duplicate definition of macro: " + Twine(MacroName));
855+
"duplicate definition of macro: " + Twine(MacroName));
855856

856857
if (!prepSkipDirectiveEnd())
857858
return ReturnError(CurPtr,
858-
"Only comments are supported after #define NAME");
859+
"only comments are supported after #define NAME");
859860

860861
if (!ReturnNextLiveToken) {
861862
PrintFatalError("#define must be ignored during the lines skipping");
@@ -865,13 +866,13 @@ tgtok::TokKind TGLexer::lexPreprocessor(tgtok::TokKind Kind,
865866
return LexToken();
866867
}
867868

868-
PrintFatalError("Preprocessing directive is not supported");
869+
PrintFatalError("preprocessing directive is not supported");
869870
return tgtok::Error;
870871
}
871872

872873
bool TGLexer::prepSkipRegion(bool MustNeverBeFalse) {
873874
if (!MustNeverBeFalse)
874-
PrintFatalError("Invalid recursion.");
875+
PrintFatalError("invalid recursion.");
875876

876877
do {
877878
// Skip all symbols to the line end.
@@ -917,7 +918,7 @@ bool TGLexer::prepSkipRegion(bool MustNeverBeFalse) {
917918
// due to #else or #endif.
918919
if (prepIsProcessingEnabled()) {
919920
if (Kind != tgtok::Else && Kind != tgtok::Endif) {
920-
PrintFatalError("Tokens processing was enabled by an unexpected "
921+
PrintFatalError("tokens processing was enabled by an unexpected "
921922
"preprocessing directive");
922923
return false;
923924
}
@@ -1032,7 +1033,7 @@ bool TGLexer::prepSkipDirectiveEnd() {
10321033
return false;
10331034
} else {
10341035
TokStart = CurPtr;
1035-
PrintError(CurPtr, "Unexpected character");
1036+
PrintError(CurPtr, "unexpected character");
10361037
return false;
10371038
}
10381039

@@ -1067,8 +1068,8 @@ void TGLexer::prepReportPreprocessorStackError() {
10671068
"empty control stack");
10681069

10691070
auto &PrepControl = PrepIncludeStack.back()->back();
1070-
PrintError(CurBuf.end(), "Reached EOF without matching #endif");
1071-
PrintError(PrepControl.SrcPos, "The latest preprocessor control is here");
1071+
PrintError(CurBuf.end(), "reached EOF without matching #endif");
1072+
PrintError(PrepControl.SrcPos, "the latest preprocessor control is here");
10721073

10731074
TokStart = CurPtr;
10741075
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; RUN: not llvm-as --disable-output %s 2>&1 | FileCheck -DFILE=%s %s
22

33
; i8388609 is the smallest integer type that can't be represented in LLVM IR
4-
; CHECK: [[FILE]]:[[@LINE+1]]:21: error: bitwidth for integer type out of range!
4+
; CHECK: [[FILE]]:[[@LINE+1]]:21: error: bitwidth for integer type out of range
55
@i2 = common global i8388609 0, align 4

llvm/test/Assembler/invalid-name.ll

2 Bytes
Binary file not shown.

llvm/test/Assembler/invalid-name2.ll

2 Bytes
Binary file not shown.

llvm/test/TableGen/64-bit-int.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def {
1616
#ifdef OOR3
1717
bits<64> Val = 0x10000000000000000;
1818
#endif
19-
// CHECK-OOR: error: Number out of range
19+
// CHECK-OOR: error: number out of range
2020

2121
bits<64> BinVal0 = 0x8000000000000000;
2222
bits<64> HexVal0 = 0b1000000000000000000000000000000000000000000000000000000000000000;

0 commit comments

Comments
 (0)