Commit Graph

35757 Commits

Author SHA1 Message Date
Chris Lattner 5e75e8bc71 Why didn't gcc catch this? :(
llvm-svn: 41420
2007-08-26 04:42:42 +00:00
Chris Lattner 881440f5d2 Don't make unknown builtins fatal errors yet.
llvm-svn: 41419
2007-08-26 04:17:05 +00:00
Chris Lattner c5221650b3 remove a bunch of dead code
llvm-svn: 41418
2007-08-26 04:13:58 +00:00
Chris Lattner 71236d0485 fix a bug introduced by the recent childification of ForStmt.
llvm-svn: 41417
2007-08-26 04:11:23 +00:00
Chris Lattner b677a9398a Make parse-ast-print print the storage class and inline
specifier of functions.

llvm-svn: 41416
2007-08-26 04:02:13 +00:00
Chris Lattner 1c72d77d01 null pointers don't get an extra newline.
llvm-svn: 41415
2007-08-26 03:53:29 +00:00
Chris Lattner 0fffcb5b28 implement codegen for complex literals.
llvm-svn: 41414
2007-08-26 03:51:12 +00:00
Chris Lattner 1c20a170c0 add a new ImaginaryLiteral AST node that is used to
represent imaginary literals:

float _Complex A;
void foo() {
  A = 1.0iF;
}

generates:

  (BinaryOperator 0x2305ec0 '_Complex float' '='
    (DeclRefExpr 0x2305e60 '_Complex float' Decl='A' 0x2305cf0)
    (ImaginaryLiteral 0x2305f40 '_Complex float'
      (FloatingLiteral 0x2305ea0 'float' 1.000000))))

llvm-svn: 41413
2007-08-26 03:42:43 +00:00
Chris Lattner ed045421a8 1.0 is double, 1.0F is a float.
llvm-svn: 41412
2007-08-26 03:29:23 +00:00
Chris Lattner f55ab18663 1) refactor some code.
2) Add support for lexing imaginary constants (a GCC extension):

t.c:5:10: warning: imaginary constants are an extension
  A = 1.0iF;
         ^

3) Make the 'invalid suffix' diagnostic pointer more accurate:

t.c:6:10: error: invalid suffix 'qF' on floating constant
  A = 1.0qF;
         ^

instead of:

t.c:6:10: error: invalid suffix 'qF' on floating constant
  A = 1.0qF;
      ^

llvm-svn: 41411
2007-08-26 01:58:14 +00:00
Chris Lattner b620c34bb0 merge checkrelational and checkequality into CheckCompareOperands,
to merge duplicate code.

llvm-svn: 41410
2007-08-26 01:18:55 +00:00
Dale Johannesen b6d2bec418 Revise per review comments.
llvm-svn: 41409
2007-08-26 01:18:27 +00:00
Chris Lattner 1895e58c84 Cases like this:
char *C;
  C != ((void*)0);

Should not warn about incompatible pointer types.  Also, make sure to
insert an implicit conversion even if the operand is null.

llvm-svn: 41408
2007-08-26 01:10:14 +00:00
Dale Johannesen 2cfcf70f82 Add APFloat interface to ConstantFPSDNode. Change
over uses in DAGCombiner.  Fix interfaces to work
with APFloats.

llvm-svn: 41407
2007-08-25 22:10:57 +00:00
Chris Lattner 1bc6fac5c6 new testcase
llvm-svn: 41406
2007-08-25 21:57:08 +00:00
Chris Lattner 27f00282e9 The new correct compound assignment operators exposed a bug in codegen.
llvm-svn: 41405
2007-08-25 21:56:20 +00:00
Steve Naroff 46c72915f4 Surpress the UsualUnaryConversions for compound assignment operators. This change
eliminates the possibility that the left hand expression is an ImplicitCastExpr.
As a result, I removed the check for ImplicitCastExpr in Expr::isLvalue().

This results in the following AST's...

[dylan:~/llvm/tools/clang] admin% cat fix.c

