Commit Graph

34241 Commits

Author SHA1 Message Date
Steve Naroff 0f6256d0fa Bug #:
Submitted by:
Reviewed by:
declare getSizeType() const and fix typo in comment...

llvm-svn: 39376
2007-04-02 23:01:44 +00:00
Steve Naroff 7840336c91 Bug #:
Submitted by:
Reviewed by:
Avoid including "clang/AST/Expr.h" in Sema.h just to access
UnaryOperator::Opcode. While the inclusion wasn't objectionable in terms
of layering, it is nice to keep the inclusions as modest as possible.

llvm-svn: 39375
2007-04-02 22:55:05 +00:00
Steve Naroff 92e30f8cc7 Bug #:
Submitted by:
Reviewed by:
Incorporate code review feedback from Chris...
- minor restructure of ParseMemberReferenceExpr logic. The last statement
is now the instantiation of the AST node (which I like a lot and will conform
to throughout Sema).
- declare StmtClassNameTable const.
- reword an error diagnostic.
- install the correct type for ParseSizeOfAlignOfTypeExpr. Added hook in
ASTContext. For now, simply return Context.UnsignedLongTy. Added a FIXME
to revisit (i.e. compute using TargetInfo).

llvm-svn: 39374
2007-04-02 22:35:25 +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 ca8f71287f Bug #:
Submitted by:
Reviewed by:
- ParseMemberReferenceExpr wasn't operating on the canonical type. From
now on, I will make sure the prologue to each Parse/Check function has
both the qualified type and the canonical type.
- More refinements to ParseDeclarator. It was allowing variable declarations
to incomplete types (e.g. void, struct foo, where foo wasn't defined).

llvm-svn: 39371
2007-04-01 01:41:35 +00:00
Steve Naroff 95af013c77 Bug #:
Submitted by:
Reviewed by:
Incorporate feedback from Chris (on the last check-in).
- added a shared hook for pre/post ++/-- CheckIncrementDecrementOperand().
- handle invalid arithmetic on incomplete types (void *, struct foo *, where the
body isn't in scope). Added a diagnostic for this case.
- added some comments and C99 annotations.
- Sema.h now includes Expr.h. I'd prefer not to, however it doesn't break
any layering.

llvm-svn: 39370
2007-03-30 23:47:58 +00:00
Steve Naroff bc2f0993c0 Bug #:
Submitted by:
Reviewed by:
Implement ++/-- typechecking for pre/post unary expressions. This includes:

- added isLvalue, isModifiableLvalue (on TypeRef, Type, and RecordType).
- added isRealType, isRealFloatingType, isComplexType.
- hacked Diag to take a TypeRef (I was sick of writing the 2 line "setup":-)
In addition, this will likely lead to less bugs...I already had written code
that was doing a getAsString on "Type" (which is wrong...since it doesn't include
any qualifiers).
- Changed UnaryOperator to take a TypeRef...pass it the right stuff.
- Removed redundant ternary expressions in several predicates.
- A couple diagnostics.

llvm-svn: 39369
2007-03-30 20:09:34 +00:00
Steve Naroff c1aadb172f Bug #:
Submitted by:
Reviewed by:
Finish up Sema::ParseArraySubscriptExpr. This involved:
- adding a couple predicates to Type.h (isObjectType, isDerivedType).
- added a diagnostic for subscripting non-object types (e.g. void (*)()).
- pass the correct result type...a minor detail:-)
- added some spec references to Type.h

llvm-svn: 39368
2007-03-28 21:49:40 +00:00
Steve Naroff d9e7bd46dd Bug #:
Submitted by:
Reviewed by:
Make an error diagnosic a bit more expression (in Sema::GetTypeForDeclarator)

llvm-svn: 39367
2007-03-27 21:47:23 +00:00
Steve Naroff bc57d0fe19 Bug #:
Submitted by:
Reviewed by:
Finish up fixes to Sema::GetTypeForDeclarator(). The typechecking should
now conform to the standard.

llvm-svn: 39366
2007-03-27 21:40:41 +00:00
Steve Naroff 06deba91d1 Bug #:
Submitted by:
Reviewed by:
Fix a couple bugs in Sema::GetTypeForDeclarator(). Need to disallow:
- void arrayOfFunctions[3]()
- void arrayOfVoids[3]
Need to talk to Chris about the return value...

llvm-svn: 39365
2007-03-27 18:04:48 +00:00
Steve Naroff cc3214299b Bug #:
Submitted by:
Reviewed by:
Finish up Sema::ParseMemberReferenceExpr. This involved:
- added a getMember() function to RecordDecl.
- added stronger typing for "Members" (from Decl->FieldDecl).
- added a dignostic for members not found.
- changed MemberExpr to install the correct TypeRef.
- In general, simplified and cleaned up the routing.

llvm-svn: 39364
2007-03-26 23:09:51 +00:00
Chris Lattner cceab1a8b7 Unnest assignment to make the code more clear
llvm-svn: 39363
2007-03-26 20:16:44 +00:00
Chris Lattner 0e13faa8ce Fix comment.
llvm-svn: 39362
2007-03-26 20:15:47 +00:00
Steve Naroff f1e53698a4 Bug #:
Submitted by:
Reviewed by:

Type Checking...round 2. This checkin "breaks" parsing carbon.h. I imagine
that this will be true for the next week or so. Nevertheless, this round of
changes includes the following:

- Hacked various Expr classes to pass the appropriate TypeRef. Still have
a few more classes to touch.
- Implement type checking for ParseArraySubscriptExpr and ParseMemberReferenceExpr.
- Added a debug hook to derive the class name for Stmt/Expr nodes. Currently a
linear search...could easily optimize if important.
- Changed the name of TaggedType->TagType. Now we have TagType and TagDecl (which
are easier to remember).
- Fixed a bug in StringLiteral conversion I did a couple weeks ago. hadError was
not initialized (oops).
- changed Sema::Diag to return true. This streamlines the type checking code
considerably.
- Added many diagnositics.

This should be it!

llvm-svn: 39361
2007-03-23 22:27:02 +00:00
Steve Naroff 26c8ea5fab Bug #:
Submitted by:
Reviewed by:
Implement type checking. First round of changes are:
- Added predicates to Type.
- Added predicates to BinExpr.
- Added Check hooks that model the categories for Binary ops.
- Added TypeRef to Expr. Will lazily eval subclasses...
- Misc bug fixes/cleanups.

llvm-svn: 39360
2007-03-21 21:08:52 +00:00
Chris Lattner bb73acd560 Support both tiger and leopard. Yes, this code is a hack :)
llvm-svn: 39359
2007-03-19 19:06:33 +00:00
Steve Naroff 97035855e3 Bug #:
Submitted by:
Reviewed by:
Down to 0 warning/errors for Carbon.h. Also made a couple trivial name
changes...

