implements test/Preprocessor/expr_usual_conversions.c, which produces this
output:
expr_usual_conversions.c:5:10: warning: left side of operator converted from negative value to unsigned: -42 to 18446744073709551574
#if (-42 + 0U) / -2
^
expr_usual_conversions.c:5:16: warning: right side of operator converted from negative value to unsigned: -2 to 18446744073709551614
#if (-42 + 0U) / -2
^
llvm-svn: 39406
t.c:2:17: warning: integer overflow in preprocessor expression
#if -(INTMAX_MAX+1)
^
t.c:2:5: warning: integer overflow in preprocessor expression
#if -(INTMAX_MAX+1)
^
GCC has some seriously confused source locations in this case:
t.c:2:19: warning: integer overflow in preprocessor expression
t.c:2:20: warning: integer overflow in preprocessor expression
column 19/20 are off the end of the line.
llvm-svn: 39404
like this:
t3.c:5:10: error: 'vers2.h' file not found
#include xstr(INCFILE(2).h)
^
instead of:
t3.c:5:10: error: file not found
#include xstr(INCFILE(2).h)
^
which is useful if the #include name is generated through macro expansion.
llvm-svn: 39398
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
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
Submitted by:
Reviewed by:
Type Checking...round 2. This checkin "breaks" parsing carbon.h. I imagine
that this will be true for the next week or so. Nevertheless, this round of
changes includes the following:
- Hacked various Expr classes to pass the appropriate TypeRef. Still have
a few more classes to touch.
- Implement type checking for ParseArraySubscriptExpr and ParseMemberReferenceExpr.
- Added a debug hook to derive the class name for Stmt/Expr nodes. Currently a
linear search...could easily optimize if important.
- Changed the name of TaggedType->TagType. Now we have TagType and TagDecl (which
are easier to remember).
- Fixed a bug in StringLiteral conversion I did a couple weeks ago. hadError was
not initialized (oops).
- changed Sema::Diag to return true. This streamlines the type checking code
considerably.
- Added many diagnositics.
This should be it!
llvm-svn: 39361
Submitted by:
Reviewed by:
Move string literal parsing from Sema=>LiteralSupport. This consolidates
all the quirky parsing code within the Lexer subsystem (yeah!). This
simplifies Sema and (more importantly) allows future parsers
(i.e. subclasses of Action) to benefit from this code.
llvm-svn: 39354
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
Submitted by:
Reviewed by:
Moved numeric literal support from SemaExpr.cpp to LiteralSupport.[h,cpp]
in Lex. This will allow it to be used by both Sema and Preprocessor (and
should be the last major refactoring of this sub-system).. Over
time, it will be reused by anyone implementing an actions module (i.e.
any subclass of llvm::clang::Action. Minor changes to IntegerLiteral in Expr.h.
More to come...
llvm-svn: 39351
whose decl objects are lazily created the first time they are referenced.
Builtin functions are described by the clang/AST/Builtins.def file, which
makes it easy to add new ones.
This is missing two important pieces:
1. Support for the rest of the gcc builtins.
2. Support for target-specific builtins (e.g. __builtin_ia32_emms).
Just adding this builtins reduces the number of implicit function definitions
by 6, reducing the # diagnostics from 550 to 544 when parsing carbon.h.
I need to add all the i386-specific ones to eliminate several hundred more.
ugh.
llvm-svn: 39327
of having a loose collection of function pointers. This also allows clients to
maintain state, and reduces the size of the Preprocessor.h interface.
llvm-svn: 39203
filenames (and also '#pragma GCC dependency' of course). Now, assuming
no cleaning is needed, we can go all the way from lexing the filename to
doing filename lookups with no mallocs. This speeds up user PP time from
0.077 to 0.075s for Cocoa.h (2.6%).
llvm-svn: 39092
class instead. SmallString allows to code to avoid hitting malloc in
the normal case (or will, when some other stuff is converted over).
llvm-svn: 39084