Commit Graph

23 Commits

Author SHA1 Message Date
Chris Lattner 86054a9634 Diagnostics relating to computation of values should only be produced if an
expression is live.  For example:
#if 0 ? 124/0 : 42

should cause no error.

This implements test/Preprocessor/expr_liveness.c

llvm-svn: 39397
2007-04-10 05:26:38 +00:00
Chris Lattner f8a0b0fa50 Add support for character constants in PP expressions, like:
#if 'a'

llvm-svn: 39393
2007-04-05 06:58:56 +00:00
Chris Lattner a9eac7ff44 Correctly represent and propagate signedness information in preprocessor
constant expressions.  This allows us to emit this diagnostic:

t.c:5:5: warning: integer constant is so large that it is unsigned
#if 12345678901234567890
    ^

And makes constant evaluation fully correct, but we do not yet detect and
warn about integer overflow.

This patch requires cvs up'ing the main llvm tree to get the APSInt class,
but no libraries need to be rebuilt there.

llvm-svn: 39388
2007-04-05 05:24:00 +00:00
Chris Lattner 6df7975ae6 minor cleanups. The major missing piece is tracking:
* signedness of values
 * overflow of intermediate computations.

llvm-svn: 39387
2007-04-04 06:54:19 +00:00
Chris Lattner ce5dc8a6b4 Switch PPExpression parsing to be in terms of APInt's whose widths are properly
sized to the target's intmax_t.  This also allows us to emit diagnostic like:

t.c:11:5: warning: integer constant is too large for its type
#if 18446744073709551616  // 2^64
    ^
t.c:15:5: warning: integer constant is too large for its type
#if 18446744073709551617  // 2^64-1
    ^

llvm-svn: 39385
2007-04-04 06:46:55 +00:00
Steve Naroff f2fb89e759 Bug #:
Submitted by:
Reviewed by:
Misc. cleanup/polish of NumericLiteralParser and it's two clients, the
C preprocessor and AST builder...

llvm-svn: 39353
2007-03-13 20:29:44 +00:00
Steve Naroff 451d8f1626 Bug #:
Submitted by:
Reviewed by:
-Converted the preprocessor to use NumericLiteralParser.
-Several minor changes to LiteralSupport interface/implementation.
-Added an error diagnostic for floating point usage in pp expr's.

llvm-svn: 39352
2007-03-12 23:22:38 +00:00
Chris Lattner 2bb8a95389 eliminate string compares when checking for the 'defined' token.
llvm-svn: 39216
2006-11-21 22:24:17 +00:00
Chris Lattner c95c8f2356 Fix a bug
llvm-svn: 39128
2006-11-05 07:59:22 +00:00
Chris Lattner bcb416bbd5 Implement test/Preprocessor/comment_save_if.c
llvm-svn: 39069
2006-10-27 05:43:50 +00:00
Chris Lattner 9916c5ca7e Remove GNU C++ min/max operator extension support, they have been removed
from gcc mainline.

llvm-svn: 39067
2006-10-27 05:24:37 +00:00
Chris Lattner 063400e46e Implement the #define_other_target directive.
llvm-svn: 38984
2006-10-14 19:54:15 +00:00
Chris Lattner 81278c6356 Implement the #define_target preprocessor directive.
llvm-svn: 38980
2006-10-14 19:03:49 +00:00
Chris Lattner b9d90f709e Detect expressions semantically equivalent to !defined(X) for the multiple-include
optimization.

llvm-svn: 38654
2006-07-04 18:32:03 +00:00
Chris Lattner e3519cc948 Change EvaluateValue/EvaluateDirectiveSubExpr to be static functions in
PPExpressions.cpp instead of methods.

llvm-svn: 38652
2006-07-04 18:11:39 +00:00
Chris Lattner 8096542744 refactor code a little, no functionality change
llvm-svn: 38651
2006-07-04 18:03:19 +00:00
Chris Lattner c79f6fb108 Rename IdentifierTokenInfo -> IdentifierInfo.
llvm-svn: 38650
2006-07-04 17:53:21 +00:00
Chris Lattner a8654ca2cf Eliminate MultipleIncludeOpt::ReadDirective and all calls to it. Any directives
that are lexed are made up of tokens, so the calls are just ugly and redundant.

Hook up the MIOpt for the #if case.  PPCExpressions doesn't currently implement
the hook though, so we still don't handle #if !defined(X) with the MIOpt.

llvm-svn: 38649
2006-07-04 17:42:08 +00:00
Chris Lattner a78a97e82f #ifdef X, #ifndef X, and #if defined(X) all mark X as used.
llvm-svn: 38638
2006-07-03 05:42:18 +00:00
Chris Lattner d01e291332 Make a fundamental change to the way we represent the location of LexerToken's.
Now, instead of keeping a pointer to the start of the token in memory, we keep the
start of the token as a SourceLocation node.  This means that each LexerToken knows
the full include stack it was created with, and means that the LexerToken isn't
reliant on a "CurLexer" member to be around (lexer tokens would previously go out of
scope when their lexers were deallocated).

This simplifies several things, and forces good cleanup elsewhere.  Now the
Preprocessor is the one that knows how to dump tokens/macros and is the one that
knows how to get the spelling of a token (it has all the context).

llvm-svn: 38551
2006-06-18 16:22:51 +00:00
Chris Lattner 7966aafd9b Simplify an API
llvm-svn: 38541
2006-06-18 06:50:36 +00:00
Chris Lattner cb28334ea4 Remove manual conditional error handling code.
llvm-svn: 38540
2006-06-18 06:48:37 +00:00
Chris Lattner 22eb972f38 Initial checkin of c-language parser
llvm-svn: 38539
2006-06-18 05:43:12 +00:00