Commit Graph

318 Commits

Author SHA1 Message Date
Steve Naroff 3109001c19 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).

llvm-svn: 39930
2007-07-16 21:54:35 +00:00
Chris Lattner bb1b44f004 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.

llvm-svn: 39906
2007-07-16 06:55:01 +00:00
Chris Lattner fc7634f2ab "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

llvm-svn: 39794
2007-07-13 03:25:53 +00:00
Steve Naroff 1c8b7d36e6 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.

llvm-svn: 39791
2007-07-12 21:46:55 +00:00
Steve Naroff b207d6bed7 Bug #:
Submitted by:
Reviewed by:
Removed Attr.[h,cpp]...they didn't have any useful content.

When more (GCC) attributes are added, we might want to create a file
of this ilk. For now, it's better to remove them (to eliminate any confusion).

I also update the Xcode project file...

llvm-svn: 39729
2007-07-11 00:42:37 +00:00
Chris Lattner ea035b5fb8 remove diagchecker.h, add more missing files.
llvm-svn: 39702
2007-06-28 04:42:53 +00:00
Chris Lattner 76148a9ded add diag checker to xcode proj
llvm-svn: 39691
2007-06-27 17:25:13 +00:00
Chris Lattner 3e3a1e9cda implement lowering of complex types
llvm-svn: 39668
2007-06-22 18:15:26 +00:00
Chris Lattner 1fde0b345b implement codegen of the relational operations
One major FIXME though.

llvm-svn: 39666
2007-06-20 18:30:55 +00:00
Chris Lattner b3fef07a30 add new files to xcode project
llvm-svn: 39662
2007-06-16 00:17:33 +00:00
Chris Lattner 23cff88741 Update the xcode project for bill
llvm-svn: 39651
2007-06-13 20:14:12 +00:00
Steve Naroff 6d26a892d4 Bug #:
Submitted by:
Reviewed by:
Move Attr.h to the correct group in the Xcode project file...

llvm-svn: 39630
2007-06-09 03:59:22 +00:00
Steve Naroff b309644a35 Bug #:
Submitted by:
Reviewed by:
Lot's of attribute scaffolding.
Modernized ParseArraySubscriptExpr...call DefaultFunctionArrayConversion (which
simplified the logic considerably) and upgrade Diags to use the range support.

llvm-svn: 39628
2007-06-09 03:47:53 +00:00
Chris Lattner 2c1720681f add a new text file for low-prio QOI todos
llvm-svn: 39606
2007-06-08 17:15:31 +00:00
Chris Lattner 328fa5c913 Emit better diagnostics for out of range digits:
diag.c:1:9: error: invalid digit '8' in octal constant
int x = 000080;
        ^
diag.c:2:9: error: invalid digit 'A' in decimal constant
int z = 1000080ABC;
        ^

instead of:

diag.c:1:9: error: invalid suffix '80' on integer constant
int x = 000080;
        ^
diag.c:2:9: error: invalid suffix 'ABC' on integer constant
int z = 1000080ABC;
        ^

llvm-svn: 39605
2007-06-08 17:12:06 +00:00
Bill Wendling 37b1ddecf6 Submitted by: Bill Wendling
Reviewed by: Chris Lattner

- Separated out the diagnostic client from the clang driver. This is in
  preparation for creating a diagnostic client that will be used to check
  error and warning messages.

llvm-svn: 39603
2007-06-07 09:34:54 +00:00
Steve Naroff 98cf3e95ce Bug #:
Submitted by:
Reviewed by:

The following code illustrates a bug in the semantic analysis for assignments:

int func() {
  int *P;
  char *x;
  P = x; // type of this assignment expression should be "int *", NOT "char *".
}

While the type checking/diagnostics are correct, the type of the assignment
expression is incorrect (which shows up during code gen).  With the fix,
the llvm code looks correct...

