Commit Graph

219 Commits

Author SHA1 Message Date
Ted Kremenek 71fff8b4de Implement "Destroy" and destructor for ObjCClassDecl, allowing us to reclaim its memory and the memory of the Decls it owns.
llvm-svn: 52059
2008-06-06 20:11:53 +00:00
Ted Kremenek 2e34af659a Implement "Destroy" and destructor for ObjCProtocolDecl, allowing us to reclaim its memory and the memory of the Decls it owns.
llvm-svn: 52055
2008-06-06 19:48:57 +00:00
Ted Kremenek 5144fe2287 Because of a lack of a clear ownership role between ObjCInterfaceDecls and
ObjCPropertyDecls, have TranslationUnit destroy ObjCPropertyDecls. This is a
horrible hack, and must be removed eventually.

llvm-svn: 52051
2008-06-06 17:21:42 +00:00
Ted Kremenek 09a0d04ea0 Initial work on additional memory collection for ObjC AST objects. We now
have Destroy methods of ObjcMethodDecl and ObjCInterfaceDecl which recursively
destroy their owned Decls and Stmts.  There are a few cases where it is not
clear what to do (FIXMEs included in the patch).

llvm-svn: 52050
2008-06-06 16:45:15 +00:00
Devang Patel 8f5645cd51 During interface layout, don't forget super class.
llvm-svn: 52035
2008-06-06 02:14:01 +00:00
Devang Patel e1f10511ba Undo previous check-in.
llvm-svn: 52034
2008-06-06 02:00:35 +00:00
Devang Patel 1216b05d3d During interface layout, don't forget super class.
llvm-svn: 52033
2008-06-06 01:50:12 +00:00
Steve Naroff f9c65246dd Fix <rdar://problem/5987482> clang on xcode: null dereference in Sema::ActOnMemberReferenceExpr.
In addition to fixing the crasher, this commit fixes further improves property lookup (by searching protocols of qualified interfaces..."NSObject <prot>").

llvm-svn: 52001
2008-06-05 13:55:23 +00:00
Devang Patel dbb7263fd9 Add ObjCInterface layout support.
Reuse RecordLayout.

llvm-svn: 51968
2008-06-04 21:54:36 +00:00
Devang Patel 21979193bb Refactoring.
Move field layout code in a ASTRecordLayout member fn.

llvm-svn: 51966
2008-06-04 21:22:16 +00:00
Ted Kremenek b147ad1051 Moved LangOptions from TranslationUnit to ASTContext. This induced a variety of cleanups in some ASTConsumers.
llvm-svn: 51943
2008-06-04 15:55:15 +00:00
Steve Naroff c68e382ba9 ASTContext::typesAreCompatible(): id is compatible with all qualified id types.
llvm-svn: 51939
2008-06-04 15:07:33 +00:00
Argyrios Kyrtzidis 6301884dc0 Move Decl and DeclContext implementations into a new DeclBase.cpp file.
llvm-svn: 51936
2008-06-04 13:04:04 +00:00
Steve Naroff 5ccccf0326 Make sure we look through categories when searching for a classes property.
Fixes <rdar://problem/5984338> clang on xcode: property implementation must have its declaration in interface 'PBXOpenQuicklyModule'

llvm-svn: 51925
2008-06-04 04:46:04 +00:00
Steve Naroff b115be707d Put back my temporary hack until Eli addresses this in a more complete fashion.
llvm-svn: 51920
2008-06-03 22:06:04 +00:00
Eli Friedman 149614bfe7 Re-fix r51907 in a way which doesn't affect valid code. This essentially
moves the check for the invalid construct to a point where it doesn't 
affect other uses of isIntegerConstantExpr, and we can warn properly 
when the extension is used.  This makes it a bit more complicated, but 
it's a lot cleaner.

Steve, please tell me if this check is sufficient to handle the 
relevant system header.  I know it's enough to handle the testcase, but 
I don't know what exactly the original looks like.

llvm-svn: 51918
2008-06-03 21:01:11 +00:00
Steve Naroff aaf5108d26 Change Expr::isIntegerConstantExpr() to allow for pointer types (for GCC compatibility). Note FIXME.
Fix <rdar://problem/5977870> clang on xcode: error: arrays with static storage duration must have constant integer length

