]> granicus.if.org Git - clang/log
clang
17 years agoReimplement SourceLocation. Instead of having a
Chris Lattner [Fri, 20 Jul 2007 16:37:10 +0000 (16:37 +0000)]
Reimplement SourceLocation.  Instead of having a
fileid/offset pair, it now contains a bit discriminating between
mapped locations and file locations.  This separates the tables for
macros and files in SourceManager, and allows better separation of
concepts in the rest of the compiler.  This allows us to have *many*
macro instantiations before running out of 'addressing space'.

This is also more efficient, because testing whether something is a
macro expansion is now a bit test instead of a table lookup (which
also used to require having a srcmgr around, now it doesn't).

This is fully functional, but there are several refinements and
optimizations left.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40103 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoimplement size/alignment analysis for arrays and vectors. This gets carbon.h working...
Chris Lattner [Thu, 19 Jul 2007 22:06:24 +0000 (22:06 +0000)]
implement size/alignment analysis for arrays and vectors.  This gets carbon.h working again.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40068 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoFinish fixing crasher with compound literals.
Steve Naroff [Thu, 19 Jul 2007 21:32:11 +0000 (21:32 +0000)]
Finish fixing crasher with compound literals.

We still need to do sematic analysis (and implement initializers), however this
should complete the parsing & ast building for compound literals.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40067 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoFix a stringizing bug that Neil noticed. We should preprocess this:
Chris Lattner [Thu, 19 Jul 2007 16:11:58 +0000 (16:11 +0000)]
Fix a stringizing bug that Neil noticed.  We should preprocess this:
#define t(x) #x
t(a
c)

to "a c", not "ac".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40060 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agosilence a warning by treating ocuvectors the same as vectors.
Chris Lattner [Thu, 19 Jul 2007 05:13:51 +0000 (05:13 +0000)]
silence a warning by treating ocuvectors the same as vectors.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40037 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoWork towards fixing crasher with compound literals...
Steve Naroff [Thu, 19 Jul 2007 01:06:55 +0000 (01:06 +0000)]
Work towards fixing crasher with compound literals...

Before this commit, we crashed in ParseBinOp...

[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang -parse-ast-check compound_literal.c
SemaExpr.cpp:1298: failed assertion `(rhs != 0) && "ParseBinOp(): missing right expression"'

With this commit, we still crash in the newly added action ParseCompoundLiteral (which is progress:-)

[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang -parse-ast-check compound_literal.c
SemaExpr.cpp:478: failed assertion `(Op != 0) && "ParseCompoundLiteral(): missing expression"'

The crash go away once the actions return AST nodes. I will do this in a separate commit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40032 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoFix a crasher that Neil reported: Sema::GetTypeForDeclarator should never
Chris Lattner [Thu, 19 Jul 2007 00:42:40 +0000 (00:42 +0000)]
Fix a crasher that Neil reported: Sema::GetTypeForDeclarator should never
return a null type.  If there is an error parsing the type, pick a new type
for error recovery purposes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40029 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoMake sure to initialize an ivar, patch by Benoit Boissinot.
Chris Lattner [Thu, 19 Jul 2007 00:11:19 +0000 (00:11 +0000)]
Make sure to initialize an ivar, patch by Benoit Boissinot.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40027 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoCorrectly respect C99 5.1.1.2p4 when searching for the first '(' of
Chris Lattner [Thu, 19 Jul 2007 00:07:36 +0000 (00:07 +0000)]
Correctly respect C99 5.1.1.2p4 when searching for the first '(' of
a function-like macro invocation.  Patch contributed by Neil Booth.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40026 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoimplement i-c-e correct evaluation for sizeof/alignof, remove some obsolete fixme's.
Chris Lattner [Wed, 18 Jul 2007 18:38:36 +0000 (18:38 +0000)]
implement i-c-e correct evaluation for sizeof/alignof, remove some obsolete fixme's.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40012 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoimplement sizeof/alignof support for structs, unions and complex.
Chris Lattner [Wed, 18 Jul 2007 18:26:58 +0000 (18:26 +0000)]
implement sizeof/alignof support for structs, unions and complex.

This allows us to compile this:

struct abc { char A; double D; };

int foo() {
  return sizeof(struct abc);
  return __alignof__(struct abc);
}

Into:

        ret i32 16
        ret i32 8

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40010 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoimplement codegen support for sizeof/alignof
Chris Lattner [Wed, 18 Jul 2007 18:12:07 +0000 (18:12 +0000)]
implement codegen support for sizeof/alignof

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40009 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoFirst round of extended vector support. Here is an overview...
Steve Naroff [Wed, 18 Jul 2007 18:00:27 +0000 (18:00 +0000)]
First round of extended vector support. Here is an overview...

- added ocu_vector_type attribute, Sema::HandleOCUVectorTypeAttribute().
- added new AST node, OCUVectorType, a subclass of VectorType.
- added ASTContext::getOCUVectorType.
- changed ASTContext::convertToVectorType() to ASTContext::getVectorType(). This is
unrelated to extended vectors, however I was in the vicinity and it was on my todo list.
Added a FIXME to Sema::HandleVectorTypeAttribute to deal with converting complex types.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40007 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoinitial layout support for structures and unions. This isn't actually
Chris Lattner [Wed, 18 Jul 2007 17:52:12 +0000 (17:52 +0000)]
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

17 years agoadd accessors
Chris Lattner [Wed, 18 Jul 2007 17:50:10 +0000 (17:50 +0000)]
add accessors

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40005 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoCast to void is valid, patch by Benoit Boissinot
Chris Lattner [Wed, 18 Jul 2007 16:00:06 +0000 (16:00 +0000)]
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

17 years agoteach -stats about new types
Chris Lattner [Wed, 18 Jul 2007 05:50:59 +0000 (05:50 +0000)]
teach -stats about new types

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39996 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoadd a note Neil pointed out
Chris Lattner [Wed, 18 Jul 2007 05:21:20 +0000 (05:21 +0000)]
add a note Neil pointed out

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39994 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoAdd initial switch stmt support, patch by Anders Carlsson!
Chris Lattner [Wed, 18 Jul 2007 02:28:47 +0000 (02:28 +0000)]
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

17 years agostrtod is more portable than strtof apparently. Instead of making this conditional,
Chris Lattner [Tue, 17 Jul 2007 15:27:33 +0000 (15:27 +0000)]
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

17 years agocheap change to fix solaris compilation. I can make this a static inline if desired
Gabor Greif [Tue, 17 Jul 2007 11:05:49 +0000 (11:05 +0000)]
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

17 years agoUse the correct method for getting the ReferenceType from a QualType.
Bill Wendling [Tue, 17 Jul 2007 05:09:22 +0000 (05:09 +0000)]
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

17 years agoI forgot to check this in earlier
Chris Lattner [Tue, 17 Jul 2007 04:58:06 +0000 (04:58 +0000)]
I forgot to check this in earlier

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39958 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoReturn the correct type from isReferenceType().
Bill Wendling [Tue, 17 Jul 2007 04:47:36 +0000 (04:47 +0000)]
Return the correct type from isReferenceType().

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39956 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoChange dyn_cast for reference types to be more like pointers and not need the canonic...
Bill Wendling [Tue, 17 Jul 2007 04:16:47 +0000 (04:16 +0000)]
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

17 years agoFix references:
Bill Wendling [Tue, 17 Jul 2007 03:52:31 +0000 (03:52 +0000)]
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

17 years agoConvert UsualArithmeticConversions to return "void". Now that we synthesize ImplicitC...
Steve Naroff [Tue, 17 Jul 2007 00:58:39 +0000 (00:58 +0000)]
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

17 years agoImplement semantic analysis for the cast operator.
Steve Naroff [Mon, 16 Jul 2007 23:25:18 +0000 (23:25 +0000)]
Implement semantic analysis for the cast operator.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39943 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoRemove the 2 QualType references to method UsualArithmeticConversions. Last week...
Steve Naroff [Mon, 16 Jul 2007 22:23:01 +0000 (22:23 +0000)]
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

17 years agoIn the final step for preserving typedef info better in the AST, upgrade
Chris Lattner [Mon, 16 Jul 2007 22:05:22 +0000 (22:05 +0000)]
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

17 years agoChange DefaultFunctionArrayConversions and UsualUnaryConversions to return void....
Steve Naroff [Mon, 16 Jul 2007 21:54:35 +0000 (21:54 +0000)]
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

17 years agoFix a GCC warning:
Chris Lattner [Mon, 16 Jul 2007 21:39:03 +0000 (21:39 +0000)]
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

17 years agoImplement break and continue. Patch by Anders Carlsson!
Chris Lattner [Mon, 16 Jul 2007 21:28:45 +0000 (21:28 +0000)]
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

17 years agoavoid requiring people to update from llvm svn.
Chris Lattner [Mon, 16 Jul 2007 21:04:56 +0000 (21:04 +0000)]
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

17 years agoConstify the is*Lvalue() methods.
Bill Wendling [Mon, 16 Jul 2007 07:07:56 +0000 (07:07 +0000)]
Constify the is*Lvalue() methods.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39907 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoMake octal constant lexing use AdvanceToTokenCharacter to give more
Chris Lattner [Mon, 16 Jul 2007 06:55:01 +0000 (06:55 +0000)]
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

17 years agoAdd a new Preprocessor::AdvanceToTokenCharacter method which, given a sloc
Chris Lattner [Mon, 16 Jul 2007 06:48:38 +0000 (06:48 +0000)]
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

17 years agoadd better comments.
Chris Lattner [Mon, 16 Jul 2007 06:46:50 +0000 (06:46 +0000)]
add better comments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39904 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agofactor a common predicate into a static method.
Chris Lattner [Mon, 16 Jul 2007 06:16:59 +0000 (06:16 +0000)]
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

17 years agoAdd a hack (mirroring llvm-gcc) to pointer difference
Chris Lattner [Mon, 16 Jul 2007 05:43:05 +0000 (05:43 +0000)]
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

17 years agoadd required directories to the path automatically, so the user doesn't need to worry...
Chris Lattner [Mon, 16 Jul 2007 04:35:52 +0000 (04:35 +0000)]
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

17 years agoMake check conflicts with the other default llvm target, 'make check' will come later...
Chris Lattner [Mon, 16 Jul 2007 04:30:36 +0000 (04:30 +0000)]
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

17 years ago'make check' is what more people expect.
Chris Lattner [Mon, 16 Jul 2007 04:26:57 +0000 (04:26 +0000)]
'make check' is what more people expect.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39899 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoDoug Gregor pointed out that _Complex actually isn't C++ at all.
Chris Lattner [Mon, 16 Jul 2007 04:22:42 +0000 (04:22 +0000)]
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

17 years agoAdd support for C++'0x keywords, patch by Doug Gregor
Chris Lattner [Mon, 16 Jul 2007 04:18:29 +0000 (04:18 +0000)]
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

17 years agoNow that isPointerType can return a pointer type, avoid stripping off typedef
Chris Lattner [Mon, 16 Jul 2007 00:23:25 +0000 (00:23 +0000)]
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

17 years agoUse the return value of isPointerType and isVectorType to significantly simplify
Chris Lattner [Mon, 16 Jul 2007 00:14:47 +0000 (00:14 +0000)]
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

17 years agoas a very useful feature, make isVectorType and isPointerType return
Chris Lattner [Mon, 16 Jul 2007 00:13:25 +0000 (00:13 +0000)]
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

17 years agorename variables to be more consistent. Always use LHS/RHS intead of T1/T2 sometimes.
Chris Lattner [Sun, 15 Jul 2007 23:59:53 +0000 (23:59 +0000)]
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

17 years agoRemove an extraneous QualType from CastExpr, it's type is always
Chris Lattner [Sun, 15 Jul 2007 23:54:50 +0000 (23:54 +0000)]
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

17 years agodon't let builtin-type handling code fall into pointer handling code
Chris Lattner [Sun, 15 Jul 2007 23:46:53 +0000 (23:46 +0000)]
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

17 years agoset the correct width for a character literal when evaluating it as an i-c-e.
Chris Lattner [Sun, 15 Jul 2007 23:32:58 +0000 (23:32 +0000)]
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

17 years agoRefactor code so that isIntegerConstantExpr has an ASTContext available.
Chris Lattner [Sun, 15 Jul 2007 23:26:56 +0000 (23:26 +0000)]
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

17 years agoremove obsolete comment.
Chris Lattner [Sun, 15 Jul 2007 06:46:25 +0000 (06:46 +0000)]
remove obsolete comment.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39868 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoChange SourceManager::getInstantiationLoc to take virtual locations, doing its
Chris Lattner [Sun, 15 Jul 2007 06:35:27 +0000 (06:35 +0000)]
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

17 years agoThis is the final step/commit for implementing exlicit implicit casts. Unlike the
Steve Naroff [Sun, 15 Jul 2007 02:02:06 +0000 (02:02 +0000)]
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

17 years agonon-apple targets should be like i386, not the mythical, bogus, linux target.
Chris Lattner [Sun, 15 Jul 2007 01:37:36 +0000 (01:37 +0000)]
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

17 years agoCache macro expander objects to avoid thrashing malloc in heavy expansion situations.
Chris Lattner [Sun, 15 Jul 2007 00:25:26 +0000 (00:25 +0000)]
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

17 years agoMake parser scope cache be a member of the parser instead of a global,
Chris Lattner [Sun, 15 Jul 2007 00:04:39 +0000 (00:04 +0000)]
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

17 years agoswitch function-like macros from using a vector for their arguments to an
Chris Lattner [Sat, 14 Jul 2007 22:46:43 +0000 (22:46 +0000)]
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

17 years agoswitch from using a vector to a smallvector for macro replacement tokens
Chris Lattner [Sat, 14 Jul 2007 22:15:50 +0000 (22:15 +0000)]
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

17 years agoexpose an iterator interface to getReplacementTokens instead of the datastructure...
Chris Lattner [Sat, 14 Jul 2007 22:11:41 +0000 (22:11 +0000)]
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

17 years agosplit function-like and object-like macro body parsing to make the
Chris Lattner [Sat, 14 Jul 2007 21:54:03 +0000 (21:54 +0000)]
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

17 years agoadd FIXME and un-XFAIL test
Gabor Greif [Sat, 14 Jul 2007 20:05:18 +0000 (20:05 +0000)]
add FIXME and un-XFAIL test

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39858 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoAdd missing directory
Bill Wendling [Sat, 14 Jul 2007 09:37:10 +0000 (09:37 +0000)]
Add missing directory

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39853 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoA significant refactoring of the type size stuff to also
Chris Lattner [Sat, 14 Jul 2007 01:29:45 +0000 (01:29 +0000)]
A significant refactoring of the type size stuff to also
compute type alignment.  This info is needed for struct layout.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39850 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoImplement trivial integer initializers, like 'int X = 4;' for global
Chris Lattner [Sat, 14 Jul 2007 00:23:28 +0000 (00:23 +0000)]
Implement trivial integer initializers, like 'int X = 4;' for global
vars.  Approach suggested by Keith.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39849 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoIn "int X,Y;", compile both X and Y.
Chris Lattner [Sat, 14 Jul 2007 00:16:50 +0000 (00:16 +0000)]
In "int X,Y;", compile both X and Y.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39848 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoadd a fixme
Chris Lattner [Sat, 14 Jul 2007 00:01:01 +0000 (00:01 +0000)]
add a fixme

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39847 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoImprove char literal pretty printing, patch by Keith Bauer!
Chris Lattner [Fri, 13 Jul 2007 23:58:20 +0000 (23:58 +0000)]
Improve char literal pretty printing, patch by Keith Bauer!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39846 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agofix type of main, use !=
Gabor Greif [Fri, 13 Jul 2007 23:40:27 +0000 (23:40 +0000)]
fix type of main, use !=

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39842 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoimplement _Complex * == and !=
Gabor Greif [Fri, 13 Jul 2007 23:33:18 +0000 (23:33 +0000)]
implement _Complex * == and !=

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39841 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoMore changes related to implementing ImplicitCastExpr.
Steve Naroff [Fri, 13 Jul 2007 23:32:42 +0000 (23:32 +0000)]
More changes related to implementing ImplicitCastExpr.

- Fixed a recent regression discovered by Keith Bauer (thanks!).
The fix involved adding (back) two arguments to UsualArithmeticConversions.
Without the reference arguments, no unary conversions were being passed back
to the caller. This had the effect of turning off the UsualUnaryConversions.
- Refactored CheckAssignmentConstraints into 3 functions. CheckAssignmentConstraints,
CheckSingleAssignmentConstraints, and CheckCompoundAssignmentConstraints.
- Changed the argument type of DefaultFunctionArrayConversion from QualType->Expr*&.
- Removed a bunch of casts in routines I was working on (cleanup).
- Fixed the visitor for ImplicitCastExpr (oops).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39840 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoUse target info to decide the sizes of basic types.
Chris Lattner [Fri, 13 Jul 2007 22:27:08 +0000 (22:27 +0000)]
Use target info to decide the sizes of basic types.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39838 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoAdd missing citation.
Chris Lattner [Fri, 13 Jul 2007 22:16:13 +0000 (22:16 +0000)]
Add missing citation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39837 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoa simple _Complex testcase
Gabor Greif [Fri, 13 Jul 2007 22:15:44 +0000 (22:15 +0000)]
a simple _Complex testcase

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39836 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoMove getSize() out of type, into ASTContext, where it has target info, and
Chris Lattner [Fri, 13 Jul 2007 22:13:22 +0000 (22:13 +0000)]
Move getSize() out of type, into ASTContext, where it has target info, and
where ASTContext can manage caches for struct layout, etc.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39835 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoUnspecified type specs default to int. This fixes a crash
Chris Lattner [Fri, 13 Jul 2007 21:02:29 +0000 (21:02 +0000)]
Unspecified type specs default to int.  This fixes a crash
on test/Sema/implicit-int.c

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39833 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoremove some extraneous spaces, no functionality change.
Chris Lattner [Fri, 13 Jul 2007 21:01:17 +0000 (21:01 +0000)]
remove some extraneous spaces, no functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39832 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoimplement codegen support for implicit casts.
Chris Lattner [Fri, 13 Jul 2007 20:25:53 +0000 (20:25 +0000)]
implement codegen support for implicit casts.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39831 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoeliminate extraneous type, add accessors.
Chris Lattner [Fri, 13 Jul 2007 20:25:36 +0000 (20:25 +0000)]
eliminate extraneous type, add accessors.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39830 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoCheck in these testcases.
Chris Lattner [Fri, 13 Jul 2007 20:18:44 +0000 (20:18 +0000)]
Check in these testcases.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39829 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agonew testcase that crashes the cfe due to implicit conversion fun
Chris Lattner [Fri, 13 Jul 2007 20:11:01 +0000 (20:11 +0000)]
new testcase that crashes the cfe due to implicit conversion fun

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39826 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agosilence a bogus gcc warning.
Chris Lattner [Fri, 13 Jul 2007 20:07:11 +0000 (20:07 +0000)]
silence a bogus gcc warning.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39824 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoRemoved some superfluous code. The getType() method and associated
Steve Naroff [Fri, 13 Jul 2007 17:39:21 +0000 (17:39 +0000)]
Removed some superfluous code. The getType() method and associated
assert is now done in UsualUnaryConversions().

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39818 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoremove use of alloca.
Chris Lattner [Fri, 13 Jul 2007 17:10:38 +0000 (17:10 +0000)]
remove use of alloca.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39815 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoAdd (explicit) AST support for implicit casts. This should simplify the
Steve Naroff [Fri, 13 Jul 2007 16:58:59 +0000 (16:58 +0000)]
Add (explicit) AST support for implicit casts. This should simplify the
code generator. Source translation tools can simply ignore this node.

- Added a new Expr node, ImplicitCastExpr.
- Changed UsualUnaryConversions/UsualArithmeticConversions to take references
to Expr *'s. This will allow these routines to instantiate the new AST node
and pass it back.
- Changed all clients of UsualUnary/UsualArithmetic (lot's of diff's).
- Changed some names in CheckConditionalOperands. Several variables where
only distinguished by their case (e.g. Cond, cond). Yuck (what was I thinking).
- Removed an old/crufty constructor in CastExpr (cleanup).

This check-in does not actually create the new AST node. I wanted to separate
the mechanical changes from the semantic changes. In addition, I need to
coordinate with Chris, since the semantic change will break the code generator.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39814 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agocheck in the basic llvm license
Chris Lattner [Fri, 13 Jul 2007 15:47:47 +0000 (15:47 +0000)]
check in the basic llvm license

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39812 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoSolaris needs an included header for alloca
Gabor Greif [Fri, 13 Jul 2007 08:21:39 +0000 (08:21 +0000)]
Solaris needs an included header for alloca

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39797 91177308-0d34-0410-b5e6-96231b3b80d8

17 years ago"Codegen for Character Literals and Conditional Operator
Chris Lattner [Fri, 13 Jul 2007 05:18:11 +0000 (05:18 +0000)]
"Codegen for Character Literals and Conditional Operator

Both in one patch, and the test case that Chris didn't commit last
time is in there too...

I'll split the patch up if somebody wants it split."

Patch by Keith Bauer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39796 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoimplement support for basic codegen of global variables with no initializers.
Chris Lattner [Fri, 13 Jul 2007 05:13:43 +0000 (05:13 +0000)]
implement support for basic codegen of global variables with no initializers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39795 91177308-0d34-0410-b5e6-96231b3b80d8

17 years ago"Someone typed "PtrToInt" where they meant "IntToPtr".
Chris Lattner [Fri, 13 Jul 2007 03:25:53 +0000 (03:25 +0000)]
"Someone typed "PtrToInt" where they meant "IntToPtr".

I've added a tests/CodeGen directory, and a test for this case that
used to fail and now passes."

Patch by Keith Bauer

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39794 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoImplement codegen for + and - with pointers. Patch contributed by
Chris Lattner [Fri, 13 Jul 2007 03:05:23 +0000 (03:05 +0000)]
Implement codegen for + and - with pointers.  Patch contributed by
Keith Bauer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39793 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoWorkaround gcc 3.4.x bug
Anton Korobeynikov [Fri, 13 Jul 2007 00:48:55 +0000 (00:48 +0000)]
Workaround gcc 3.4.x bug

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39792 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoTwo changes...
Steve Naroff [Thu, 12 Jul 2007 21:46:55 +0000 (21:46 +0000)]
Two changes...

- Teach all the integer/float predicates on Type about Vectors.
- Disallow bitwise compliment on float vectors. For example...

typedef float __attribute__(( vector_size(16) )) float4;

float4 float4_return()
{
    float4 xx;

    return ~xx;
}

...now emits the following diagnostic...

[administrators-powerbook59:~/llvm/tools/clang] admin% ../../Debug/bin/clang bug.c
bug.c:8:12: error: invalid argument type to unary expression 'float4'
    return ~xx;
           ^
1 diagnostic generated.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39791 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoupdate tests
Chris Lattner [Thu, 12 Jul 2007 16:52:08 +0000 (16:52 +0000)]
update tests

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39786 91177308-0d34-0410-b5e6-96231b3b80d8

17 years ago-pedantic no longer defaults to on.
Chris Lattner [Thu, 12 Jul 2007 16:49:27 +0000 (16:49 +0000)]
-pedantic no longer defaults to on.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39785 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoupdate test
Chris Lattner [Thu, 12 Jul 2007 16:48:52 +0000 (16:48 +0000)]
update test

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39784 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agodon't pick up random stuff in .svn directories.
Chris Lattner [Thu, 12 Jul 2007 16:46:07 +0000 (16:46 +0000)]
don't pick up random stuff in .svn directories.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39783 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoadd missing header
Gabor Greif [Thu, 12 Jul 2007 16:00:00 +0000 (16:00 +0000)]
add missing header
(needed on Solaris)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39781 91177308-0d34-0410-b5e6-96231b3b80d8