Граф коммитов

5403 Коммитов

Автор SHA1 Сообщение Дата
Chris Lattner 464175bba1 initial layout support for structures and unions. This isn't actually
hooked up to anything, so it's not very useful yet.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40006 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-18 17:52:12 +00:00
Chris Lattner a8fe39eb2b add accessors
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40005 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-18 17:50:10 +00:00
Chris Lattner 75af4801c8 Cast to void is valid, patch by Benoit Boissinot
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40003 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-18 16:00:06 +00:00
Chris Lattner 6d87fc66ca teach -stats about new types
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39996 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-18 05:50:59 +00:00
Chris Lattner ce0afc0b09 add a note Neil pointed out
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39994 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-18 05:21:20 +00:00
Chris Lattner 6c36be5b38 Add initial switch stmt support, patch by Anders Carlsson!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39989 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-18 02:28:47 +00:00
Chris Lattner 67798cb3dd strtod is more portable than strtof apparently. Instead of making this conditional,
just always use strtod.  This is temporary code anyway.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39972 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-17 15:27:33 +00:00
Gabor Greif 79cc005a07 cheap change to fix solaris compilation. I can make this a static inline if desired
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39970 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-17 11:05:49 +00:00
Bill Wendling ccb4af858b Use the correct method for getting the ReferenceType from a QualType.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39960 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-17 05:09:22 +00:00
Chris Lattner 9697a5c457 I forgot to check this in earlier
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39958 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-17 04:58:06 +00:00
Bill Wendling 251dcaf861 Return the correct type from isReferenceType().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39956 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-17 04:47:36 +00:00
Bill Wendling ea5e79f930 Change dyn_cast for reference types to be more like pointers and not need the canonical type. Also fix so that we're not expecting a return value from a void function
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39954 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-17 04:16:47 +00:00
Bill Wendling 08ad47cbd1 Fix references:
According to the spec (C++ 5p6[expr]), we need to adjust "T&" to
    "T" before further analysis. We do this via the "implicit cast"
    thingy.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39953 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-17 03:52:31 +00:00
Steve Naroff a4332e283e Convert UsualArithmeticConversions to return "void". Now that we synthesize ImplicitCastExpr's,
there is no compelling need to return the converted type. If both expression type's are arithmetic, then
both types will always be the same. If they aren't (for pointer/int types, say), then the
types will be different. The client is responsible for distinguishing...


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39947 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-17 00:58:39 +00:00
Steve Naroff 16beff8408 Implement semantic analysis for the cast operator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39943 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 23:25:18 +00:00
Steve Naroff 3e5e5560b3 Remove the 2 QualType references to method UsualArithmeticConversions. Last week, I added these
to quickly fix a regression. Avoiding them entirely is a much cleaner solution. Clients of 
UsualArithmeticConversions should simply call getType() on the expression to get the
converted type. In practice, only a small number of routines care about this.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39934 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 22:23:01 +00:00
Chris Lattner a2c7767ce7 In the final step for preserving typedef info better in the AST, upgrade
isPointerType and isVectorType to only look through a single level of typedef
when one is present.  For this invalid code:

typedef float float4 __attribute__((vector_size(16)));
typedef int int4 __attribute__((vector_size(16)));
typedef int4* int4p;
void test(float4 a, int4p result, int i) {
    result[i] = a;
}

we now get:

t.c:5:15: error: incompatible types assigning 'float4' to 'int4'
    result[i] = a;
    ~~~~~~~~~ ^ ~

instead of:

t.c:5:15: error: incompatible types assigning 'float4' to 'int  __attribute__((vector_size(16)))'
    result[i] = a;
    ~~~~~~~~~ ^ ~

The rest of the type predicates should be upgraded to do the same thing.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39932 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 22:05:22 +00:00
Steve Naroff c80b4eefa2 Change DefaultFunctionArrayConversions and UsualUnaryConversions to return void. The caller
needs to query the expression for the type. Since both these functions guarantee the expression 
contains a valid type, removed old/vacuous asserts (from code calling both of these routines).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39930 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 21:54:35 +00:00
Chris Lattner 26824906e5 Fix a GCC warning:
SemaExpr.cpp:561: warning: dereferencing type-punned pointer will break strict-aliasing rules