llvm-svn: 51907
2008-06-03 17:15:29 +00:00
Steve Naroff ebf4cb4841 Fix <rdar://problem/5979875> clang on xcode: error: use of undeclared identifier 'super'
llvm-svn: 51888
2008-06-02 23:03:37 +00:00
Nuno Lopes 3fe4651e2e fix decl attributes cleaning
this plugs the leak of attributes and also fixes a crash in the test

llvm-svn: 51862
2008-06-01 22:53:53 +00:00
Ted Kremenek 380df93fd6 Added "InitializeTU" to ASTConsumer. This is used by Sema::ParseAST to pass a
TranslationUnit object instead of an ASTContext. By default it calls
Initialize(ASTConstext& Context) (to match with the current interface used by
most ASTConsumers).

Modified the ObjC-Rewriter to use InitializeTU, and to tell the TranslationUnit
to not free its Decls.  This is a workaround for: <rdar://problem/5966749>

llvm-svn: 51825
2008-05-31 20:11:04 +00:00
Steve Naroff 66002283e6 Teach Expr::isLvalue() about ObjC properties. For now, all properties are writable. Added a FIXME for another day.
llvm-svn: 51800
2008-05-30 23:23:16 +00:00
Ted Kremenek 8595668eca Fix some strict-aliasing warnings by using Stmt* instead of Expr* in VariableArrayType, EnumConstantDecl, and VarDecl.
llvm-svn: 51772
2008-05-30 16:14:41 +00:00
Eli Friedman 3df5efe83e Cleanup/refactoring of Sema struct layout. This patch unifies the struct
and union codepaths and fixes some minor bugs.

I'm reasonably confident this is accurate, at least for X86.  I'll 
correct any bugs as I find them; I haven't found any for a while, 
though.

llvm-svn: 51762
2008-05-30 09:31:38 +00:00
Steve Naroff ec94403018 Add basic support for properties references (a missing feature).
While it is far from complete, it does fix the following <rdar://problem/5967199> clang on xcode: error: member reference is not to a structure or union

llvm-svn: 51719
2008-05-30 00:40:33 +00:00
Ted Kremenek 5fc6dc070c Fix one strict-aliasing warning.
llvm-svn: 51707
2008-05-29 21:52:26 +00:00
Steve Naroff 021ca18bb5 - Move ObjC Expresssion AST's from Expr.h => ExprObjC.h
- #include ExprObjC.h in many places

llvm-svn: 51703
2008-05-29 21:12:08 +00:00
Eli Friedman 824f8c12fd Assume statement expressions have side effects; this gets rid of a lot
of extra warnings in the Python source.

llvm-svn: 51594
2008-05-27 15:24:04 +00:00
Eli Friedman aee9e54dca Don't swap function decls, and add them to the scope as they are
encountered.  Mixing up the decls is unintuitive, and confuses the AST 
destruction code. Fixes PR2360.

Note that there is a need to look up the characteristics and 
declarations of a function associated with a particular name or decl, 
but the original swapping code doesn't solve it properly. 
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-May/001644.html is one 
suggestion for how to fix that.

llvm-svn: 51584
2008-05-27 05:07:37 +00:00
Eli Friedman e2bbfe22c7 Stop leaking the TUDecl.
llvm-svn: 51575
2008-05-27 03:08:09 +00:00
Eli Friedman 1f97e5798f Always initialize NEXT_CATCH; fixes a Valgrind uninitialized read error
(originally reported in PR1682).

llvm-svn: 51551
2008-05-25 04:34:57 +00:00
Ted Kremenek a08154d85f Call the correct destructor.
llvm-svn: 51544
2008-05-24 15:09:56 +00:00
Steve Naroff b3424a9ab6 Minor tweak to -ast-dump for ivars.
llvm-svn: 51508
2008-05-23 22:01:24 +00:00
Steve Naroff e3fa7136b0 Tweak AST dumper for ObjC ivars.
llvm-svn: 51463
2008-05-23 00:59:14 +00:00
Dan Gohman 75d69da5ab Move getAccessedFieldNo out of lib/AST/Expr.cpp into
lib/CodeGen/CGExpr.cpp and to change include/clang/AST/Attr.h to
use its own enum for visibility types instead of using
llvm::GlobalValue::VisibilityTypes. These changes eliminate
dependencies in the AST library on LLVM's VMCore library.