llvm-svn: 39358
2007-03-16 01:36:44 +00:00
Steve Naroff 6fbf0dcb6e Bug #:
Submitted by:
Reviewed by:
carbon.h looking good! Only 1 warning left...no parse errors!

This fixes 3 bugs...
- A couple tricky bugs with type canonicalization. Nested typedef's  weren't being
handled properly. For example, the following didn't work:

typdef int __darwin_pid_t;
typedef __darwin_pid_t pid_t;

int getpgid(pid_t);
int getpgid(int);

- The storage class wasn't being preserved. As a result, Sema was complaining
about the  following:

extern char *foo;
char *foo;

- various built-ins weren't registered...resulting in spurious warnings.

llvm-svn: 39357
2007-03-16 00:33:25 +00:00
Steve Naroff 3273c22863 Bug #:
Submitted by:
Reviewed by:
This is a "small" checkin.  #include_next wasn't working properly on
Leopard. This is because the driver has some hard coded paths that
don't work on Leopard. The real fix is to derive them, however I don't
think we need to solve this now. At this point, anyone working on clang
should be able to use Leopard. This fix removed 11 errors processing
"carbon.h". The bug that bubbles up to the top is in MergeFunctionDecl().
As part of digging into this part of Sema, I rearranged some methods
(and changed the visibility).

