summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
* More type checking for blocks. Still incomplete (will hopefully finish up ↵Steve Naroff2008-09-052-30/+82
| | | | | | this weekend). llvm-svn: 55862
* Add comment back that Argiris pointed out that I mistakenly removed (the ↵Ted Kremenek2008-09-051-0/+2
| | | | | | comments below it were stale, so I accidently removed the whole thing). llvm-svn: 55841
* Change struct forward declarations and definitions to use unique ↵Ted Kremenek2008-09-052-12/+140
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | RecordDecls, as opposed to creating a single RecordDecl and reusing it. This change effects both RecordDecls and CXXRecordDecls, but does not effect EnumDecls (yet). The motivation of this patch is as follows: - Capture more source information, necessary for refactoring/rewriting clients. - Pave the way to resolve ownership issues with RecordDecls with the forthcoming addition of DeclGroups. Current caveats: - Until DeclGroups are in place, we will leak RecordDecls not explicitly referenced by the AST. For example: typedef struct { ... } x; The RecordDecl for the struct will be leaked because the TypedefDecl doesn't refer to it. This will be solved with DeclGroups. - This patch also (temporarily) breaks CodeGen. More below. High-level changes: - As before, TagType still refers to a TagDecl, but it doesn't own it. When a struct/union/class is first referenced, a RecordType and RecordDecl are created for it, and the RecordType refers to that RecordDecl. Later, if a new RecordDecl is created, the pointer to a RecordDecl in RecordType is updated to point to the RecordDecl that defines the struct/union/class. - TagDecl and RecordDecl now how a method 'getDefinition()' to return the TagDecl*/RecordDecl* that refers to the TagDecl* that defines a particular enum/struct/class/union. This is useful from going from a RecordDecl* that defines a forward declaration to the RecordDecl* that provides the actual definition. Note that this also works for EnumDecls, except that in this case there is no distinction between forward declarations and definitions (yet). - Clients should no longer assume that 'isDefinition()' returns true from a RecordDecl if the corresponding struct/union/class has been defined. isDefinition() only returns true if a particular RecordDecl is the defining Decl. Use 'getDefinition()' instead to determine if a struct has been defined. - The main changes to Sema happen in ActOnTag. To make the changes more incremental, I split off the processing of enums and structs et al into two code paths. Enums use the original code path (which is in ActOnTag) and structs use the ActOnTagStruct. Eventually the two code paths will be merged, but the idea was to preserve the original logic both for comparison and not to change the logic for both enums and structs all at once. - There is NO CHAINING of RecordDecls for the same RecordType. All RecordDecls that correspond to the same type simply have a pointer to that type. If we need to figure out what are all the RecordDecls for a given type we can build a backmap. - The diff in CXXRecordDecl.[cpp,h] is actually very small; it just mimics the changes to RecordDecl. For some reason 'svn' marks the entire file as changed. Why is CodeGen broken: - Codegen assumes that there is an equivalence between RecordDecl* and RecordType*. This was true before because we only created one RecordDecl* for a given RecordType*, but it is no longer true. I believe this shouldn't be too hard to change, but the patch was big enough as it is. I have tested this patch on both the clang test suite, and by running the static analyzer over Postgresql and a large Apple-internal project (mix of Objective-C and C). llvm-svn: 55839
* Remove stale comments.Ted Kremenek2008-09-051-8/+0
| | | | llvm-svn: 55822
* Remove "NextDecl" from RecordDecl. This change touches many files that ↵Ted Kremenek2008-09-052-6/+4
| | | | | | | | where RecordDecl or CXXRecordDecl was constructed, always with an argument of 'NULL' for the previous declaration. The motivation behind this change is that chaining the RecordDecls is simply unnecessary. Once we create multiple RecordDecls for the same struct/union/class, clients that care about all the declarations of the same struct can build a back map by seeing which Decls refer to the same RecordType. llvm-svn: 55821
* Prevent invalid warnings about incomplete implementations for methodsDaniel Dunbar2008-09-042-15/+28
| | | | | | which are inherited from base clases or protocols. llvm-svn: 55790
* Touchup CheckSingleAssignmentConstraints() and CheckCompareOperands() to ↵Steve Naroff2008-09-041-1/+19
| | | | | | | | check for block pointers. Added a couple FIXME's wrt PointLikeType. If the author reads this, it would be great to get some background on this class (thanks in advance). llvm-svn: 55778
* Fix a handful of typos (closure->block) to avoid confusion.Steve Naroff2008-09-041-3/+3
| | | | llvm-svn: 55768
* Add type checking for blocks.Steve Naroff2008-09-042-0/+97
| | | | llvm-svn: 55767
* Generate error if we try to implicit cast between different addressMon P Wang2008-09-041-5/+20
| | | | | | spaces llvm-svn: 55765
* Set register storage class correctly for function parameters.Daniel Dunbar2008-09-031-3/+5
| | | | | | - PR2730 llvm-svn: 55739
* Add __builtin_object_size support.Daniel Dunbar2008-09-032-4/+30
| | | | | | | - Currently CodeGen always returns a conservative value for this (-1 or 0 depending on the context). llvm-svn: 55735
* Add semantic analysis for "blocks". Steve Naroff2008-09-034-1/+224
| | | | | | | | | | | | | | | Highlights... - 4 new AST nodes, BlockExpr, BlockStmtExpr, BlockExprExpr, BlockDeclRefExpr. - Sema::ActOnBlockStart(), ActOnBlockError(), ActOnBlockStmtExpr(), ActOnBlockExprExpr(), ActOnBlockReturnStmt(). Next steps... - hack Sema::ActOnIdentifierExpr() to deal with block decl refs. - add attribute handler for byref decls. - add test cases. llvm-svn: 55710
* Fix 80 col violations.Ted Kremenek2008-09-031-9/+8
| | | | llvm-svn: 55707
* Improve type-checking of ?: for Objective-C types.Daniel Dunbar2008-09-031-12/+17
| | | | | | | - Allow any Objective-C object types to devolve to type id in a ?: expression. This matches gcc behavior more closely. llvm-svn: 55705
* Restore Objective-C dot-syntax access of methods.Daniel Dunbar2008-09-031-33/+63
| | | | | | | | - Now also searches for correct setter method. - There are still some issues regarding validation of the setter method and access of read-only properties. llvm-svn: 55686
* When creating CXXRecordDecls and RecordDecls within ActOnTag, hook up the ↵Ted Kremenek2008-09-021-5/+15
| | | | | | new [CXX]RecordDecl with the RecordDecl chain. llvm-svn: 55652
* Fix for PR2747: allow pointer->int casts with a null base; these are Eli Friedman2008-09-021-0/+7
| | | | | | offset-of-like expressions. llvm-svn: 55627
* An extremely hacky version of transparent_union support; it isn't Eli Friedman2008-09-021-7/+22
| | | | | | | | | anywhere near correct in terms of missing cases and missing diagnostics, but it's good enough to handle the uses in the Linux system headers, which are currently a constant pain for compiling applications on Linux. llvm-svn: 55621
* Make sure to take the unqualified versions of the canonical types for Eli Friedman2008-09-021-3/+4
| | | | | | | type-checking pointer subtraction; if the canonical types aren't used, the qualifiers won't always get stripped off correctly. llvm-svn: 55620
* Backing out r55607 due to logic errors and test regression.Eli Friedman2008-09-011-10/+6
| | | | | | I'll try to come up with a correct fix for the testcase sometime soon. llvm-svn: 55614
* Tidy up sema processing of attribute "nonull":Ted Kremenek2008-09-011-8/+20
| | | | | | | | - warn about nonnull being applied to functions with no pointer arguments - continue processing argument list in the attribute when we encounter a non-pointer parameter being marked as nonnull - when no argument list is specified, only mark pointers as nonnull. This fixes PR 2732 and radar 6188814. llvm-svn: 55610
* fix one more this-is-not-a-constant error. test includedNuno Lopes2008-09-011-0/+3
| | | | llvm-svn: 55609
* make CheckArithmeticConstantExpression() aware of &foo and pointersNuno Lopes2008-09-011-6/+10
| | | | llvm-svn: 55607
* Add Objective-C property setter support.Daniel Dunbar2008-08-301-1/+6
| | | | | | | | | | | | | | | | | | | | | | - Change Obj-C runtime message API, drop the ObjCMessageExpr arg in favor of just result type and selector. Necessary so it can be reused in situations where we don't want to cons up an ObjCMessageExpr. - Update aggregate binary assignment to know about special property ref lvalues. - Add CodeGenFunction::EmitCallArg overload which takes an already emitted rvalue. Add CodeGenFunction::StoreComplexIntoAddr. Disabled logic in Sema for parsing Objective-C dot-syntax that accesses methods. This code does not search in the correct order and the AST node has no way of properly representing its results. Updated StmtDumper to print a bit more information about ObjCPropertyRefExprs. llvm-svn: 55561
* minor cleanupNico Weber2008-08-291-15/+4
| | | | llvm-svn: 55538
* First wave of changes to support "blocks" (an extension to C).Steve Naroff2008-08-271-0/+8
| | | | | | This commit adds the declaration syntax (and associated type). llvm-svn: 55417
* Add synthesized property methods to protocols and categories in Sema.Daniel Dunbar2008-08-271-12/+25
| | | | | | | | | | | | | | | | - It is not clear that this is the right approach, but this is at least consistent with how interfaces are handled. - This means NeXT now emits the correct metadata for properties in protocols. - This currently introduces a spurious warning involving inherited properties in protocols or categories; however, it also fixes some situations where we were failing to emit a warning. I will scrub this code tomorrow and fix this issue as well as number of other missed warnings / error situations that appear to exist. llvm-svn: 55407
* Move implicit Obj-C param creation into ObjCMethodDecl.Daniel Dunbar2008-08-263-36/+3
| | | | | | | | | | - Add ObjCMethodDecl::createImplicitParams. - Remove ObjCMethodDecl::set{Self,Cmd}Decl - Remove Sema::CreateImplicitParameter No (intended) functionality change. llvm-svn: 55356
* Rename ObjCPropertyImplDecl::PropertyImplKind (consistency)Daniel Dunbar2008-08-261-3/+3
| | | | | | | | | - Change enum name to Kind. - Change enum constants to English strings. Also, fix getPropertyImplementation (which probably should be renamed) llvm-svn: 55354
* In incompatible pointer-typed ?: expressions, add implicit conversionDaniel Dunbar2008-08-261-10/+23
| | | | | | | | | | | | | | | | | | | | of RHSs to id type instead of void* if either has Objective-C object type. - This ensures the result can still be used in normal places an object can be used, like a message send. Add implicit conversions for ?: applied to qualified id types to ensure that the RHSs are compatible. - This prevents a codegen crash (creating invalid PHI nodes). - Again, this relates to the fact that qualified id types have no canonical types. - Note that the implicit type casted to is incorrect, however this doesn't currently cause problems because of the flexibility of the id type. Test cases for above. llvm-svn: 55346
* Do typechecking and codegen for K&R-style function declarations Eli Friedman2008-08-252-13/+12
| | | | | | | correctly. Not a regression, but made more obvious by my recent fix which made function type compatibility checking a bit more strict. llvm-svn: 55339
* Fix for PR2720; be a little bit more permissive in initializers for Eli Friedman2008-08-251-21/+23
| | | | | | | | | | casting pointers to integers. Eventually, we should check whether we can evaluate an expression using Expr::tryEvaluate, and this codepath should be tightened to only handle standard-compliant cases. llvm-svn: 55331
* Objective-C foreach selector elements must be lvalues.Anders Carlsson2008-08-251-3/+10
| | | | llvm-svn: 55316
* Fix silly bug in objc_gc attribute parsing and add test caseAnders Carlsson2008-08-241-2/+2
| | | | llvm-svn: 55286
* Pass SourceRanges by reference to the various Diag methods.Argyrios Kyrtzidis2008-08-242-14/+16
| | | | llvm-svn: 55284
* Add support for parsing the objc_gc attribute. Tests will come shortly.Anders Carlsson2008-08-231-0/+32
| | | | llvm-svn: 55269
* Make sure to create CXX record decls for the implicit Obj-C type ↵Anders Carlsson2008-08-231-14/+16
| | | | | | declarations. This lets us compile Cocoa.h as Objective-C++ llvm-svn: 55261
* make sure that ParseAST invokes the action for end of translation unit.Chris Lattner2008-08-232-0/+10
| | | | llvm-svn: 55222
* minor cleanup, remove finalize method.Chris Lattner2008-08-232-5/+4
| | | | llvm-svn: 55216
* Use isa instead of dyn_cast.Anders Carlsson2008-08-221-2/+1
| | | | llvm-svn: 55207
* Add support for C++'s "type-specifier ( expression-list )" expression:Argyrios Kyrtzidis2008-08-222-0/+76
| | | | | | | | | | -The Parser calls a new "ActOnCXXTypeConstructExpr" action. -Sema, depending on the type and expressions number: -If the type is a class, it will treat it as a class constructor. [TODO] -If there's only one expression (i.e. "int(0.5)" ), creates a new "CXXFunctionalCastExpr" Expr node -If there are no expressions (i.e "int()" ), creates a new "CXXZeroInitValueExpr" Expr node. llvm-svn: 55177
* Initial sema support for C++ static initializers.Anders Carlsson2008-08-221-4/+11
| | | | llvm-svn: 55166
* Rewrite type compatibility testing to do type merging rather than just Eli Friedman2008-08-222-3/+32
| | | | | | | | | | | | testing compatibility. This is necessary for some constructs, like merging redeclarations. Also, there are some ObjC changes to make sure that typesAreCompatible(a,b) == typesAreCompatible(b,a). I don't have any ObjC code beyond the testsuite, so please tell me if there are any cases where this doesn't behave as expected. llvm-svn: 55158
* add a simple check to warn people who type "=+" when they probably meantChris Lattner2008-08-211-2/+22
| | | | | | "+=". llvm-svn: 55131
* Fix a regression from my fix to PR2631. Fixes PR2692.Eli Friedman2008-08-201-0/+2
| | | | llvm-svn: 55083
* Fix attributes on Obj-C interfaces & methods.Daniel Dunbar2008-08-201-2/+9
| | | | | | | - Drop MethodAttrs parameter to ObjCMethodDecl - Call ProcessDeclAttributeList for interface & method decls. llvm-svn: 55068
* Fix subtle bug introduced in r54852.Daniel Dunbar2008-08-202-2/+2
| | | | | | | | | - UsualUnaryConversions takes an Expr *& and may modify its argument, this broke when it was refactored into Sema::CheckCastTypes. This meant that we were missing implicit casts in some places. - Seems pretty sad that this got through our tests. llvm-svn: 55039
* Re-enable deletion of AST nodes upon completion of ParseAST.Ted Kremenek2008-08-201-3/+0
| | | | llvm-svn: 55038
* Added ObjCAtDefsFieldDecl to represent FieldDecls created by @defs.Ted Kremenek2008-08-201-4/+14
| | | | | | This fixes an ownership issue where FieldDecls could be owned both by an ObjCInterfaceDecl and a RecordDecl. llvm-svn: 55037
OpenPOWER on IntegriCloud