minor cleanups. The major missing piece is tracking:

* signedness of values
 * overflow of intermediate computations.

llvm-svn: 39387
This commit is contained in:
Chris Lattner 2007-04-04 06:54:19 +00:00
parent 531efa43d8
commit 6df7975ae6
1 changed files with 4 additions and 4 deletions

View File

@ -12,7 +12,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// FIXME: implement testing for asserts. // FIXME: implement testing for #assert's.
// FIXME: Track signed/unsigned correctly. // FIXME: Track signed/unsigned correctly.
// FIXME: Track and report integer overflow correctly. // FIXME: Track and report integer overflow correctly.
// //
@ -146,21 +146,21 @@ static bool EvaluateValue(APInt &Result, LexerToken &PeekTok,
PP.Diag(PeekTok, diag::err_pp_expected_value_in_expr); PP.Diag(PeekTok, diag::err_pp_expected_value_in_expr);
return true; return true;
case tok::numeric_constant: { case tok::numeric_constant: {
SmallString<512> IntegerBuffer; SmallString<64> IntegerBuffer;
IntegerBuffer.resize(PeekTok.getLength()); IntegerBuffer.resize(PeekTok.getLength());
const char *ThisTokBegin = &IntegerBuffer[0]; const char *ThisTokBegin = &IntegerBuffer[0];
unsigned ActualLength = PP.getSpelling(PeekTok, ThisTokBegin); unsigned ActualLength = PP.getSpelling(PeekTok, ThisTokBegin);
NumericLiteralParser Literal(ThisTokBegin, ThisTokBegin+ActualLength, NumericLiteralParser Literal(ThisTokBegin, ThisTokBegin+ActualLength,
PeekTok.getLocation(), PP); PeekTok.getLocation(), PP);
if (Literal.hadError) if (Literal.hadError)
return true; // a diagnostic was already reported. return true; // a diagnostic was already reported.
if (Literal.isFloatingLiteral()) { if (Literal.isFloatingLiteral()) {
PP.Diag(PeekTok, diag::err_pp_illegal_floating_literal); PP.Diag(PeekTok, diag::err_pp_illegal_floating_literal);
return true; return true;
} }
assert(Literal.isIntegerLiteral() && "Unknown ppnumber"); assert(Literal.isIntegerLiteral() && "Unknown ppnumber");
// FIXME: Handle overflow based on whether the value is signed. If signed // FIXME: Handle overflow based on whether the value is signed. If signed
// and if the value is too large, emit a warning "integer constant is so // and if the value is too large, emit a warning "integer constant is so
// large that it is unsigned" e.g. 12345678901234567890. // large that it is unsigned" e.g. 12345678901234567890.