llvm-svn: 51398
2008-05-22 00:50:06 +00:00
Dan Gohman dac7fe424f Remove the unneeded #include of VMCore header "llvm/DerivedTypes.h".
llvm-svn: 51392
2008-05-21 20:26:42 +00:00
Ted Kremenek a2157719be Add Destroy method to Types, making there destruction more harmonious with
the destruction of Decls and Stmts.

llvm-svn: 51385
2008-05-21 16:38:54 +00:00
Ted Kremenek f025a8bc1c Fix potential double-free.
llvm-svn: 51381
2008-05-21 16:00:02 +00:00
Steve Naroff e181c13593 Fixup ASTContext::PrintStats()...it was causing several test failures.
llvm-svn: 51380
2008-05-21 15:59:22 +00:00
Ted Kremenek 512d9412ec When destroying DeclStmts, also destroy the associated Decl (reclaim its memory).
llvm-svn: 51379
2008-05-21 15:53:55 +00:00
Eli Friedman b158b4a47b Fix the destruction "properly" in the sense that we actually destroy the
ASTs.  This is a hack, but I haven't considered how we really 
want to do this.

llvm-svn: 51364
2008-05-21 05:33:10 +00:00
Eli Friedman 0883bfb541 PR2347: Fix crash iterating over VLAs; this started triggering because
we now iterate over the whole AST when we destroy it.

llvm-svn: 51363
2008-05-21 05:06:46 +00:00
Eli Friedman 14b2993484 Don't kill the declarations if the translation unit doesn't own them
(specifically, for TranslationUnits created from SerializationTest.cpp).  
Fixes a double-free bug in the serialization tests.

llvm-svn: 51362
2008-05-21 05:01:55 +00:00
Eli Friedman cc6b071c1e Remove hacks from ASTContext now that alignment gets reported correctly.
llvm-svn: 51322
2008-05-20 15:17:39 +00:00
Ted Kremenek 78aa98f7b8 Reclaim memory from chains of ScopedDecls, and reclaim memory for the initializers of EnumConstantDecls.
llvm-svn: 51299
2008-05-20 04:49:55 +00:00
Ted Kremenek 40e489dfd8 Delete AST nodes, not just Decls.
llvm-svn: 51298
2008-05-20 04:10:52 +00:00
Ted Kremenek fa8a09e0bc Reclaim memory allocated for ParmVarDecl's in FunctionDecl::Destroy.
Fixed a bug in ParmVarDecl::param_end(): Handle the case where there are no
ParmVarDecls for a FunctionDecl, but its function prototype has formal arguments
(can happen with typedefs).

llvm-svn: 51297
2008-05-20 03:56:00 +00:00
Ted Kremenek 878ff6c04d When serializing FunctionDecl, serialize out a reference to the previous declaration.
llvm-svn: 51294
2008-05-20 03:33:58 +00:00
Ted Kremenek b865b38eda Remove unnecessary #include (introduced by a recent patch of mine).
llvm-svn: 51288
2008-05-20 00:47:23 +00:00
Ted Kremenek ce20e8fe8d Try to plug some memory leaks...
1) Sema::ParseAST now constructs a TranslationUnit object to own the top-level Decls, which releases the top-level Decls upon exiting ParseAST.

2) Bug fix: TranslationUnit::~TranslationUnit handles the case where a Decl is added more than once as a top-level Decl.

3) Decl::Destroy is now a virtual method, obviating the need for a special dispatch based on DeclKind.

3) FunctionDecl::Destroy now releases its Body using its Destroy method.

4) Added Stmt::Destroy and Stmt::DestroyChildren, which recursively delete the child ASTs of a Stmt and call their dstors.  We may need to special case dstor/Destroy methods for particular Stmt subclasses that own other dynamically allocated objects besides AST nodes.

5) REGRESSION: We temporarily are not deallocating attributes; a FIXME is provided.

llvm-svn: 51286
2008-05-20 00:43:19 +00:00
Ted Kremenek ee5794265a Added Stmt::DestroyChildren, which will be used by the dstors of the subclasses of Stmt to recursively delete their child AST nodes.
llvm-svn: 51278
2008-05-19 22:02:12 +00:00
Eli Friedman ca8da1d89d Make the unused expression warning a bit less aggressive (found in PHP
code).