llvm-svn: 39356
2007-03-14 21:52:03 +00:00
Steve Naroff b7d4924eb1 Bug #:
Submitted by:
Reviewed by:
Added size expression to ArrayType. This was needed to implement
Type::isIncompleteType(). At the moment, there is no support for
determining if we have a constant expression (which won't be too
difficult now that we have support for literal parsing/ast's).
Nevertheless, the parser will allow "struct foo { int a[b]; }"
(which is illegal). There is still significant work to fully analyze
array types. The good news is "carbon.h" goes from 288 bogus errors
down to 26!

llvm-svn: 39355
2007-03-14 19:55:17 +00:00
Steve Naroff 4f88b3113e Bug #:
Submitted by:
Reviewed by:
Move string literal parsing from Sema=>LiteralSupport. This consolidates
all the quirky parsing code within the Lexer subsystem (yeah!). This
simplifies Sema and (more importantly) allows future parsers
(i.e. subclasses of Action) to benefit from this code.

llvm-svn: 39354
2007-03-13 22:37:02 +00:00
Steve Naroff f2fb89e759 Bug #:
Submitted by:
Reviewed by:
Misc. cleanup/polish of NumericLiteralParser and it's two clients, the
C preprocessor and AST builder...

llvm-svn: 39353
2007-03-13 20:29:44 +00:00
Steve Naroff 451d8f1626 Bug #:
Submitted by:
Reviewed by:
-Converted the preprocessor to use NumericLiteralParser.
-Several minor changes to LiteralSupport interface/implementation.
-Added an error diagnostic for floating point usage in pp expr's.

llvm-svn: 39352
2007-03-12 23:22:38 +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 cf30755a41 Bug #:
Submitted by:
Reviewed by:
Refactored ParseNumericConstant using SkipDigits and friends. This
cleaned up the code and removed many "breaks". In the process, I found
several bugs that needed to be fixed (proof that this refactoring had
real value, not simply aesthetics). Also simplified error handling logic
and removed an unused error condition from Diagnostics.def.

llvm-svn: 39350
2007-03-07 01:21:37 +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
Chris Lattner 4eeeabbc28 test commit
llvm-svn: 39347
2007-03-02 23:14:38 +00:00
Steve Naroff 2c055d2b2b Go back to having the clang driver create ASTContext explicitly, passing
it to Sema/ASTStreamer (separating the lifetime of ASTContext from
the lifetime of Sema). One day it might be useful to consider creating
a context object implicitly if one isn't provided (using default arguments in
Sema's constructor). At this point, adding this convenience isn't necessary.

llvm-svn: 39346
2007-02-28 19:32:13 +00:00
Steve Naroff 38d31b47b0 Make Sema's use of the preprocessor explicit (rather than assume
the prerocessor will be available via ASTContext).
- Removed the public data member "PP" in ASTContext.
- Changed ASTContext's contructor to take TargetInfo/IdentifierTable explicitly.
- Implicitly create an ASTContext in Sema's constructor. This simplifies
the clients job (and makes ASTContext more private).
--As a side effect, added a "PrintStats" hook to Sema.

To support this level of encapsulation, ASTContext is always dynamically
allocated (by Sema). Previously, ASTContext was being allocated on the
stack. I don't believe this should be a performance issue (since ASTContext
is fairly course grain and tied to the lifetime of Sema currently).

llvm-svn: 39345
2007-02-28 01:22:02 +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 408451b1af Added isa<> support for Statements and Expressions. This involved:
- adding enum constants &  instance data to Stmt.
- adding classof() functions to all Stmt's.
- modifying contructors to pass the appropriate enum as an arg.
Also tightened up a couple "void *" declarations/casts for arrays.

llvm-svn: 39343
2007-02-26 22:17:12 +00:00
Steve Naroff df7855bb17 Batch search/replace snafu (inadvertantly changed IntegerConstant->StringLiteral).
clang still compiled/linked/ran properly...simply a confusing name regression.
From now on I'll make sure I run "cvs diff" before committing any changes!

llvm-svn: 39342
2007-02-21 23:46:25 +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
Bill Wendling bf313b0bb2 Removed tabs.
llvm-svn: 39340
2007-02-13 20:09:46 +00:00
Bill Wendling 82487e1ac3 Testcase for bool types.
llvm-svn: 39339
2007-02-13 01:52:09 +00:00
Bill Wendling 4073ed5daa C++: Added support for bool types.
llvm-svn: 39338
2007-02-13 01:51:42 +00:00
Chris Lattner b5f661a255 typo
llvm-svn: 39337
2007-02-11 19:20:42 +00:00
Chris Lattner b055f2ddfc switch to using iterators instead of stringmap visitors.
llvm-svn: 39336
2007-02-11 08:19:57 +00:00
Chris Lattner 125c9f8e2a update readme.
llvm-svn: 39335
2007-02-11 08:19:36 +00:00
Chris Lattner 54d032bb76 CStringMap -> StringMap.
llvm-svn: 39334
2007-02-08 19:24:25 +00:00
Chris Lattner 34d1f5a8de adjust to CStringMap interface change.
llvm-svn: 39333
2007-02-08 19:08:49 +00:00
Chris Lattner 1036ee6c36 move a method out of line
llvm-svn: 39332
2007-01-31 05:05:57 +00:00
Chris Lattner 720f576f8d Optimize #define analysis for the common case of a single target.
llvm-svn: 39331
2007-01-30 06:01:31 +00:00
Chris Lattner f82a33b487 add 3 apple-local intrinsics.
llvm-svn: 39330
2007-01-30 05:47:29 +00:00
Chris Lattner 83f1881702 Stub out the i386 SSE builtins, this eliminates nearly 300 warnings parsing
carbon.h on intel, bringing the total to 257.

llvm-svn: 39329
2007-01-30 05:34:20 +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