Patch by Benoit Boissinot!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39928 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 21:39:03 +00:00
Chris Lattner da13870e99 Implement break and continue. Patch by Anders Carlsson!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39927 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 21:28:45 +00:00
Chris Lattner f0fbcb356b avoid requiring people to update from llvm svn.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39925 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 21:04:56 +00:00
Bill Wendling ca51c97fbb Constify the is*Lvalue() methods.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39907 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 07:07:56 +00:00
Chris Lattner 136f93a2b6 Make octal constant lexing use AdvanceToTokenCharacter to give more
accurate diagnostics.  For test/Lexer/comments.c we now emit:

int x = 000000080;  /* expected-error {{invalid digit}} */
               ^
constants.c:7:4: error: invalid digit '8' in octal constant
00080;             /* expected-error {{invalid digit}} */
   ^


The last line is due to an escaped newline.  The full line looks like:

int y = 0000\
00080;             /* expected-error {{invalid digit}} */


Previously, we emitted:
constants.c:4:9: error: invalid digit '8' in octal constant
int x = 000000080;  /* expected-error {{invalid digit}} */
        ^
constants.c:6:9: error: invalid digit '8' in octal constant
int y = 0000\
        ^

which isn't too bad, but the new way is better for the user,
regardless of whether there is an escaped newline or not.

All the other lexer-related diagnostics should switch over 
to using AdvanceToTokenCharacter where appropriate.  Help
wanted :).

This implements test/Lexer/constants.c.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39906 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 06:55:01 +00:00
Chris Lattner 97ba77cf09 Add a new Preprocessor::AdvanceToTokenCharacter method which, given a sloc
specifying the start of a token and a logical (phase 3) character number,
returns a sloc representing the input character corresponding to it.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39905 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 06:48:38 +00:00
Chris Lattner 20e6ccd6f7 add better comments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39904 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 06:46:50 +00:00
Chris Lattner f66d3e390f factor a common predicate into a static method.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39903 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 06:16:59 +00:00
Chris Lattner 99e0d7905d Add a hack (mirroring llvm-gcc) to pointer difference
codegen to compile:

int test(int *A, int *B) {
  return A-B;
}

into:

_test:
        movl 4(%esp), %eax
        subl 8(%esp), %eax
        sarl $2, %eax
        ret

instead of:

_test:
        movl 4(%esp), %eax
        subl 8(%esp), %eax
        movl %eax, %ecx
        sarl $31, %ecx
        shrl $30, %ecx
        addl %ecx, %eax
        sarl $2, %eax
        ret



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39902 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 05:43:05 +00:00
Chris Lattner 1467e03df1 add required directories to the path automatically, so the user doesn't need to worry about it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39901 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 04:35:52 +00:00
Chris Lattner 7d5afc3982 Make check conflicts with the other default llvm target, 'make check' will come later I guess.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39900 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 04:30:36 +00:00
Chris Lattner 077c3f2d5c 'make check' is what more people expect.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39899 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 04:26:57 +00:00
Chris Lattner 9505581a3a Doug Gregor pointed out that _Complex actually isn't C++ at all.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39898 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 04:22:42 +00:00
Chris Lattner d4b80f1a0e Add support for C++'0x keywords, patch by Doug Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39897 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 04:18:29 +00:00
Chris Lattner 7a2e047c60 Now that isPointerType can return a pointer type, avoid stripping off typedef
information in the common case.  On this invalid code:

typedef float float4 __attribute__((vector_size(16)));
typedef int int4 __attribute__((vector_size(16)));
void test(float4 a, int4 *result, int i) {
    result[i] = a;
}

we now generate:
  t.c:5:15: error: incompatible types assigning 'float4' to 'int4'