llvm-svn: 51276
2008-05-19 21:24:43 +00:00
Ted Kremenek 92137a3d8d Added CFGBlock::hasBinaryBranchTerminator().
llvm-svn: 51190
2008-05-16 16:06:00 +00:00
Eli Friedman db421caaa3 Minor cleanup to isBuiltinConstantExpr.
llvm-svn: 51188
2008-05-16 13:28:37 +00:00
Ted Kremenek 98b730d5bb Removed bogus "return true" in Expr::isConstantExpr that returned true for all
expressions. This appears to be a regression introduced in r51113 that caused
many test cases to fail (there is still a test case in the Analysis directory
that is failing):

http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20080512/005706.html

llvm-svn: 51164
2008-05-15 21:49:04 +00:00
Eli Friedman a1b4ed8003 Implementation of __builtin_shufflevector, a portable builtin capable of
expressing the full flexibility of the LLVM shufflevector instruction.  
The expected immediate usage is in *mmintrin.h, so that they don't 
depend on the mess of gcc-inherited (and not completely implemented)
shuffle builtins.

llvm-svn: 51113
2008-05-14 19:38:39 +00:00
Nate Begeman d386215916 Remove AST dependency on VMCore by switching ExtVectorElementExpr off Constant.
llvm-svn: 51068
2008-05-13 21:03:02 +00:00
Ted Kremenek 2abde809ce Unbreak build.
llvm-svn: 50980
2008-05-12 17:42:30 +00:00
Ted Kremenek 8322da5fa3 Grammar cleanup in comment.
Remove redundant assignment.

llvm-svn: 50978
2008-05-12 17:40:56 +00:00
Ted Kremenek 92f78f4c04 When reading in the DeclCtx during deserialization, register the DeclCtx of the
ScopedDecl with the backpatcher, and *not* a local variable on the stack. The
value of DeclCtx gets filled in *later* by the backpatcher.

This fixes: http://llvm.org/bugs/show_bug.cgi?id=2308

llvm-svn: 50976
2008-05-12 17:29:34 +00:00
Nuno Lopes de9746cd45 fix free/delete mismatch problem in add/mergeProperties (found by valgrind)
llvm-svn: 50945
2008-05-10 10:31:54 +00:00
Nate Begeman f322eabbce Extend vector member references to include {.hi, .lo, .e, .o} which return a
vector of the same element type and half the width, with the high, low, even,
and odd elements respectively.

Allow member references to member references, so that .hi.hi gives you the high
quarter of a vector.  This is fairly convenient syntax for some insert/extract
operations.

Remove some unnecessary methods/types in the ExtVectorElementExpr class.

llvm-svn: 50892
2008-05-09 06:41:27 +00:00
Fariborz Jahanian 8983f17ba0 Synthesized getter/setter method declarations need not have
an implementation. This fixes couple of failing prperty tests
caused by my previous patch.

llvm-svn: 50830
2008-05-07 20:53:44 +00:00
Fariborz Jahanian ec6e4c8096 This patch introduces declaration of getter methods for ObjC2's
properties. Couple of property tests will fail with this patch.
Will fix them next.

llvm-svn: 50818
2008-05-07 17:43:59 +00:00
Steve Naroff 456c0f6738 Fixup InitListExpr::child_begin/end. Thanks to Ted for catching the regression.
llvm-svn: 50816
2008-05-07 17:35:03 +00:00
Steve Naroff 6eda39c345 Fix off-by-one error.
llvm-svn: 50815
2008-05-07 16:50:14 +00:00
Fariborz Jahanian 8d91686b0d percolate @optional/@required protocols down to ASTs for
properties declared in the protocol.

llvm-svn: 50662
2008-05-05 18:51:55 +00:00
Chris Lattner 7b9293ba20 Simplify FunctionDecl::AddRedeclaration a bit by using std::swap.
Fix 'swapping' of attributes to not insert null values into the 
DeclAttrs map.

llvm-svn: 50612
2008-05-04 02:29:49 +00:00
Fariborz Jahanian 98a6c4fa77 This patch is about merging ObjC2's properties declared in class
protocols into class's property list and performing semantics
on them for while doing so.