[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang cast.c -emit-llvm
cast.c:4:5: warning: incompatible pointer types assigning 'char *' to 'int *'
  P = x; // type of assignment expression is "int *", NOT "char *".
  ~ ^ ~
; ModuleID = 'foo'

define i32 @func() {
entry:
        %P = alloca i32*                ; <i32**> [#uses=1]
        %x = alloca i8*         ; <i8**> [#uses=1]
        %allocapt = bitcast i32 undef to i32            ; <i32> [#uses=0]
        %tmp = load i8** %x             ; <i8*> [#uses=1]
        %conv = bitcast i8* %tmp to i32*                ; <i32*> [#uses=1]
        store i32* %conv, i32** %P
        ret i32 undef
}

Even though the fix was simple, I decided to rename/refactor the surrounding code
to make a clearer distinction between constraint checking and conversion.

- Renamed AssignmentConversionResult -> AssignmentCheckResult.
- Renamed UsualAssignmentConversions -> CheckAssignmentConstraints.
- Changed the return type of CheckAssignmentConstraints and CheckPointerTypesForAssignment
from QualType -> AssignmentCheckResult. These routines no longer take a reference to the result (obviously).
- Changed CheckAssignmentOperands to return the correct type (with spec annotations).

llvm-svn: 39601
2007-06-06 18:38:38 +00:00
Chris Lattner cf106ab42a implement support for casts to/from pointers.
llvm-svn: 39595
2007-06-06 04:05:39 +00:00
Chris Lattner 6563712933 xcode randomly changed the project, who knows what this does
llvm-svn: 39594
2007-06-05 20:53:44 +00:00
Steve Naroff 6d9de3dd74 Bug #:
Submitted by:
Reviewed by:
Touch up a couple comments (one was incorrect/out-of-date).

llvm-svn: 39589
2007-06-05 19:14:28 +00:00
Chris Lattner 946aa31f02 implement codegen of while stmts and lvalue evaluation of paren exprs :)
llvm-svn: 39582
2007-06-05 03:59:43 +00:00
Steve Naroff c27f89ebb3 Bug #:
Submitted by:
Reviewed by:
Apply UsualUnaryConversion() to statement conditions that expect scalars.
UsualUnaryConversion() converts function/arrays to pointers.

This fixes the following...

int func() {
  int A[10];
  while (A) {
  }
  if (A) ;
  for (; A; ) ;
}

llvm-svn: 39580
2007-06-03 18:23:48 +00:00
Chris Lattner d7f58867e5 Implement scaffolding for lvalues. Implement block vardecl lvalues.
This allows us to translate:

int func() {
  register int X;
  {
    int Y;
    return 1+X+Y;
  }
}

into:

define i32 @func() {
entry:
        %X = alloca i32         ; <i32*> [#uses=1]
        %Y = alloca i32         ; <i32*> [#uses=1]
        %allocapt = bitcast i32 undef to i32            ; <i32> [#uses=0]
        %tmp = load i32* %X             ; <i32> [#uses=1]
        %tmp1 = add i32 1, %tmp         ; <i32> [#uses=1]
        %tmp2 = load i32* %Y            ; <i32> [#uses=1]
        %tmp3 = add i32 %tmp1, %tmp2            ; <i32> [#uses=1]
        ret i32 %tmp3
                ; No predecessors!
        ret i32 undef
}

llvm-svn: 39555
2007-06-02 05:24:33 +00:00
Chris Lattner 5e1f32a16f reorder files alphabetically
llvm-svn: 39551
2007-06-02 04:47:52 +00:00
Chris Lattner 3e450f947b add new files.
llvm-svn: 39544
2007-06-02 00:01:41 +00:00
Steve Naroff 0f2fe17ff1 Bug #:
Submitted by:
Reviewed by:
Implement support for GCC __attribute__.

- Implement "TODO" in Parser::ParseAttributes. Changed the return type from
void to Parser::DeclTy. Changed all call sites to accept the return value.
- Added Action::ParseAttribute and Sema::ParseAttribute to return an
appropriate AST node. Added new node AttributeDecl to Decl.h.

Still to do...hook up to the Decl...

llvm-svn: 39539
2007-06-01 17:11:19 +00:00
Chris Lattner d1af2d2956 Implement conversion of clang ast types to LLVM types, at least for some trivial
cases.

llvm-svn: 39519
2007-05-29 23:17:50 +00:00
Steve Naroff 8563f65042 Bug #:
Submitted by:
Reviewed by:
Refine Sema::ParseCallExpr() diags (range support, add types).

Before:

func-assign.c:27:11: warning: passing argument 1 from incompatible pointer type
  pintFunc(&FOO);
          ^
func-assign.c:28:12: error: incompatible type for argument 1
  floatFunc(&FOO);
           ^
func-assign.c:29:12: error: too many arguments to function
  floatFunc(1,2,3);
           ^
After:

func-assign.c:27:11: warning: passing incompatible pointer 'struct foo *' to function expecting 'int *'
  pintFunc(&FOO);
  ~~~~~~~~^~~~~
func-assign.c:28:12: error: passing incompatible type 'struct foo *' to function expecting 'float'
  floatFunc(&FOO);
  ~~~~~~~~~^~~~~
func-assign.c:29:12: error: too many arguments to function
  floatFunc(1,2,3);
  ~~~~~~~~~^  ~

llvm-svn: 39513
2007-05-28 19:25:56 +00:00
Chris Lattner eefa10e78a implement full sema support for the GCC address-of-label extension.
llvm-svn: 39510
2007-05-28 06:56:27 +00:00
Chris Lattner bed314465a Reorganize codegen files.
llvm-svn: 39504
2007-05-28 01:07:47 +00:00
Steve Naroff 9358c715da Bug #:
Submitted by:
Reviewed by:
- Added type checking to Sema::ParseReturnStmt (still under construction).
- Improved Expr::isLvalue() and Expr::isModifiableLvalue() to return more
info. Used the info in Sema::CheckAssignmentOperands() to produce more
descriptive diagnostics. Added FIXME to other clients of isLvalue()/etc.
- Added a SourceLocation slot to MemberExpr...changed the implementation
of getSourceRange().
- Added getResultType() helper to FunctionDecl.
- Changed many Diag calls to use the SourceRange support (now that it's
a big hit...we better milk it:-).

llvm-svn: 39501
2007-05-27 23:58:33 +00:00
Chris Lattner f97fe38cb5 Initial scaffolding for an -emit-llvm mode. This requires the LLVM VMCore
library to be built for the driver to link.

llvm-svn: 39495
2007-05-24 06:29:05 +00:00
Chris Lattner c31f4545d1 add ParseExprCXX.cpp to project.
llvm-svn: 39491
2007-05-24 01:09:15 +00:00
Chris Lattner f95211394a implement printer support for C++ bool literals
llvm-svn: 39489
2007-05-24 00:50:25 +00:00
Steve Naroff 7fd6893333 Bug #:
Submitted by:
Reviewed by:
One bug compiling "Carbon.h" on Leopard, one diagnostic tweak.
- CheckIndirectionOperand wasn't operating on the canonical type (so it
was complaining about typedef names).
- The diagnostic was less than great. Here's what is was:

[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang t.c
t.c:4:3: error: invalid argument type to unary expression 'int'
 *p;
 ^~

And here's what I changed it to...

snaroff:clang naroff$ ../../Debug/bin/clang bug.c
bug.c:5:3: error: indirection requires a pointer ('int' operand invalid)
  *p;
  ^~

llvm-svn: 39481
2007-05-22 18:27:41 +00:00
Chris Lattner a8a2c82f55 Move ASTStreamer.h into "clang/Sema/ASTStreamer.h"
llvm-svn: 39478
2007-05-21 17:38:36 +00:00
Chris Lattner d1654ef0ed Split the AST library into two libraries: libast and libsema.
llvm-svn: 39477
2007-05-21 17:34:19 +00:00
Chris Lattner 67ca9252f8 Implement Sema::ParseNumericConstant for integer constants in terms of APInt
and correctly in terms of C99 6.4.4.1p5.

llvm-svn: 39473
2007-05-21 01:08:44 +00:00
Steve Naroff ada7d4298b Bug #:
Submitted by:
Reviewed by:
Fix two bugs...

- Sema::CheckConditionalOperands(). Needed to move the check for
null pointer constants up to the clause dealing with two pointers types.
The previous code would never get executed.
- Expr::isNullPointerConstant(). This predicate was much too naive...it
should have had a FIXME (my bad). It now deals with "void *" cast expressions.
It still has one major bug...it needs to evaluate the expression to correctly
determine if it is a null pointer constant (e.g. 7-7 should pass).

llvm-svn: 39464
2007-05-20 17:54:12 +00:00
Chris Lattner ebd1b33477 Use the new source ranges tracking feature to highlight the important pieces
of a subexpression when emitting a diagnostic.  Consider this example:

struct A { int X; };

void test1(void *P, int C) {
  return ((C*40) + *P) / 42+P;
}

void test2(struct A friendlystruct, int C) {
  return (C     *40) + friendlystruct;
}

void test3(struct A friendlystruct, int C) {
  return friendlystruct + test2(friendlystruct
                               , C);
}


clang now produces this output:

t.c:4:18: error: invalid operands to binary expression ('int' and 'void')
  return ((C*40) + *P) / 42+P;
          ~~~~~~ ^ ~~

This shows the important pieces of a nested (and potentially very complex)
expression.


t.c:8:18: error: invalid operands to binary expression ('int' and 'struct A')
  return (C     *40) + friendlystruct;
         ~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~

This shows that tabs in source files (after the 'C') and multichar tokens
(friendlystruct) are handled correctly.



t.c:12:25: error: invalid operands to binary expression ('struct A' and 'void')
  return friendlystruct + test2(friendlystruct
         ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~

This shows how multiline ranges are printed.  Any part of the range that is
not on the same line as the carat is just ignored.  This also shows that
trailing spaces on the line aren't highlighted.

llvm-svn: 39459
2007-05-19 08:06:14 +00:00
Steve Naroff e845e272ba Bug #:
Submitted by:
Reviewed by:
More tweaks to error diagnostics (adding types, using the new hooks on expr).
Still more to do...

llvm-svn: 39455
2007-05-18 01:06:45 +00:00
Steve Naroff a78fe7e3ed Bug #:
Submitted by:
Reviewed by:
- Implement type checking for Sema::CheckConditionalOperands.
- Fixed crasher in Sema::UsualUnaryConversion (incorrect use of cast<>).
- Added a few diagnostics and started passing 2 args! (Thanks Chris!).

Here's some diagnostic output that is much nicer than gcc...

[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang cond.c
cond.c:12:14: error: used type 'struct foo' where arithmetic or pointer type is required
  result = s ? 1 : 2;
             ^
cond.c:13:14: error: incompatible operand types ('struct foo' and 'struct bar')
  result = a ? s : s2;
             ^
cond.c:14:14: warning: pointer type mismatch ('struct foo *' and 'struct bar *')
  result = a ? ps : ps2;
             ^
cond.c:14:10: warning: assignment makes integer from pointer without a cast
  result = a ? ps : ps2;
         ^
cond.c:15:14: error: incompatible operand types ('struct foo *' and 'struct foo')
  result = a ? ps : s;
             ^
cond.c:16:14: warning: pointer type mismatch ('void (*)(int)' and 'void (*)(int, int)')
  result = a ? func : func2;
             ^
cond.c:16:10: warning: assignment makes integer from pointer without a cast
  result = a ? func : func2;
         ^
7 diagnostics generated.
[dylan:~/llvm/tools/clang] admin% cc -c cond.c
cond.c: In function 'main':
cond.c:12: error: used struct type value where scalar is required
cond.c:13: error: type mismatch in conditional expression
cond.c:14: warning: pointer type mismatch in conditional expression
cond.c:14: warning: assignment makes integer from pointer without a cast
cond.c:15: error: type mismatch in conditional expression
cond.c:16: warning: pointer type mismatch in conditional expression
cond.c:16: warning: assignment makes integer from pointer without a cast

llvm-svn: 39451
2007-05-16 19:47:19 +00:00
Chris Lattner 36982e4367 Add support for inserting up to 10 strings in a diagnostic, with %0, %1, %2,
etc.

llvm-svn: 39447
2007-05-16 17:49:37 +00:00
Steve Naroff 475cca0d1a Bug #:
Submitted by:
Reviewed by:
Fixed a bug in Sema::CheckAddressOfOperand(). It was (incorrectly) using
isModifiableLvalue() instead of isLvalue(). This motivated me to (finally)
cleanup methods surrounding lsLvalue/isModifiableLvalue. Cleanup involved:
- adding Expr::isLvalue().
- modified Expr::isModifiableLvalue() to use Expr::isLvalue().
- removed Type::isLvalue(), Type::isModifiableLvalue(), and
QualType::isModifiableLvalue(). They were confusing...the respective logic
is now a part of the Expr member functions...
- also added some comments and spec references, since these methods are
so central to expressions working properly.

llvm-svn: 39443
2007-05-14 17:19:29 +00:00
Steve Naroff 38a9dae33f Bug #:
Submitted by:
Reviewed by:
- implement Type::functionTypesAreCompatible().
- fix bug in Sema::CheckAssignmentOperands(). Spec allows any pointer type
to be assigned to _Bool.

llvm-svn: 39428
2007-05-02 19:22:16 +00:00
Chris Lattner 739e739b81 Remove the clang::SourceBuffer class, switch to the llvm::MemoryBuffer class.
llvm-svn: 39426
2007-04-29 07:12:06 +00:00
Steve Naroff 4750051ebb Bug #:
Submitted by:
Reviewed by:
Continue working on type checking for unary operators. Added:

- Two 3 private functions to Sema: CheckAddressOfOperand(), CheckIndirectionOperand(),
and getDecl().
- Added Expr::isLvalue() - it was needed for CheckAddressOfOperand(). It will
also be needed for ++/-- and the assignment operators.
- Added a couple diagnostics for invalid lvalues (for & of).

llvm-svn: 39408
2007-04-19 23:00:49 +00:00
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
Steve Naroff d50c88e489 Bug #:
Submitted by:
Reviewed by:
Fix "FIXME: does this lose qualifiers from the typedef??" in ASTContext::getTypedefType().

This change was fairly pervasive...nevertheless, here are the highlights:
- Change the type of Type::CanonicalType to TypeRef (was "Type *").
- Change the implementation of TypeRef::getCanonicalType() to work for typedefs.
- Make the implementation of Type::getCanonicalType private (only TypeRef should access). This
will force clients to use TypeRef::getCanonicalType (the correct version of the function). Since
TypeRef overloads "->", it was very easy to fall into this bug...
- Changed many references of "Type *" to "TypeRef"...when the raw type pointer is required, use t.getTypePtr().
- Changed all the *Type classes to take a TypeRef.
- Made the Type constructor protected (cleanup).
- Removed function Expr::getType().
- Convert functions in SemaExpr to use the above support. This fixed the "const" bug I was originally investigating.

I will follow this check-in up with a rename of TypeRef->QualType. I will also make sure the constructor does not default to 0 (which can lead to broken code...).

llvm-svn: 39394
2007-04-05 21:15:20 +00:00
Chris Lattner ef8743b4f6 Move LiteralSupport files to their alphabetic position.
llvm-svn: 39384
2007-04-04 06:45:50 +00:00
Steve Naroff ef2ab6a572 Bug #:
Submitted by:
Reviewed by:
Add three new classes to Decl.h: BlockVarDecl, FileVarDecl, and ParmVarDecl.

Made the constructor to VarDecl protected, to indicate it is "abstract".

Reorganized the Decl::Kind enum to allow us to add ObjectDecls/TypeDecls with
minimal breakage.  In the process, realized the isa support for ObjectDecl was already broken (so
the reorg paid for itself already:-) The range check should also be more efficient...

llvm-svn: 39373
2007-04-02 20:50:54 +00:00
Steve Naroff fc49d67add Bug #:
Submitted by:
Reviewed by:
- Finished up incomplete type analysis for varibles (in Sema::ParseDeclarator()).
- Added many spec refs, since this area is confusing (for top level decls
in particular).
- Added a FIXME to MergeVarDecl()...it needs to be taught about tentative
definitions. As a result, we currently issue some bogus diagnostics.

llvm-svn: 39372
2007-04-01 21:27:45 +00:00
Steve Naroff 09ef474197 Bug #:
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
2007-03-09 23:16:33 +00:00
Steve Naroff 8160ea2072 Bug #:
Submitted by:
Reviewed by:
More code to parse numeric constants. This checkin includes:
- Feedback from Chris.
- Support for parsing floating point constants.
- Moved the code to "Sema". Changed API in Action.
- More/better error diagnostics.

At this point, the parsing support should be largely complete. Next step
is to work on filling in sensible values (in IntegerLiteral/FloatLiteral).

llvm-svn: 39349
2007-03-06 01:09:46 +00:00
Steve Naroff 1fb30c5e99 Bug #:
Submitted by:
Reviewed by:
First phase of parsing IntegerConstants. At the moment, all processing
is done in the Parser, not Sema. If necessary, this is easy to move.
Next steps:
- Convert well for strings to actual values (need to look @ APInt.h)
- Design the API between the Parser and Sema. Sema shouldn't have to be
concerned with any parsing issues...

llvm-svn: 39348
2007-03-03 00:02:57 +00:00
Steve Naroff 7f890eb790 More changes to complete the dynamic type support for Stmt/Expr.
This set of changes includes:
- convert ExprCXX.h and add to the Xcode project file.
-- required adding CXXBoolLiteralExpr to StmtNodes.def.
-- required adding visitor support (decl/defn).
- make the class codes in StmtNodes.def explicit (to enable range checking).
-- this required changing all clients of the STMT macro.
- declare the instance data const.

llvm-svn: 39344
2007-02-27 02:53:10 +00:00
Steve Naroff ab62488ae3 rename IntegerConstant->IntegerLiteral
rename FloatingConstant->FloatingLiteral
rename StringExpr->StringLiteral

llvm-svn: 39341
2007-02-21 22:05:47 +00:00
Chris Lattner 10a5b387cc Add support for target-specific builtins, including detecting nonportability
of source code.  For example:

$ clang INPUTS/carbon_h.c -arch i386 -arch ppc
prints:
...
/usr/lib/gcc/i686-apple-darwin8/4.0.1/include/mmintrin.h:51:3: note: use of a target-specific builtin function, source is not 'portable'
  __builtin_ia32_emms ();
  ^

because carbon.h pulls in xmmintrin.h, and __builtin_ia32_emms isn't a builtin on ppc.

Though clang now supports target-specific builtins, the full table isn't implemented yet.

llvm-svn: 39328
2007-01-29 05:24:35 +00:00
Chris Lattner 9561a0b3e7 Add support for target-independent builtin functions (like __builtin_abs),
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
2007-01-28 08:20:04 +00:00
Chris Lattner 4194315681 Save the member list of a struct/union in the RecordDecl for the struct.
llvm-svn: 39297
2007-01-25 04:52:46 +00:00
Chris Lattner 7b9ace672b simplify structure body parsing code. Reorganize how tags are processed.
Diagnose redefintion of tag types, e.g.:

t.c:7:8: error: redefinition of 'blah'
struct blah {};
       ^
t.c:1:8: error: previous definition is here
struct blah {
       ^
2 diagnostics generated.

llvm-svn: 39286
2007-01-23 20:11:08 +00:00
Chris Lattner b8d6d5a81d Formalize preprocessor callbacks together into a PPCallbacks structure, instead
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
2006-11-21 04:09:30 +00:00
Chris Lattner 229ce60fc9 split the ParseFunctionDefinition action into two actions, one which is
called before and one which is called after function definition parsing.

llvm-svn: 39196
2006-11-21 01:21:07 +00:00
Chris Lattner 302b4be4c2 build TypedefDecl objects when parsing typedefs.
Add a parsing fastpath for when we see typedef at the top-level.

llvm-svn: 39182
2006-11-19 02:31:38 +00:00
Chris Lattner 9dfdb3c70d rearrange the type printing code so that we can do the horrible C "inside out"
thing properly.  This allows us to print types like:
int (*A)[restrict static 4][6];

properly, in addition to representing them properly. :)

llvm-svn: 39178
2006-11-13 07:38:09 +00:00
Chris Lattner 288e86ff15 Rename SemaDeclSpec.{h|cpp} back to DeclSpec.{h|cpp} now that the distinction
between sema and parse is clear.

llvm-svn: 39167
2006-11-11 23:03:42 +00:00
Chris Lattner f84a79c4e9 restructure code to build the framework for creating types from declarators.
llvm-svn: 39166
2006-11-11 22:59:23 +00:00
Chris Lattner cb6a382b67 introduce a new ASTContext class to hold long-lived ast nodes.
llvm-svn: 39161
2006-11-10 06:20:45 +00:00
Chris Lattner 88724336e9 with xcode bugs worked around, I can actually add files to the project, woo
llvm-svn: 39160
2006-11-10 05:33:04 +00:00
Chris Lattner af8d581230 move semantic analysis of statements to it's own file.
llvm-svn: 39156
2006-11-10 05:07:45 +00:00
Chris Lattner ddd6fc84cf move ASTBuilder.h/cpp to be a private Sema.h/cpp files, not part of the
interface exported by libast.

llvm-svn: 39154
2006-11-10 04:58:55 +00:00
Chris Lattner ce76529a56 move Type.h to libAST
llvm-svn: 39152
2006-11-09 06:37:20 +00:00
Chris Lattner 697e5d692b Change courses on how we do semantic analysis. Semantic analysis
fundamentally requires having an AST around, so move all sema to the
AST library.  This is the first step, later steps will be needed to
clean up libast.

llvm-svn: 39150
2006-11-09 06:32:27 +00:00
Chris Lattner 289ab7bb1d rename SemaDecl.cpp/h to SemaDeclSpec.cpp/h
llvm-svn: 39149
2006-11-08 06:54:53 +00:00
Chris Lattner 87ca807e15 add Type.h to the project
llvm-svn: 39146
2006-11-08 06:03:37 +00:00
Chris Lattner b6a0e1781f implement trivial scope caching. This reduces malloc traffic in the common
case, speeding up parsing of this contrived example:

#define A {{}}
#define B A A A A A A A A A A
#define C B B B B B B B B B B
#define D C C C C C C C C C C
#define E D D D D D D D D D D
#define F E E E E E E E E E E
#define G F F F F F F F F F F
#define H G G G G G G G G G G

void foo() {
  H
}

from 7.478s to 4.321s.  GCC requires 8.2s.

llvm-svn: 39138
2006-11-06 00:22:42 +00:00
Chris Lattner 33ad2cacc9 Make Scope keep track of the kind of scope it is. Properly scope loop and
switch statements.  Make break/continue check that they are inside of an
appropriate control-flow construct.  This implements Parser/bad-control.c.

llvm-svn: 39136
2006-11-05 23:47:55 +00:00
Chris Lattner c19ddcd6dd rename EmptyAction.cpp -> MinimalAction.cpp
llvm-svn: 39135
2006-11-05 18:46:16 +00:00
Chris Lattner 7ad0fbe1f2 rename a bunch of files for better consistency
llvm-svn: 39126
2006-11-05 07:46:30 +00:00
Chris Lattner 76af84462c use the StmtNodes.def database to eliminate redundant code.
llvm-svn: 39118
2006-11-04 20:54:18 +00:00
Chris Lattner 6fef2fb277 Add a new StmtNodes.def file as a catalog of all the Stmt's. This helps
eliminate repetitive code.

llvm-svn: 39117
2006-11-04 20:49:30 +00:00
Chris Lattner 72b7d39d78 remove full locinfo AST nodes for now. They just clutter the implementation
and should be implemented with an ASTBuilder subclass anyway.

llvm-svn: 39107
2006-11-04 06:37:16 +00:00
Chris Lattner 469d357425 implement visitor chaining.
llvm-svn: 39105
2006-11-04 06:32:52 +00:00
Chris Lattner 5e9a878126 add a new StmtVisitor class for traversing Stmt/Expr nodes.
llvm-svn: 39104
2006-11-04 06:21:51 +00:00
Chris Lattner 569ce145d8 rename Builder.cpp -> ASTBuilder.cpp
llvm-svn: 39096
2006-11-03 06:45:47 +00:00
Chris Lattner e5cca06829 Make AST nodes for ReturnStmt's and CompoundStmts
llvm-svn: 39046
2006-10-25 04:29:46 +00:00
Chris Lattner f42cce7a8e Add new Stmt class
llvm-svn: 39045
2006-10-25 04:09:21 +00:00
Chris Lattner 0ba3dc4ec3 Start removing LexerToken from the actions interface.
llvm-svn: 39043
2006-10-25 03:38:23 +00:00
Chris Lattner 8120bc7e4a add new DirectoryLookup.h file
llvm-svn: 39032
2006-10-22 07:26:43 +00:00
Chris Lattner 6cd618c3e8 update
llvm-svn: 39030
2006-10-22 06:34:13 +00:00
Chris Lattner 63dd32b656 Implement subframework lookup
llvm-svn: 39015
2006-10-20 04:42:40 +00:00
Chris Lattner 59a9ebdb17 refactor header searching stuff out of the main Preprocessor object into
it's own HeaderSearch object.  This makes Preprocessor simpler and easier
to understand.

llvm-svn: 39012
2006-10-18 05:34:33 +00:00
Chris Lattner 1ff0ed1d24 update
llvm-svn: 39010
2006-10-18 04:02:58 +00:00
Chris Lattner a11999d83a start creating proper ast nodes for variables and functions
llvm-svn: 38991
2006-10-15 22:34:45 +00:00
Chris Lattner 2cbe715b79 Add Targets.cpp.
llvm-svn: 38973
2006-10-14 07:39:38 +00:00
Chris Lattner 1e27fe165c Add new TargetInfo class to clang.
llvm-svn: 38971
2006-10-14 07:06:20 +00:00
Chris Lattner d3e9895b9a Initial support for semantic analysis and AST building for StringExpr nodes.
llvm-svn: 38960
2006-10-06 05:22:26 +00:00
Chris Lattner 940edd4cff Move clang driver into Driver subdir
llvm-svn: 38957
2006-10-06 04:16:30 +00:00
Chris Lattner 1b92649857 Add AST nodes and actions for paren exprs and simple unary ops.
llvm-svn: 38940
2006-08-23 06:42:10 +00:00
Chris Lattner 9b6d4cb90e Add (basic) expression AST representation capabilities for int/fp/binops/condexpr.
Add callbacks for same.
Add "full locinfo" mode.

llvm-svn: 38939
2006-08-23 05:17:46 +00:00
Chris Lattner c11438cee1 Implement first cut of ASTBuilder class.
llvm-svn: 38938
2006-08-18 05:17:52 +00:00
Chris Lattner 01b0f1be80 xcode 2.4
llvm-svn: 38937
2006-08-18 03:44:41 +00:00
Chris Lattner 73709eda2b Stub out the ASTStreamer
llvm-svn: 38935
2006-08-17 06:28:25 +00:00
Chris Lattner 3e7bd4ed44 Start adding support for printing out parser callbacks and adding ast building
llvm-svn: 38933
2006-08-17 05:51:27 +00:00
Chris Lattner 685ed1e9ee Rename Parse/ParserActions.h -> Parse/Action.h
llvm-svn: 38913
2006-08-14 00:22:04 +00:00
Chris Lattner 4bb61de36c Remove Actions.cpp, it is and always will be empty.
llvm-svn: 38912
2006-08-14 00:15:57 +00:00
Chris Lattner 8693a519d4 Implement initializer parsering.
llvm-svn: 38900
2006-08-13 21:54:02 +00:00
Chris Lattner ee2cdfdd2d Move files around
llvm-svn: 38857
2006-08-10 19:05:43 +00:00
Chris Lattner c951dae2a4 Parse if statements
llvm-svn: 38844
2006-08-10 04:23:57 +00:00
Chris Lattner 0ccd51ebe2 Start parsing statements and function bodies. This implements
Parser/statements.c:test1.

llvm-svn: 38842
2006-08-09 05:47:47 +00:00
Chris Lattner 2df305abfa New file
llvm-svn: 38822
2006-08-05 23:08:14 +00:00
Chris Lattner 971c6b681a Add scaffolding for scopes.
llvm-svn: 38821
2006-08-05 22:46:42 +00:00
Chris Lattner 22dc378630 Split LangOptions out into its own header
llvm-svn: 38806
2006-08-04 04:44:06 +00:00
Chris Lattner b9093cd1d0 Add an initial cut at a datastructure for holding declspec's.
llvm-svn: 38805
2006-08-04 04:39:53 +00:00
Chris Lattner 0bb5f835e4 initial support for parsing, right now just ;'s at the top level, but this
adds most simple scaffolding.

llvm-svn: 38802
2006-07-31 01:59:18 +00:00
Chris Lattner e8eef3207b add infrastructure for warning if redef'd macro bodies differ, but don't
fully implement it.

Fix warning on #define __LINE__ to warn about redefinition, not #undef.

llvm-svn: 38679
2006-07-08 07:01:00 +00:00
Chris Lattner bff18d5649 Diagnose erroneous macro definitions where a ## operator is at the start/end of the macro
llvm-svn: 38677
2006-07-06 04:49:18 +00:00
Chris Lattner 3451f7da35 initial checkin of xcode project that I've been using for a while
llvm-svn: 38662
2006-07-04 19:30:23 +00:00