instead of:
  t.c:5:15: error: incompatible types assigning 'float4' to 'int  __attribute__((vector_size(16)))'

This implements test/Sema/typedef-retain.c



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39892 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 00:23:25 +00:00
Chris Lattner 12d9ff6a07 Use the return value of isPointerType and isVectorType to significantly simplify
ParseArraySubscriptExpr.  Notably, the new code doesn't have to think about 
canonical types at all.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39891 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 00:14:47 +00:00
Chris Lattner 3acb138056 as a very useful feature, make isVectorType and isPointerType return
the actual vectortype or pointertype when they return success.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39890 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 00:13:25 +00:00
Chris Lattner 727a80dda3 rename variables to be more consistent. Always use LHS/RHS intead of T1/T2 sometimes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39889 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-15 23:59:53 +00:00
Chris Lattner 26dc7b3926 Remove an extraneous QualType from CastExpr, it's type is always
the result type of the expr node.

Implement isIntegerConstantExpr for ImplicitCastExpr nodes the same
was as for CastExpr nodes.

Implement proper sign/zero extension as well as truncation and noop
conversion in the i-c-e evaluator.  This allows us to correctly
handle i-c-e's like these:

char array[1024/(sizeof (long))];
int x['\xBb' == (char) 187 ? 1: -1];

this implements test/Sema/i-c-e2.c



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39888 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-15 23:54:50 +00:00
Chris Lattner bfef6d7c67 don't let builtin-type handling code fall into pointer handling code
not all builtin types have size and alignment equal to pointers :)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39887 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-15 23:46:53 +00:00
Chris Lattner 2eadfb638e set the correct width for a character literal when evaluating it as an i-c-e.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39886 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-15 23:32:58 +00:00
Chris Lattner 590b6646ef Refactor code so that isIntegerConstantExpr has an ASTContext available.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39884 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-15 23:26:56 +00:00
Chris Lattner dda75cf84c remove obsolete comment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39868 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-15 06:46:25 +00:00
Chris Lattner abca2bba54 Change SourceManager::getInstantiationLoc to take virtual locations, doing its
virtual->physical mapping explicitly.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39867 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-15 06:35:27 +00:00
Steve Naroff fa2eaabd30 This is the final step/commit for implementing exlicit implicit casts. Unlike the
previous two checkins, which involved lot's of tedious refactoring, this checkin is nice and clean:-)

- Hacked UsualUnaryConversions, UsualArithmeticConversions, and DefaultFunctionArrayConversion
to create the AST node (using a helper function promoteExprToType).
- Added a setType method to Expr.
- Changed Expr::isIntegerConstantExpr to allow for the new node.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39866 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-15 02:02:06 +00:00
Chris Lattner c3f8937483 non-apple targets should be like i386, not the mythical, bogus, linux target.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39865 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-15 01:37:36 +00:00
Chris Lattner 9594acf32d Cache macro expander objects to avoid thrashing malloc in heavy expansion situations.
This doesn't significantly improve carbon.h, but it does speed up
INPUTS/macro_pounder_obj.c by 48%



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39864 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-15 00:25:26 +00:00
Chris Lattner 9e344c65b1 Make parser scope cache be a member of the parser instead of a global,
which makes it multithread clean.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39863 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-15 00:04:39 +00:00
Chris Lattner 25c9648909 switch function-like macros from using a vector for their arguments to an
explicitly new'd array.  The array never mutates once created, so a vector
is overkill.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39862 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-14 22:46:43 +00:00
Chris Lattner f46f68b558 switch from using a vector to a smallvector for macro replacement tokens
This speeds up parsing carbon.h by 3.3% by avoiding some malloc traffic for 
small macros.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39861 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-14 22:15:50 +00:00
Chris Lattner c215bd659d expose an iterator interface to getReplacementTokens instead of the datastructure itself.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39860 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-14 22:11:41 +00:00
Chris Lattner b5e240fa9e split function-like and object-like macro body parsing to make the
code more obvious.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39859 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-14 21:54:03 +00:00