llvm-svn: 50587
2008-05-02 19:17:30 +00:00
Ted Kremenek 3b33e2544a Fixed bug in ObjCIVarExpr: the child iterator now iterates over the Base expression.
llvm-svn: 50585
2008-05-02 18:40:22 +00:00
Ted Kremenek a06e7120bb Bug fix in StmtPrinter to handle pretty-printing ObjCMessageExprs involving variadic methods (also did some cosmetic cleanups in the printing output).
llvm-svn: 50583
2008-05-02 17:32:38 +00:00
Ted Kremenek b8861a6ccf Use pointer swizziling to unify in ObjCMessageExpr the receiver and classname "fields". This saves us a pointer.
Implemented serialization for ObjCMessageExpr.

llvm-svn: 50528
2008-05-01 17:26:20 +00:00
Steve Naroff 20348b5653 Extend InitListExpr API/IMPL to support arbitrary add/remove (in support of the initializer rewrite I am doing).
llvm-svn: 50511
2008-05-01 02:04:18 +00:00
Ted Kremenek 6065ef6b9b Bug fix in CFG::getBlockEdgeImpl(): Use a BumpPtrAllocator to allocate
std::pair<CFGBlock*, CFGBlock*> that have an 8-byte alignment for use with
ProgramPoint. This fixes a bug reported by Argiris where using std::set<> on
Windows would result in a 4-byte alignment, not an 8-byte alignment.

Fixes: <rdar://problem/5892265>
llvm-svn: 50364
2008-04-28 18:00:46 +00:00
Argyrios Kyrtzidis 081148986a Parsing of namespaces:
-NamespaceDecl for the AST
-Checks for name clashes between namespaces and tag/normal declarations.

This commit doesn't implement proper name lookup for namespaces.

llvm-svn: 50321
2008-04-27 13:50:30 +00:00
Ted Kremenek 467297ab48 TranslationUnit now owns IdentifierTable, TargetInfo, and Selectors objects
when it is constructed via deserialization.  This is done by recording a flag
indicating that this is the case, and it deletes these objects by getting
the references stored in the ASTContext object.  This fixes some memory
leaks that occurs when we deserialize translation units from bitcode files.

The rationale between having TranslationUnit sometimes own these objects and
sometimes not is that a TranslationUnit object can be constructed from
state generated by the parser (Preprocessor; semantic analyzer, etc.), and thus
in these cases won't own the IdentifierTable or Selectors, etc.  During
deserialization, there is no Preprocessor, so somebody needs to own these
objects in order for them to be properly reclaimed.

llvm-svn: 50149
2008-04-23 16:25:39 +00:00
Fariborz Jahanian 6efdf1ddab Patch to build AST for property implementation declarations and
to print declaration from its AST.

llvm-svn: 50117
2008-04-23 00:06:01 +00:00
Chris Lattner bec41348e2 "This patch renames
DeclContext *CtxDecl -> DeclContext *DeclCtx
DeclContext *CD -> DeclContext *DC

It makes the code more consistent."

Patch by Zhongxing Xu!

llvm-svn: 50105
2008-04-22 18:39:57 +00:00
Fariborz Jahanian a591a12ea5 Allow property in base class to be implemented in a
derived class.

llvm-svn: 50074
2008-04-21 23:57:08 +00:00
Fariborz Jahanian a054e99fa8 Continuation of work on ObjC2's properties.
Added iterators, methods to find property and categories.
Use them in doing semantic analysis on property implementation
declarations. Fixed typos.

llvm-svn: 50050
2008-04-21 19:04:53 +00:00
Douglas Gregor 89f238cbe1 Clean up handling of function redeclarations
llvm-svn: 50021
2008-04-21 02:02:58 +00:00
Nate Begeman ce4d7fce6b OCUVector -> ExtVector, shorthand for extended vector, per feedback from Chris.
llvm-svn: 49942
2008-04-18 23:10:10 +00:00
Fariborz Jahanian 8e36cddde0 Added property decl support for protocols.
Added assertion if unexpected property decls are found where they don't belong.
Consolidated property decl. printing by using a helper function.