short x; void test4(char c) { 
  x += c; 
  x = x + c;
}
[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang fix.c -parse-ast-dump
Read top-level variable decl: 'x'

void test4(char c)
(CompoundStmt 0x2605d30
  (CompoundAssignOperator 0x2605c40 'short' '+='
    (DeclRefExpr 0x2605c00 'short' Decl='x' 0x2605a80)
    (DeclRefExpr 0x2605c20 'char' Decl='c' 0x2605bc0))
  (BinaryOperator 0x2605d10 'short' '='
    (DeclRefExpr 0x2605c60 'short' Decl='x' 0x2605a80)
    (ImplicitCastExpr 0x2605d00 'short'
      (BinaryOperator 0x2605ce0 'int' '+'
        (ImplicitCastExpr 0x2605cc0 'int'
          (DeclRefExpr 0x2605c80 'short' Decl='x' 0x2605a80))
        (ImplicitCastExpr 0x2605cd0 'int'
          (DeclRefExpr 0x2605ca0 'char' Decl='c' 0x2605bc0))))))

llvm-svn: 41404
2007-08-25 19:54:59 +00:00
Chris Lattner 479ed3aab8 read and ignore the body of a namespace.
llvm-svn: 41403
2007-08-25 18:15:16 +00:00
Steve Naroff e2562ff99d Change Expr::isLvalue() to properly deal with ImplicitCastExpr's.
This fixes the following bug...

t.c:1:31: error: expression is not assignable
short x; void foo(char c) { x += c; }

This case, among others are now captured in implicit-casts.c.

llvm-svn: 41402
2007-08-25 14:37:06 +00:00
Steve Naroff aac9415bfb Give CXXBoolLiteralExpr a type (all expressions need a valid type).
This fixes the following:

******************** TEST 'Parser/cxx-bool.cpp' FAILED! ********************
Command:
clang -fsyntax-only Parser/cxx-bool.cpp
Output:
SemaExpr.cpp:731: failed assertion `!t.isNull() && "DefaultFunctionArrayConversion - missing type"'
Output/cxx-bool.cpp.out.script: line 1: 22697 Abort trap              clang -fsyntax-only Parser/cxx-bool.cpp

llvm-svn: 41401
2007-08-25 14:02:58 +00:00
Chris Lattner a5235173bc refactor enough of the top-level parsing logic to parse and
ignore 'namespace foo {}'

llvm-svn: 41400
2007-08-25 06:57:03 +00:00
Chris Lattner 66b67efa61 C++ explicitly allows an empty source file.
llvm-svn: 41399
2007-08-25 05:47:03 +00:00
Chris Lattner e33fbdb898 Fix the test/Sema/format-strings.c regression. This code should be refactored.
llvm-svn: 41398
2007-08-25 05:36:18 +00:00
Chris Lattner 6d5922fd66 reenable this.
llvm-svn: 41397
2007-08-25 05:31:19 +00:00
Chris Lattner 9449fd7bc3 Fix the regression on test/Sema/cfstring.c
llvm-svn: 41396
2007-08-25 05:30:33 +00:00
Chris Lattner a206358bb6 test the parser only, not sema.
llvm-svn: 41395
2007-08-25 05:26:51 +00:00
Devang Patel 6114751544 Move exit condition and exit branch from exiting block into loop header and dominator info. This avoid execution of dead iteration. Loop is already filter in the beginning such that this change is safe.
llvm-svn: 41394
2007-08-25 02:39:24 +00:00
Chris Lattner 8692811955 Split the ASTNode out for compound assignments out from binary operators. Now
they show up in dumps etc.

llvm-svn: 41393
2007-08-25 02:00:02 +00:00
Chris Lattner d8c9fc5ed8 fix off-by-one error
llvm-svn: 41392
2007-08-25 01:55:00 +00:00
Chris Lattner e7d0864aed Fix clang -parse-ast-dump carbon.c
llvm-svn: 41391
2007-08-25 01:49:16 +00:00
Chris Lattner 4d15a0dbc0 rename sNames -> StmtClassInfo. Make lookups constant time.
llvm-svn: 41390
2007-08-25 01:42:24 +00:00
Devang Patel c1ef32ef3d Constant split values needs upper bound and lower bound check, just like any other split value.
llvm-svn: 41389
2007-08-25 01:09:14 +00:00
Chris Lattner 2ed652f11d Allow target constants to be illegal types. The target should
know how to handle them.  This fixes 
test/CodeGen/Generic/asm-large-immediate.ll

llvm-svn: 41388
2007-08-25 01:00:22 +00:00
Devang Patel 4e63e1f5b5 While calculating upper loop bound for first loop and lower loop bound for second loop, take care of edge cases.
llvm-svn: 41387
2007-08-25 00:56:38 +00:00
Chris Lattner dbfc4e4b07 Teach the dag scheduler to handle inline asm nodes with multi-value immediate operands.
llvm-svn: 41386
2007-08-25 00:53:07 +00:00
Bill Wendling 48597b4ff8 The personality function might need to be declared as:
.set  Lset0,___gxx_personality_v0-.
    .long Lset0

on some targets. Make it so!

llvm-svn: 41385
2007-08-25 00:51:55 +00:00
Chris Lattner d8c9cb9182 rename isOperandValidForConstraint to LowerAsmOperandForConstraint,
changing the interface to allow for future changes.

llvm-svn: 41384
2007-08-25 00:47:38 +00:00
Dale Johannesen 45e608ad75 Comment out declaration of operator== (undefined).
llvm-svn: 41383
2007-08-25 00:40:41 +00:00
Neil Booth 02ca902a40 Test
llvm-svn: 41382
2007-08-25 00:36:22 +00:00
Neil Booth 2873711c40 Add self
llvm-svn: 41381
2007-08-25 00:31:24 +00:00
Tanya Lattner ebd4e7ba2f Rename llvm-gcc4 to llvm-gcc.
llvm-svn: 41380
2007-08-24 23:23:23 +00:00
Steve Naroff 0c1c7ed5e6 This modest change insures ImplicitCastExpr's get generated for all "assignments",
while includes init decls, assignment exprs, call exprs, and return statements.

Here are a few examples with the correct AST's...

[dylan:~/llvm/tools/clang] admin% cat impcomp.c

_Complex double X;
void test2(int c) {
  X = 5;
}
void foo() {
  int i;
  double d = i;
  double _Complex a = 5;

  test2(a);
  a = 5;
  d = i;
}


[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang impcomp.c -parse-ast-dump
Read top-level variable decl: 'X'

void test2(int c)
(CompoundStmt 0x2605ce0
  (BinaryOperator 0x2605cc0 '_Complex double' '='
    (DeclRefExpr 0x2605c70 '_Complex double' Decl='X' 0x2605af0)
    (ImplicitCastExpr 0x2605cb0 '_Complex double'
      (IntegerLiteral 0x2605c90 'int' 5))))


void foo()
(CompoundStmt 0x2606030
  (DeclStmt 0x2605bd0
    0x2605d90 "int i")
  (DeclStmt 0x2605e20
    0x2605de0 "double d =
      (ImplicitCastExpr 0x2605e10 'double'
        (DeclRefExpr 0x2605dc0 'int' Decl='i' 0x2605d90))")
  (DeclStmt 0x2605e90
    0x2605e50 "_Complex double a =
      (ImplicitCastExpr 0x2605e80 '_Complex double'
        (IntegerLiteral 0x2605e30 'int' 5))")
  (CallExpr 0x2605f20 'void'
    (ImplicitCastExpr 0x2605f00 'void (*)(int)'
      (DeclRefExpr 0x2605ea0 'void (int)' Decl='test2' 0x2605c00))
    (ImplicitCastExpr 0x2605f10 'int'
      (DeclRefExpr 0x2605ec0 '_Complex double' Decl='a' 0x2605e50)))
  (BinaryOperator 0x2605fa0 '_Complex double' '='
    (DeclRefExpr 0x2605f50 '_Complex double' Decl='a' 0x2605e50)
    (ImplicitCastExpr 0x2605f90 '_Complex double'
      (IntegerLiteral 0x2605f70 'int' 5)))
  (BinaryOperator 0x2606010 'double' '='
    (DeclRefExpr 0x2605fc0 'double' Decl='d' 0x2605de0)
    (ImplicitCastExpr 0x2606000 'double'
      (DeclRefExpr 0x2605fe0 'int' Decl='i' 0x2605d90))))

llvm-svn: 41379
2007-08-24 22:33:52 +00:00
Dale Johannesen bdea32d812 Poison APFloat::operator==. Replace existing uses with bitwiseIsEqual.
This means backing out the preceding change to Constants.cpp, alas.

llvm-svn: 41378
2007-08-24 22:09:56 +00:00
Chris Lattner 74ed76bb0e remove a dead argument
llvm-svn: 41377
2007-08-24 21:41:10 +00:00
Chris Lattner 9f0ad96b3e implement codegen for real/imag. TODO: imag of non-complex.
llvm-svn: 41376
2007-08-24 21:20:17 +00:00
Chris Lattner 30b5dd0b79 Implement sema support for __real/__imag nodes.
llvm-svn: 41375
2007-08-24 21:16:53 +00:00
Ted Kremenek 066dd939c0 Added child_begin/child_end to all subclasses of Stmt in Stmt.h. All
concrete subclasses of Stmt are now required to implement 
child_begin/child_end.

llvm-svn: 41374
2007-08-24 21:09:09 +00:00
Chris Lattner 3d966d6556 Teach emit-llvm for scalars to properly handle compound assignment
operators in all their glory :)

llvm-svn: 41373
2007-08-24 21:00:35 +00:00
Dale Johannesen 7891d8edf0 Use APFloat internally for ConstantFPSDNode.
llvm-svn: 41372
2007-08-24 20:59:15 +00:00
Chris Lattner 0b490b0d38 sink clone() down the class hierarchy from CmpInst into ICmpInst/FCmpInst.
This eliminates a conditional on that path, and ensures ICmpInst/FCmpInst
both have an out-of-line virtual method to home the class.

llvm-svn: 41371
2007-08-24 20:48:18 +00:00