summaryrefslogtreecommitdiffstats
path: root/clang/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* Bug #:Steve Naroff2007-04-202-15/+34
| | | | | | | | | | Submitted by: Reviewed by: Start hacking on binary ops... Important bug fix...was ignoring the return value from ImplicitConversion. This didn't bother the type checking logic, however the AST was malformed. llvm-svn: 39410
* Bug #:Steve Naroff2007-04-201-7/+49
| | | | | | | | | | Submitted by: Reviewed by: - Added Type::isPromotableIntegerType(). - The unary operators are now largely complete (Sema::ParseUnaryOp and friends). - Implemented ImplicitConversion hook (was a stub). llvm-svn: 39409
* Bug #:Steve Naroff2007-04-192-2/+74
| | | | | | | | | | | | | | 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
* Bug #:Steve Naroff2007-04-056-41/+41
| | | | | | | | | | | | Submitted by: Reviewed by: -Changed the name of TypeRef to QualType. Many diffs. -Changed the QualType constructor to require Quals be passed. This makes the code a bit more verbose, however will make the code easier to work on. Given the complexity of types, this should help spot bogosities. -Changed the Expr constructor to require a QualType. Same motivation. llvm-svn: 39395
* Bug #:Steve Naroff2007-04-053-18/+22
| | | | | | | | | | | | | | | | | | | | | | 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
* Bug #:Steve Naroff2007-04-032-31/+48
| | | | | | | | | | | | | | | | | | | | | Submitted by: Reviewed by: - Typechecking for ++/-- not operating on canonical type (fixed). - Many changes to Decl.h... -- Changed ObjectDecl->ValueDecl. -- ValueDecl doesn't define a storage class. The storage class is now defined by VarDecl/FunctionDecl. EnumConstant decls don't need a storage class. -- FieldDecl now inherits directly from Decl (it is not a value). - Changed SemaExpr to use the new Decl.h. Also added a couple diagnostics for bogus storage class usage. For example: z.c:6:10: error: illegal storage class on function auto int func(); ^ z.c:7:14: error: illegal storage class on file-scoped variable register int b; ^ llvm-svn: 39379
* Bug #:Steve Naroff2007-04-022-4/+4
| | | | | | | | | | 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
* Bug #:Steve Naroff2007-04-021-15/+17
| | | | | | | | | | | | | | | | 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
* Bug #:Steve Naroff2007-04-021-6/+8
| | | | | | | | | | | | | | 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
* Bug #:Steve Naroff2007-04-011-10/+27
| | | | | | | | | | | | 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
* Bug #:Steve Naroff2007-04-012-16/+31
| | | | | | | | | | | | 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
* Bug #:Steve Naroff2007-03-302-46/+57
| | | | | | | | | | | | | | 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
* Bug #:Steve Naroff2007-03-303-7/+39
| | | | | | | | | | | | | | | | | | 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
* Bug #:Steve Naroff2007-03-281-6/+20
| | | | | | | | | | | | 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
* Bug #:Steve Naroff2007-03-271-1/+3
| | | | | | | | Submitted by: Reviewed by: Make an error diagnosic a bit more expression (in Sema::GetTypeForDeclarator) llvm-svn: 39367
* Bug #:Steve Naroff2007-03-271-10/+13
| | | | | | | | | Submitted by: Reviewed by: Finish up fixes to Sema::GetTypeForDeclarator(). The typechecking should now conform to the standard. llvm-svn: 39366
* Bug #:Steve Naroff2007-03-271-1/+10
| | | | | | | | | | | 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
* Bug #:Steve Naroff2007-03-262-15/+12
| | | | | | | | | | | | | 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
* Bug #:Steve Naroff2007-03-233-20/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Bug #:Steve Naroff2007-03-213-7/+63
| | | | | | | | | | | | | 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
* Bug #:Steve Naroff2007-03-162-12/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Bug #:Steve Naroff2007-03-141-15/+16
| | | | | | | | | | | | | | | 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
* Bug #:Steve Naroff2007-03-131-198/+6
| | | | | | | | | | | 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
* Bug #:Steve Naroff2007-03-131-9/+12
| | | | | | | | | Submitted by: Reviewed by: Misc. cleanup/polish of NumericLiteralParser and it's two clients, the C preprocessor and AST builder... llvm-svn: 39353
* Bug #:Steve Naroff2007-03-121-7/+5
| | | | | | | | | | 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
* Bug #:Steve Naroff2007-03-091-198/+26
| | | | | | | | | | | | | 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
* Bug #:Steve Naroff2007-03-071-113/+102
| | | | | | | | | | | | 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
* Bug #:Steve Naroff2007-03-063-7/+236
| | | | | | | | | | | | | | | 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
* Go back to having the clang driver create ASTContext explicitly, passingSteve Naroff2007-02-283-15/+8
| | | | | | | | | 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
* Make Sema's use of the preprocessor explicit (rather than assumeSteve Naroff2007-02-284-14/+24
| | | | | | | | | | | | | | | | 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
* Added isa<> support for Statements and Expressions. This involved:Steve Naroff2007-02-261-1/+2
| | | | | | | | | - 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
* Batch search/replace snafu (inadvertantly changed ↵Steve Naroff2007-02-212-10/+10
| | | | | | | | | 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
* rename IntegerConstant->IntegerLiteralSteve Naroff2007-02-212-8/+8
| | | | | | | rename FloatingConstant->FloatingLiteral rename StringExpr->StringLiteral llvm-svn: 39341
* Removed tabs.Bill Wendling2007-02-132-2/+2
| | | | llvm-svn: 39340
* C++: Added support for bool types.Bill Wendling2007-02-134-3/+15
| | | | llvm-svn: 39338
* switch to using iterators instead of stringmap visitors.Chris Lattner2007-02-111-0/+1
| | | | llvm-svn: 39336
* Add support for target-specific builtins, including detecting nonportabilityChris Lattner2007-01-291-1/+1
| | | | | | | | | | | | | | | | | 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
* Add support for target-independent builtin functions (like __builtin_abs),Chris Lattner2007-01-283-13/+64
| | | | | | | | | | | | | | | | | | 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
* make LookupScopedDecl a method instead of a static functionChris Lattner2007-01-282-11/+15
| | | | llvm-svn: 39326
* When injecting a definition for implicitly defined functions, do so atChris Lattner2007-01-281-4/+8
| | | | | | | translation-unit scope, so we only warn about each implicitly defined function once. This cuts the number of errors parsing carbon.h from 616 to 550. llvm-svn: 39325
* Start doing trivial merging of function prototypes. If we have a functionChris Lattner2007-01-271-2/+6
| | | | | | | proto, then a function body, and they have the same type, don't emit an error. This reduces #errors from 654->616 llvm-svn: 39324
* Add some better diagnostics for things like:Chris Lattner2007-01-271-3/+33
| | | | | | | int foo; int foo(); llvm-svn: 39323
* Refactor conflict handling code, no functionality change.Chris Lattner2007-01-272-22/+78
| | | | llvm-svn: 39322
* Fix test/Parser/argument_qualified.cChris Lattner2007-01-271-1/+3
| | | | llvm-svn: 39316
* adjust to change in SmallSet interfaceChris Lattner2007-01-271-2/+1
| | | | llvm-svn: 39313
* rename some classes, no functionality changes.Chris Lattner2007-01-263-3/+3
| | | | llvm-svn: 39307
* start gather stats on types processed. carbon.h currently yields:Chris Lattner2007-01-261-31/+46
| | | | | | | | | | | | | | | | | | | | | *** AST Context Stats: 30594 types total. 19 builtin types 3929 pointer types 308 array types 18883 function types with proto 8 function types with no proto 2988 typename (typedef) types 4459 tagged types 1476 struct types 80 union types 0 class types 2903 enum types 83298 slow type lookups Next up, making type canonicalization not trivially silly. llvm-svn: 39305
* Don't crash if GetTypeForDeclarator can't grok a type.Chris Lattner2007-01-251-9/+16
| | | | llvm-svn: 39304
* Reject:Chris Lattner2007-01-251-1/+20
| | | | | | | | | | | | | | | struct q { int a, a; }; with: t.c:3:19: error: duplicate member 'a' struct q { int a, a; }; ^ t.c:3:16: error: previous definition is here struct q { int a, a; }; ^ llvm-svn: 39303
* Register enumconstantdecls in their appropriate scope and check for conflicts.Chris Lattner2007-01-251-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | This emits these diagnostics: t.c:4:14: error: redefinition of 'a' enum foo22 { a, b }; ^ t.c:3:5: error: previous definition is here int a; ^ t.c:8:17: error: redefinition of enumerator 'b' enum foo23 { c, b }; ^ t.c:4:17: error: previous definition is here enum foo22 { a, b }; ^ 4 diagnostics generated. for: int a; enum foo22 { a, b }; enum foo23 { c, b }; llvm-svn: 39302
OpenPOWER on IntegriCloud