llvm-svn: 49862
2008-04-17 18:25:18 +00:00
Argyrios Kyrtzidis c3b69ae815 Addition of TranslationUnitDecl to the AST:
-Added TranslationUnitDecl class to serve as top declaration context
-ASTContext gets a TUDecl member and a getTranslationUnitDecl() function
-All ScopedDecls get the TUDecl as DeclContext when declared at global scope

llvm-svn: 49855
2008-04-17 14:40:12 +00:00
Fariborz Jahanian 549e83caa0 New AST class for property implementation declarations.
llvm-svn: 49821
2008-04-16 22:00:24 +00:00
Fariborz Jahanian d634dfae0f Fixed a comment.
llvm-svn: 49819
2008-04-16 21:11:25 +00:00
Ted Kremenek c1f9a28e4d Added CFGBlock::getTerminatorCondition() to get the Expr* of the condition a block's terminator.
Refactored LiveVariables to use getTerminatorCondition() in VisitTerminator().

Bug fix: CFG now computes Block-level expression numbers using information
from block terminators.  This fixes <rdar://problem/5868189>.

llvm-svn: 49818
2008-04-16 21:10:48 +00:00
Fariborz Jahanian 9d981eb9ae This patch adds support for declaraing properties in categories,
just as they are declared in objc classes.

llvm-svn: 49817
2008-04-16 21:08:45 +00:00
Ted Kremenek b65a67d7b6 Remove uses of "Selector&" and "const Selector&", since Selector is just an
immutable smart pointer (we don't need to pass references, just pass Selector).

llvm-svn: 49773
2008-04-16 04:30:16 +00:00
Steve Naroff 08899ff85d Remove FileVarDecl and BlockVarDecl. They are replaced by VarDecl::isBlockVarDecl() and VarDecl::isFileVarDecl().
This is a fairly mechanical/large change. As a result, I avoided making any changes/simplifications that weren't directly related. I did break two Analysis tests. I also have a couple FIXME's in UninitializedValues.cpp. Ted, can you take a look? If the bug isn't obvious, I am happy to dig in and fix it (since I broke it).

llvm-svn: 49748
2008-04-15 22:42:06 +00:00
Fariborz Jahanian 0152a1a5db New AST representation for each objc2's property declaration.
llvm-svn: 49699
2008-04-14 23:36:35 +00:00
Douglas Gregor 83a586ec19 Introduce support for finding class and enum names via ordinary name lookup in C++
llvm-svn: 49621
2008-04-13 21:07:44 +00:00
Chris Lattner 861a226586 This patch is just the easy part of the class names patch, which
allows the parsing of "class" in addition to "struct" and "union" to
declare a record.  So this patch allows:

 class C { };
 class C c1;

But it does not contain the lookup bits, so this won't work yet:

 C c2;

Patch by Doug Gregor!

llvm-svn: 49613
2008-04-13 18:59:07 +00:00
Sam Bishop fcd78b02c2 Use static_cast<> instead of cast<> in Decl::Destroy(). Suggestion by Argiris
Kirtzidis!

llvm-svn: 49603
2008-04-13 04:32:18 +00:00
Chris Lattner b0d3844fb8 Default argument cleanups and minor improvements, patch by
Doug Gregor!

llvm-svn: 49598
2008-04-12 23:52:44 +00:00
Fariborz Jahanian 4572b45574 AST generation for objc2's property declarations.
llvm-svn: 49565
2008-04-11 23:40:25 +00:00
Steve Naroff 5a4611cdda Add class and super class location info to ObjCInterfaceDecl...
llvm-svn: 49553
2008-04-11 19:35:35 +00:00
Sam Bishop ef8b94ae84 Invoke destructors in Decl::Destroy().
llvm-svn: 49547
2008-04-11 18:04:39 +00:00
Sam Bishop 703ae9624b Stub out and start using a Decl::Destroy() method.
llvm-svn: 49532
2008-04-11 15:01:25 +00:00
Sam Bishop 4c088b766d Use the ASTContext allocator when creating deserialized Decl objects.
llvm-svn: 49530
2008-04-11 14:49:10 +00:00
Chris Lattner 58258246ec Several improvements from Doug Gregor related to default
argument handling.  I'll fix up the c89 (void) thing next.

llvm-svn: 49459
2008-04-10 02:22:51 +00:00