[cfe-commits] r59863 - in /cfe/trunk: include/clang/Lex/LiteralSupport.h lib/Lex/LiteralSupport.cpp
Chris Lattner
sabre at nondot.org
Fri Nov 21 23:23:31 PST 2008
Author: lattner
Date: Sat Nov 22 01:23:31 2008
New Revision: 59863
URL: http://llvm.org/viewvc/llvm-project?rev=59863&view=rev
Log:
remove the NumericLiteralParser::Diag helper method, inlining it into
its call sites. This makes it more explicit when the hasError flag is
getting set and removes a confusing difference in behavior between
PP.Diag and Diag in this code.
Modified:
cfe/trunk/include/clang/Lex/LiteralSupport.h
cfe/trunk/lib/Lex/LiteralSupport.cpp
Modified: cfe/trunk/include/clang/Lex/LiteralSupport.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/LiteralSupport.h?rev=59863&r1=59862&r2=59863&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/LiteralSupport.h (original)
+++ cfe/trunk/include/clang/Lex/LiteralSupport.h Sat Nov 22 01:23:31 2008
@@ -84,9 +84,7 @@
bool* isExact = NULL);
private:
- void Diag(SourceLocation Loc, unsigned DiagID,
- const std::string &M = std::string());
-
+
void ParseNumberStartingWithZero(SourceLocation TokLoc);
/// SkipHexDigits - Read and skip over any hex digits, up to End.
Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=59863&r1=59862&r2=59863&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Sat Nov 22 01:23:31 2008
@@ -141,11 +141,10 @@
}
// FALL THROUGH.
default:
- if (isgraph(ThisTokBuf[0])) {
+ if (isgraph(ThisTokBuf[0]))
PP.Diag(Loc, diag::ext_unknown_escape) << std::string()+(char)ResultChar;
- } else {
+ else
PP.Diag(Loc, diag::ext_unknown_escape) << "x"+llvm::utohexstr(ResultChar);
- }
break;
}
@@ -225,8 +224,9 @@
if (s == ThisTokEnd) {
// Done.
} else if (isxdigit(*s) && !(*s == 'e' || *s == 'E')) {
- Diag(PP.AdvanceToTokenCharacter(TokLoc, s-begin),
- diag::err_invalid_decimal_digit, std::string(s, s+1));
+ PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-begin),
+ diag::err_invalid_decimal_digit) << std::string(s, s+1);
+ hadError = true;
return;
} else if (*s == '.') {
s++;
@@ -242,8 +242,9 @@
if (first_non_digit != s) {
s = first_non_digit;
} else {
- Diag(PP.AdvanceToTokenCharacter(TokLoc, Exponent-begin),
- diag::err_exponent_has_no_digits);
+ PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, Exponent-begin),
+ diag::err_exponent_has_no_digits);
+ hadError = true;
return;
}
}
@@ -330,10 +331,11 @@
// Report an error if there are any.
if (s != ThisTokEnd) {
- Diag(PP.AdvanceToTokenCharacter(TokLoc, s-begin),
- isFPConstant ? diag::err_invalid_suffix_float_constant :
- diag::err_invalid_suffix_integer_constant,
- std::string(SuffixBegin, ThisTokEnd));
+ PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-begin),
+ isFPConstant ? diag::err_invalid_suffix_float_constant :
+ diag::err_invalid_suffix_integer_constant)
+ << std::string(SuffixBegin, ThisTokEnd);
+ hadError = true;
return;
}
}
@@ -369,17 +371,21 @@
if (*s == '+' || *s == '-') s++; // sign
const char *first_non_digit = SkipDigits(s);
if (first_non_digit == s) {
- Diag(PP.AdvanceToTokenCharacter(TokLoc, Exponent-ThisTokBegin),
- diag::err_exponent_has_no_digits);
+ PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, Exponent-ThisTokBegin),
+ diag::err_exponent_has_no_digits);
+ hadError = true;
return;
}
s = first_non_digit;
- if (!PP.getLangOptions().HexFloats)
- Diag(TokLoc, diag::ext_hexconstant_invalid);
+ if (!PP.getLangOptions().HexFloats) {
+ PP.Diag(TokLoc, diag::ext_hexconstant_invalid);
+ hadError = true;
+ }
} else if (saw_period) {
- Diag(PP.AdvanceToTokenCharacter(TokLoc, s-ThisTokBegin),
- diag::err_hexconstant_requires_exponent);
+ PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-ThisTokBegin),
+ diag::err_hexconstant_requires_exponent);
+ hadError = true;
}
return;
}
@@ -395,8 +401,9 @@
if (s == ThisTokEnd) {
// Done.
} else if (isxdigit(*s)) {
- Diag(PP.AdvanceToTokenCharacter(TokLoc, s-ThisTokBegin),
- diag::err_invalid_binary_digit, std::string(s, s+1));
+ PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-ThisTokBegin),
+ diag::err_invalid_binary_digit) << std::string(s, s+1);
+ hadError = true;
}
// Other suffixes will be diagnosed by the caller.
return;
@@ -424,8 +431,9 @@
// If we have a hex digit other than 'e' (which denotes a FP exponent) then
// the code is using an incorrect base.
if (isxdigit(*s) && *s != 'e' && *s != 'E') {
- Diag(PP.AdvanceToTokenCharacter(TokLoc, s-ThisTokBegin),
- diag::err_invalid_octal_digit, std::string(s, s+1));
+ PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-ThisTokBegin),
+ diag::err_invalid_octal_digit) << std::string(s, s+1);
+ hadError = true;
return;
}
@@ -445,8 +453,9 @@
if (first_non_digit != s) {
s = first_non_digit;
} else {
- Diag(PP.AdvanceToTokenCharacter(TokLoc, Exponent-ThisTokBegin),
- diag::err_exponent_has_no_digits);
+ PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, Exponent-ThisTokBegin),
+ diag::err_exponent_has_no_digits);
+ hadError = true;
return;
}
}
@@ -530,12 +539,6 @@
return V;
}
-void NumericLiteralParser::Diag(SourceLocation Loc, unsigned DiagID,
- const std::string &M) {
- PP.Diag(Loc, DiagID) << M;
- hadError = true;
-}
-
CharLiteralParser::CharLiteralParser(const char *begin, const char *end,
SourceLocation Loc, Preprocessor &PP) {
More information about the cfe-commits
mailing list