Commit Graph

5427 Commits

Author SHA1 Message Date
Daniel Dunbar e36c39f3bf Missed a file; part of:
Move implicit Obj-C param creation into ObjCMethodDecl.
 - Add ObjCMethodDecl::createImplicitParams.
 - Remove ObjCMethodDecl::set{Self,Cmd}Decl
 - Remove Sema::CreateImplicitParameter

No (intended) functionality change.

llvm-svn: 55357
2008-08-26 06:08:30 +00:00
Daniel Dunbar 3b4fdb0951 Rename ObjCPropertyImplDecl::PropertyImplKind (consistency)
- Change enum name to Kind.
 - Change enum constants to English strings.

Also, fix getPropertyImplementation (which probably should be renamed)

llvm-svn: 55354
2008-08-26 04:47:31 +00:00
Daniel Dunbar 222ab49928 Fix return type for setter method.
llvm-svn: 55353
2008-08-26 02:53:23 +00:00
Daniel Dunbar ad3cdc2ba7 Synthesize property setter method as we do for getter.
- Also, fix Parser to construct proper SetterName selector (should be
   lifted out of parser though).

llvm-svn: 55352
2008-08-26 02:32:45 +00:00
Anders Carlsson ab55d9cd74 Handle emitting __builtin_huge_valf as a constant expr.
llvm-svn: 55299
2008-08-25 03:27:15 +00:00
Anders Carlsson 4f177f803a treat bool literals as constatnt expressions.
llvm-svn: 55255
2008-08-23 21:12:35 +00:00
Argyrios Kyrtzidis ce4528f008 Add CodeGen support for CXXZeroInitValueExpr.
llvm-svn: 55249
2008-08-23 19:35:47 +00:00
Anders Carlsson 0fbd44699a Handle AddrLabelExprs in Expr::isConstantExpr
llvm-svn: 55245
2008-08-23 18:49:32 +00:00
Argyrios Kyrtzidis 857fcc2f8e Add support for C++'s "type-specifier ( expression-list )" expression:
-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
2008-08-22 15:38:55 +00:00
Eli Friedman 3e62c21c49 Fix some issues with array type merging. (No visible difference,
because nothing uses the merged types yet.)

llvm-svn: 55161
2008-08-22 01:48:21 +00:00
Eli Friedman 777a6bb582 Minor const cleanup.
llvm-svn: 55160
2008-08-22 00:59:49 +00:00
Eli Friedman 47f7711e4b Rewrite type compatibility testing to do type merging rather than just
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
2008-08-22 00:56:42 +00:00
Eli Friedman 24c0154b77 Initial implementation of floats in Expr::tryEvaluate; this doesn't
implement some things, like unary operators and casts, but it's enough
to fix PR2703 as filed.

llvm-svn: 55155
2008-08-22 00:06:13 +00:00
Daniel Dunbar 73a73f52fd Fix attributes on Obj-C interfaces & methods.
- Drop MethodAttrs parameter to ObjCMethodDecl
 - Call ProcessDeclAttributeList for interface & method decls.

llvm-svn: 55068
2008-08-20 18:02:42 +00:00
Ted Kremenek 0e857200bb Added ObjCAtDefsFieldDecl to represent FieldDecls created by @defs.
This fixes an ownership issue where FieldDecls could be owned both by an ObjCInterfaceDecl and a RecordDecl.

llvm-svn: 55037
2008-08-20 03:26:33 +00:00
Argyrios Kyrtzidis 3bab3d21f9 Add ExplicitCastExpr to replace the current CastExpr, and have ImplicitCastExpr and ExplicitCastExpr derive from a common base class (CastExpr):
Expr
  -> CastExpr
     -> ExplicitCastExpr
     -> ImplicitCastExpr 

llvm-svn: 54955
2008-08-18 23:01:59 +00:00
Steve Naroff 40471b3ba8 Fix ASTContext::getObjCEncodingForType() to limit the type info for structure bodies (mimics gcc's adhoc rules).
This fixes <rdar://problem/6140902> clang ObjC rewriter: If a class contains a struct ivar with a lot of members, ... 

llvm-svn: 54777
2008-08-14 15:00:38 +00:00
Daniel Dunbar 7da1b82f56 Update some isIntegerConstantExpr uses to use
getIntegerConstantExprValue where appropriate.

llvm-svn: 54771
2008-08-13 23:47:13 +00:00
Daniel Dunbar 56fdb6ae69 More #include cleaning
- Kill unnecessary #includes in .cpp files. This is an automatic
   sweep so some things removed are actually used, but happen to be
   included by a previous header. I tried to get rid of the obvious
   examples and this was the easiest way to trim the #includes in one
   fell swoop.
 - We now return to regularly scheduled development.

llvm-svn: 54632
2008-08-11 06:23:49 +00:00
Daniel Dunbar 6e8aa537f8 More #include cleaning
- Drop {Decl.h,DeclObjC.h,IdentifierTable.h} from Expr.h
 - Moved Sema::getCurMethodDecl() out of line (dependent on
   ObjCMethodDecl via dyn_cast).

llvm-svn: 54629
2008-08-11 05:35:13 +00:00
Daniel Dunbar 221fa94e40 More #include cleaning
- Drop Expr.h,RecordLayout.h from ASTContext.h (for DeclBase.h and
   SourceLocation.h)
 - Move ASTContext constructor into implementation

llvm-svn: 54627
2008-08-11 04:54:23 +00:00
Steve Naroff 0d7c6dbae8 Cleanup ObjCSuperRefExpr (remove last usage and AST node:-).
llvm-svn: 54617
2008-08-10 19:10:41 +00:00
Anders Carlsson d361a7df78 Remove the old evaluator code.
llvm-svn: 54615
2008-08-10 17:03:01 +00:00
Chris Lattner 6307f19726 rename PreDefinedExpr -> PredefinedExpr
llvm-svn: 54605
2008-08-10 01:53:14 +00:00
Argyrios Kyrtzidis 8a23f55186 Add some C++ Decl statistics.
llvm-svn: 54604
2008-08-10 01:47:31 +00:00
Eli Friedman 5ce8cc7554 Remove the ICE pointer cast hack; the issue this was working around is
now fixed in an alternate way.

llvm-svn: 54598
2008-08-09 22:24:21 +00:00
Eli Friedman 5cf85cc977 Turn on the new constant expression evaluator; it isn't
anywhere near complete, but I don't know of any issues, and it can 
handle enough to allow removing the I-C-E pointer cast hack.

llvm-svn: 54597
2008-08-09 22:21:56 +00:00
Chris Lattner 572100b648 Fix PR2400 by more graceful handling of invalid decls. Don't try to layout
an invalid struct decl.  Thanks to Martin Doucha for the 
isIncompleteArrayType part of this patch.

llvm-svn: 54592
2008-08-09 21:35:13 +00:00
Argyrios Kyrtzidis cbad725bf4 Change 'Wchar' to 'WChar' casing, for consistency.
No functionality change.

llvm-svn: 54588
2008-08-09 17:20:01 +00:00
Argyrios Kyrtzidis d8f2f5f1b7 Handle WChar inside BuiltinType::getName().
llvm-svn: 54587
2008-08-09 17:11:33 +00:00
Argyrios Kyrtzidis 40e9e4828f Implement support for the 'wchar_t' C++ type.
llvm-svn: 54585
2008-08-09 16:51:54 +00:00
Argyrios Kyrtzidis 6bd44afc2f Destroy and delete the FieldDecl members of a RecordDecl.
llvm-svn: 54527
2008-08-08 14:08:55 +00:00
Argyrios Kyrtzidis faf0876cab Add CXXRecordType class.
llvm-svn: 54488
2008-08-07 20:55:28 +00:00
Ted Kremenek 8889bb3ff4 Cleanup some processing with DeclStmt, and gradually start using the internal BumpPtrAllocator to allocator more of CFG's data structures.
llvm-svn: 54433
2008-08-06 23:20:50 +00:00
Ted Kremenek e26ccf3553 Always construct the BumpPtrAllocator used by CFG as an instance variable.
llvm-svn: 54429
2008-08-06 22:22:32 +00:00
Ted Kremenek 66db7d66de Fix serialization of DeclStmt.
llvm-svn: 54428
2008-08-06 22:17:30 +00:00
Ted Kremenek 8d78a09a56 Reorder serialization methods.
When serializing DeclStmt, encode a bit indicating whether or not the DeclStmt owns the Decl.  This is an interim solution.

llvm-svn: 54410
2008-08-06 15:50:59 +00:00
Nico Weber de565e3bc9 remove spaces at eol to test commit access
llvm-svn: 54381
2008-08-05 23:15:29 +00:00
Ted Kremenek 4f8792b616 Added decl_iterator to DeclStmt to provide an abstract interface to iterate over the ScopedDecls of a DeclStmt.
Updated a few clients of DeclStmt::getNextDeclarator() to use decl_iterator instead.  Will update other clients after additional testing.

llvm-svn: 54368
2008-08-05 20:46:55 +00:00
Ted Kremenek be9b33bf0f Nico Weber:
"the attached patch fixes some typos, 80 cols violations, etc. in comments."

llvm-svn: 54328
2008-08-04 22:51:42 +00:00
Chris Lattner 7adf076088 Finally fix PR2189. This makes a fairly invasive but important change to
move getAsArrayType into ASTContext instead of being a method on type.
This is required because getAsArrayType(const AT), where AT is a typedef
for "int[10]" needs to return ArrayType(const int, 10).

Fixing this greatly simplifies getArrayDecayedType, which is a good sign.

llvm-svn: 54317
2008-08-04 07:31:14 +00:00
Eli Friedman bd84059cdb Minor tweak plus a couple of FIXMEs.
llvm-svn: 54119
2008-07-27 05:46:18 +00:00
Ted Kremenek 192510920e Fix serialization for TypedefType by allowing TypedefType to access the internal CanonicalType stored in Type.
The test case Serialization/stmt_exprs.c now passes.

llvm-svn: 54117
2008-07-27 03:47:53 +00:00
Chris Lattner 872eb55f5e make "call foo.dump()" and "call foo->dump()" work in GDB,
with QualTypes and Types.

llvm-svn: 54116
2008-07-27 00:48:22 +00:00
Chris Lattner 401cc23c4d Comment out the last call to QualType::getCanonicalType. This *breaks*
Serialization/stmt_exprs.c, but I don't know the right solution.  Will fix
when I get a chance to talk to Ted about it.

llvm-svn: 54109
2008-07-26 22:40:28 +00:00
Chris Lattner 574dee6cac change more instances of QualType::getCanonicalType to call
ASTContext::getCanonicalType instead (PR2189)

llvm-svn: 54105
2008-07-26 22:17:49 +00:00
Chris Lattner 6731544be7 convert more code to use ASTContext to get canonical types instead
of doing it directly.  This is required for PR2189.

llvm-svn: 54102
2008-07-26 21:30:36 +00:00
Chris Lattner 944d306371 fix some problems handling stmtexprs with labels (PR2374), and
improve 'expression unused' diagnostics for stmtexprs.

llvm-svn: 54098
2008-07-26 19:51:01 +00:00
Chris Lattner 06afbebbdd fix an extraneous blank line in -ast-dump output.
llvm-svn: 54097
2008-07-26 19:24:43 +00:00
Chris Lattner a075e63bbc fix several problems with the protocol qualified id handling where id was implicit.
First, fix canonical type handling of these, since protocol qualified id's are always
canonical.  Next, enhance SemaType to actually make these when used (instead of int)
allowing them to actually be used when appropriate.  Finally remove a bunch of logic
relating to the mishandling of canonical types with protocol-qual id's.  This fixes
rdar://5986251

llvm-svn: 54083
2008-07-26 00:46:50 +00:00
Chris Lattner 2841fc0e7b fix 80 col violation.
llvm-svn: 54075
2008-07-25 23:30:42 +00:00
Chris Lattner 903eb518e6 Fix rdar://6095136, various crashes with incomplete enum types.
llvm-svn: 54074
2008-07-25 23:18:17 +00:00
Chris Lattner 6bf59d82c8 minor cleanup
llvm-svn: 54073
2008-07-25 23:07:18 +00:00
Daniel Dunbar c9809a9d68 Remove unused ASTConsumer::HandleTopLevelDeclaration
llvm-svn: 54071
2008-07-25 22:39:30 +00:00
Chris Lattner ec8996d771 Add support for __extension__ as an lvalue. rdar://6097308
llvm-svn: 54033
2008-07-25 18:07:19 +00:00
Ted Kremenek 77c51b2aa3 Move isObjCObjectPointerType() from Sema to ASTContext.
llvm-svn: 53998
2008-07-24 23:58:27 +00:00
Ted Kremenek 1692342e58 Added UnaryOperator::isPrefix().
llvm-svn: 53963
2008-07-23 22:18:43 +00:00
Ted Kremenek 73295fab89 When constructing an ObjCIvarDecl object in Sema, provide its visibility up front instead of setting it afterwards.
This change also fixes a subtle bug where the access control of an ivar would be initialized to garbage if we didn't have an explicit visibility specifier (e.g., @private).

llvm-svn: 53955
2008-07-23 18:04:17 +00:00
Chris Lattner 390d39ac7e move two more lists of protocols over to use ObjCList<ObjCProtocolDecl>,
simplifying code along the way and fixing a problem and memory leak or two.

llvm-svn: 53876
2008-07-21 21:32:27 +00:00
Chris Lattner d004505b74 introduce a new ObjCList templated class and start moving
various objc lists over to it.  First up, the protocol list 
on ObjCInterfaceDecl.

llvm-svn: 53856
2008-07-21 18:19:38 +00:00
Chris Lattner 65056c48a7 rename setReferencedProtocolList -> addReferencedProtocols to
be consistent with ObjCInterfaceDecl.

llvm-svn: 53852
2008-07-21 17:23:15 +00:00
Chris Lattner ca1e848588 Switch initialization of the protocol list for an interface decl to use
the standard "set these as the list of protocols" interface instead of a 
strange "set this as the size and then set each one to the value" interface.
The problem with the later is that it a) is completely different from 
everything else, b) is awkward, and c) doesn't handle the case when a
referenced protocol is invalid: it set it to null.

This meant that all clients downstream would have to handle null protocols
in the protocol list, and empirically they didn't.  Fix this by not setting
invalid protocols in the referenced protocol list, fixing the crash on 
test/Sema/objc-interface-1.m

While I'm at it, clean up some locations so that we produce:

t.m:1:25: error: cannot find interface declaration for 'NSObject', superclass of 'NSWhatever'
@interface NSWhatever : NSObject <NSCopying>
~~~~~~~~~~~~~~~~~~~~~   ^

instead of:

t.m:1:1: error: cannot find interface declaration for 'NSObject', superclass of 'NSWhatever'
@interface NSWhatever : NSObject <NSCopying>
^

llvm-svn: 53846
2008-07-21 07:06:49 +00:00
Chris Lattner 419f699b55 use iterators instead of direct access to protocol list.
llvm-svn: 53831
2008-07-21 05:19:23 +00:00
Steve Naroff de7d0f69ba Two fixes:
- Make sure ObjCIvarDecl propagates the bitfield width.
- RewriteObjC::SynthesizeIvarOffsetComputation(): Avoid using the __OFFSETOF__ mumbo jumbo for bitfields (since it isn't legal C). This fixes <rdar://problem/5986079> clang ObjC rewriter: bitfields and ivar access don't mix.

llvm-svn: 53694
2008-07-16 18:22:22 +00:00
Chris Lattner 477c4be1e9 expand casts to handle what isIntegerConstantExpr handles.
Casts from pointers remain a problem. :)

llvm-svn: 53501
2008-07-12 01:15:53 +00:00
Chris Lattner 7174bf3722 Add support for __builtin_type_compatible_p, enums, etc.
llvm-svn: 53500
2008-07-12 00:38:25 +00:00
Chris Lattner 9941570ce9 start remembering diagnostics for various cases, add some missing
code.  Switch to Eli's getIntWidth method.

llvm-svn: 53499
2008-07-12 00:14:42 +00:00
Chris Lattner cdf34e7668 Provide a structure for passing down 'is evaluated' and passing up
diagnosic+loc info for i-c-e evaluation.

llvm-svn: 53490
2008-07-11 22:52:41 +00:00
Chris Lattner f09ad16cfc simplify some code a bit.
llvm-svn: 53477
2008-07-11 22:15:16 +00:00
Chris Lattner f8d7f72956 share code between sizeof(expr) and sizeof(type)
llvm-svn: 53475
2008-07-11 21:24:13 +00:00
Chris Lattner b062dcc17b implement support for __extension__, make sure the result of a
comparison has the right width.

llvm-svn: 53469
2008-07-11 19:29:32 +00:00
Chris Lattner ae8cc15977 add a new getIntTypeSizeInBits method.
llvm-svn: 53468
2008-07-11 19:24:49 +00:00
Chris Lattner 2bd2e028ca rename "SInt" methods to "Int" in APValue.
llvm-svn: 53467
2008-07-11 19:19:21 +00:00
Chris Lattner e13042c04f make the new evaluator avoid conversions APValue<->APSInt in some cases.
Add some accessors to APValue.

llvm-svn: 53465
2008-07-11 19:10:17 +00:00
Chris Lattner 05706e8859 rearrange some code, no functionality changes.
llvm-svn: 53463
2008-07-11 18:11:29 +00:00
Ted Kremenek 252d03c598 Patch by Csaba Hruska and Peter Neumark:
"adds support (de)serialization (from)to (in memory) buffer."

llvm-svn: 53425
2008-07-10 22:10:48 +00:00
Nuno Lopes e212c3ecc2 revert my bogus attempt to fix the comment. sorry for the noise.
llvm-svn: 53248
2008-07-08 21:13:06 +00:00
Anders Carlsson 0166481455 Fix small bug. The evaluator now works well enough to pass all tests
llvm-svn: 53238
2008-07-08 16:49:00 +00:00
Anders Carlsson 4a3585b7c0 More constant expression work.
llvm-svn: 53235
2008-07-08 15:34:11 +00:00
Anders Carlsson 9c18165448 Move out some methods.
llvm-svn: 53234
2008-07-08 14:35:21 +00:00
Anders Carlsson b5ad021cd7 More work.
llvm-svn: 53233
2008-07-08 14:30:00 +00:00
Seo Sanghyeon 1904f44757 Compilation fix
llvm-svn: 53222
2008-07-08 07:23:12 +00:00
Anders Carlsson 374b93df76 Port more of Eli's evaluator over. This makes the int evaluator handle binary and unary operators.
llvm-svn: 53221
2008-07-08 05:49:43 +00:00
Anders Carlsson 0a1707c6ba Commit beginnings of int evaluator. Currently not used.
llvm-svn: 53219
2008-07-08 05:13:58 +00:00
Nuno Lopes 7bfa180056 fix CheckForConstantInitializer() for Compound Literals
also fix the correspondent test (it was expecting more errors than it should. please confirm my fix is correct (at least gcc agrees with me)

llvm-svn: 53174
2008-07-07 16:46:50 +00:00
Anders Carlsson 7a241baf2f Shuffle things around in preparation for integrating Eli's constant evaluator.
llvm-svn: 53074
2008-07-03 04:20:39 +00:00
Argyrios Kyrtzidis ed9834272f Add Sema support for C++ classes.
llvm-svn: 52956
2008-07-01 10:37:29 +00:00
Chris Lattner 9a8d1d9e56 Make a few related changes:
1) add a new ASTContext::getFloatTypeSemantics method.
2) Use it from SemaExpr.cpp, CodeGenTypes.cpp and other places.
3) Change the TargetInfo.h get*Format methods to return their 
   fltSemantics byref instead of by pointer.
4) Change CodeGenFunction::EmitBuiltinExpr to allow builtins which
   sometimes expand specially and othertimes fall back to libm.
5) Add support for __builtin_nan("") to codegen, cases that don't pass
   in an empty string are currently lowered to libm calls.
6) Fix codegen of __builtin_infl.

llvm-svn: 52914
2008-06-30 18:32:54 +00:00
Eli Friedman 4f89ccb1df Fix for PR2501; this patch makes usual arithmetic conversions for
integers which have the same width and different signedness work 
correctly. (The testcase in PR2501 uses a comparison between long and 
unsigned int).

llvm-svn: 52853
2008-06-28 06:23:08 +00:00
Ted Kremenek 17ae57faa8 Update serialization for ObjCMessageExpr to handle additional bit-swizziling of receiver information.
llvm-svn: 52679
2008-06-24 17:00:08 +00:00
Ted Kremenek a3a37ae8c8 ObjCMessageExpr objects that represent messages to class methods now can contain the ObjCInterfaceDecl* of the target class if it was available when the ObjCMessageExpr object was constructed. The original interfaces of the class has been preserved (requiring no functionality changes from clients), but now a "getClasSInfo" method returns both the ObjCInterfaceDecl* and IdentifierInfo* of the target class.
llvm-svn: 52676
2008-06-24 15:50:53 +00:00
Chris Lattner 5d20a70d01 remove dead enums.
llvm-svn: 52581
2008-06-21 18:06:44 +00:00
Chris Lattner a9b3cae8fd Switch 'super' from being a weird cast thing to being a predefined expr node.
Patch by David Chisnall with objc rewriter and stmtdumper updates from me.

llvm-svn: 52580
2008-06-21 18:04:54 +00:00
Ted Kremenek 99ecdd175d Added ParentMap, a class to represent a lazily constructed mapping from child to parents.
llvm-svn: 52553
2008-06-20 21:40:36 +00:00
Chris Lattner 5696e7badf Change self/_cmd to be instances of ImplicitParamDecl instead of ParmVarDecl.
Patch by David Chisnall!

llvm-svn: 52422
2008-06-17 18:05:57 +00:00
Ted Kremenek c6501dbc10 Fix more strict-aliasing warnings.
Fix indentation of class declarations in ExprCXX.h

llvm-svn: 52380
2008-06-17 03:11:08 +00:00
Ted Kremenek 08e171183f This patch is motivated by numerous strict-aliasing warnings when compiling
clang as a Release build.

The big change is that all AST nodes (subclasses of Stmt) whose children are
Expr* store their children as Stmt* or arrays of Stmt*. This is to remove
strict-aliasing warnings when using StmtIterator. None of the interfaces of any
of the classes have changed (except those with arg_iterators, see below), as the
accessor methods introduce the needed casts (via cast<>). While this extra
casting may seem cumbersome, it actually adds some important sanity checks
throughout the codebase, as clients using StmtIterator can potentially overwrite
children that are expected to be Expr* with Stmt* (that aren't Expr*). The casts
provide extra sanity checks that are operational in debug builds to catch
invariant violations such as these.

For classes that have arg_iterators (e.g., CallExpr), the definition of
arg_iterator has been replaced. Instead of it being Expr**, it is an actual
class (called ExprIterator) that wraps a Stmt**, and provides the necessary
operators for iteration. The nice thing about this class is that it also uses
cast<> to type-checking, which introduces extra sanity checks throughout the
codebase that are useful for debugging.

A few of the CodeGen functions that use arg_iterator (especially from
OverloadExpr) have been modified to take begin and end iterators instead of a
base Expr** and the number of arguments. This matches more with the abstraction
of iteration. This still needs to be cleaned up a little bit, as clients expect
that ExprIterator is a RandomAccessIterator (which we may or may not wish to
allow for efficiency of representation).

This is a fairly large patch. It passes the tests (except CodeGen/bitfield.c,
which was already broken) on both a Debug and Release build, but it should
obviously be reviewed.

llvm-svn: 52378
2008-06-17 02:43:46 +00:00
Ted Kremenek 1c77e8f26b Silence uninitialized value warning in Release build.
llvm-svn: 52376
2008-06-16 23:46:27 +00:00
Ted Kremenek bba87243aa Silence uninitialized value warning during Release build.
llvm-svn: 52375
2008-06-16 23:45:12 +00:00
Argyrios Kyrtzidis de794aadae Fix "copy & paste" error.
llvm-svn: 52227
2008-06-11 23:15:56 +00:00
Argyrios Kyrtzidis 406fb231f8 -Add DeclChain member to DeclContext.
-ScopedDecls get chained to their DeclContext.
-DeclContext's DeclChain replaces FunctionDecl's DeclChain and EnumDecl's ElementList.

llvm-svn: 52164
2008-06-10 01:32:09 +00:00
Argyrios Kyrtzidis d8cb25ee90 Dump the name of CXXStruct/CXXUnion/CXXClass Decl subclasses.
llvm-svn: 52161
2008-06-09 23:36:53 +00:00
Argyrios Kyrtzidis 554a07bab3 -Changes to TagDecl:
Added TagKind enum.
  Added getTagKind() method.
  Added convenience methods: isEnum(), isStruct(), isUnion(), isClass().
-RecordDecl/CXXRecordDecl::Create() accept a TagKind enum instead of a DeclKind one.

llvm-svn: 52160
2008-06-09 23:19:58 +00:00
Argyrios Kyrtzidis 2951e14520 Added new C++ AST Decl subclasses.
llvm-svn: 52155
2008-06-09 21:05:31 +00:00
Chris Lattner a5678ccd4a capture whether a CharacterLiteral was wide or not in the AST.
Patch by Mike Stump!

llvm-svn: 52081
2008-06-07 22:35:38 +00:00
Chris Lattner a0173131fa Fix ast dumping to work with long double literals, e.g. we dump:
long double X() { return 1.0L; }

as:

long double X()
(CompoundStmt 0xb06a00 <t.c:2:17, col:32>
  (ReturnStmt 0xb068d0 <col:19, col:26>
    (FloatingLiteral 0xb02cf0 <col:26> 'long double' 1.000000)))

llvm-svn: 52080
2008-06-07 22:13:43 +00:00
Eli Friedman 7dbab8a6a1 Fix the line endings in the newly added DeclBase.cpp.
llvm-svn: 52075
2008-06-07 16:52:53 +00:00
Ted Kremenek ef17049bac Reclaim memory owned by ObjCForwardProtocolDecls.
llvm-svn: 52063
2008-06-06 21:05:33 +00:00
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
Sam Bishop 506215c708 Changed the Decl::Kind enum of the ObjCPropertyDecl class, so that it follows
the pattern of the other Decl classes.

llvm-svn: 49399
2008-04-08 20:49:25 +00:00
Chris Lattner aa9c7aed0f Add support for C++ default arguments, and rework Parse-Sema
interaction for function parameters, fixing PR2046.

Patch by Doug Gregor!

llvm-svn: 49369
2008-04-08 04:40:51 +00:00
Sam Bishop e0680b7e7a Pass the ASTContext object around when deserializing Decl and Stmt objects, so
they can be created using the same allocator as in the "from source code" case.

llvm-svn: 49353
2008-04-07 21:55:54 +00:00
Chris Lattner 4ba0cef93b random whitespace fixes.
llvm-svn: 49328
2008-04-07 07:01:58 +00:00
Chris Lattner fa00732562 fix a bug I introduced in my previous checkin.
llvm-svn: 49327
2008-04-07 06:58:21 +00:00
Chris Lattner e6b27c6ecd simplify array compatibility testing.
llvm-svn: 49326
2008-04-07 06:56:55 +00:00
Chris Lattner 7460fd297d simplify reference handling.
llvm-svn: 49325
2008-04-07 06:52:53 +00:00
Chris Lattner 49af6a4beb move some code around, no other change.
llvm-svn: 49324
2008-04-07 06:51:04 +00:00
Chris Lattner ec646834e7 simplify compatibility testing for tag types.
llvm-svn: 49323
2008-04-07 06:49:41 +00:00
Chris Lattner 3c7961597f merge compatibility testing of qualified/unqualified interfaces together
and fix a bug.

llvm-svn: 49322
2008-04-07 06:38:24 +00:00
Chris Lattner 64bf6ba308 Fix a really bad bug where type uniquing would merge a<x> with b<x> as the same
type, because it did not include a/b in the hash.

llvm-svn: 49321
2008-04-07 06:37:47 +00:00
Chris Lattner c9062d01d7 MyOtherClass<MyProtocol>* is compatible with MyClass*
if MyClass is a superclass of MyOtherClass, there is no need for
an exact interface match.

llvm-svn: 49320
2008-04-07 06:06:56 +00:00
Chris Lattner 7bbd3d75ef Remove a dead check for compatible builtin types
llvm-svn: 49319
2008-04-07 05:55:38 +00:00
Chris Lattner 90bef90ad4 futher simplify compatibility testing of objc interface types.
llvm-svn: 49318
2008-04-07 05:53:18 +00:00
Chris Lattner 9555466f7e ocuvector and vector should be compatible. Fix ASQual compatibility.
llvm-svn: 49316
2008-04-07 05:43:21 +00:00
Chris Lattner aee96c3a90 Fix comment typo, do reference eval at the correct type.
llvm-svn: 49315
2008-04-07 05:37:56 +00:00
Chris Lattner f8a6b4d4fc simplify vector type compatibility testing.
llvm-svn: 49314
2008-04-07 05:36:14 +00:00
Chris Lattner 2a3569b5d9 move ObjCQualifiedIdTypesAreCompatible out of ASTContext into Sema.
While it is similar to the other compatibility predicates in ASTContext,
it is not used by them and is different.

In addition, greatly simplify ObjCQualifiedIdTypesAreCompatible and
fix some canonical type bugs.  Also, simplify my Type::getAsObjC* methods.

llvm-svn: 49313
2008-04-07 05:30:13 +00:00
Chris Lattner ae947fe3f9 Replace an O(n^2) algorithm in areCompatObjCQualInterfaces with
an O(n) algorithm by taking advantage of the fact that the
protocol qualifier list is already guaranteed sorted.

llvm-svn: 49312
2008-04-07 05:05:41 +00:00
Chris Lattner e0ea37ace7 move sorting of qualifying protocols from the parser into
sema.  This allows clients of the parser to have the unmolested 
list if desired, and guarantees that noone can create an
ObjCQualifiedInterfaceType with an unsorted list.

llvm-svn: 49310
2008-04-07 04:56:42 +00:00
Chris Lattner bd7981a978 eliminate getReferencedProtocols from
ObjCQualifiedIdType/ObjCQualifiedInterfaceType, adding an interator 
interface instead.

llvm-svn: 49308
2008-04-07 04:44:08 +00:00
Chris Lattner f96084ee73 make QualifiedInterfaceTypesAreCompatible a static function
and start simplifying it.

llvm-svn: 49307
2008-04-07 04:17:40 +00:00
Chris Lattner ae1b6078e3 This predicate is just a generic "issuperclass" predicate, move it to the
ObjCInterfaceType as a method.

llvm-svn: 49306
2008-04-07 04:13:03 +00:00
Chris Lattner ddfdaf9a69 Simplify some objc compatibility testing, make interfaceTypesAreCompatible
a static function named isCompatibleInterfaceAssign.

llvm-svn: 49305
2008-04-07 04:07:56 +00:00
Chris Lattner f8c3e82897 simplify the logic in ASTContext::objcTypesAreCompatible
llvm-svn: 49302
2008-04-07 01:30:37 +00:00
Chris Lattner ba5862e74c clean up some logic in objc type handling. Specifically, make it so that
there are QualType::getAsObjc* type methods, and make isa<ObjCInterfaceType>
return true for ObjCQualifiedInterfaceType's.

llvm-svn: 49300
2008-04-07 00:27:04 +00:00
Chris Lattner b9dfb03ddb trivial changes to getFloatingTypeOfSizeWithinDomain, nothing significant.
llvm-svn: 49298
2008-04-06 23:58:54 +00:00
Chris Lattner d4bacd68bf simplify max type computation by making it return an integer (like
getFloatingTypeOrder) instead of a type.  Fix a fixme.

llvm-svn: 49297
2008-04-06 23:55:33 +00:00
Chris Lattner b90739d556 minor simplifications/cleanups to type comparisons.
llvm-svn: 49296
2008-04-06 23:38:49 +00:00
Chris Lattner f1e4ec2898 remove a use of getCanonicalType.
llvm-svn: 49294
2008-04-06 23:09:52 +00:00
Chris Lattner 76a00cf3ff Start switching clients over from CT.getCanonicalType() to Context.getCanonicalType(CT) for PR2189.
While I'm at it, clean up a bit of maxIntegerType.

llvm-svn: 49292
2008-04-06 22:59:24 +00:00
Chris Lattner ed0d0795ff introduce a new ASTContext::getCanonicalType method. This is the first
step towards fixing PR2189.

llvm-svn: 49291
2008-04-06 22:41:35 +00:00
Chris Lattner 7d9b6a9d50 Use EnumType to simplify some code.
llvm-svn: 49289
2008-04-06 22:29:16 +00:00
Chris Lattner 8b23c25b21 make use of EnumType to simplify some code, eliminate warnings
when assertions are disabled.

llvm-svn: 49288
2008-04-06 22:05:18 +00:00
Chris Lattner e07e912f5e Make EnumType/RecordType classof predicates simpler and more efficient in
some cases.

llvm-svn: 49287
2008-04-06 22:04:54 +00:00
Chris Lattner 3fb61c1fbb add a helper EnumType object for asking about tagtypes for enums.
llvm-svn: 49286
2008-04-06 21:58:47 +00:00
Chris Lattner 713e6592be Fix a bug I introduced in my const'ification patch.
llvm-svn: 49262
2008-04-06 05:25:03 +00:00
Chris Lattner 0a5ff0d34a This patch contains these changes:
-Renamed ContextDecl -> DeclContext
-Removed DeclContext pointer from FieldDecl
-EnumDecl inherits from DeclContext, instead of TagDecl

Patch by Argiris Kirtzidis!

llvm-svn: 49261
2008-04-06 04:47:34 +00:00
Chris Lattner 157dd0811e fix a number of const qualification bugs.
llvm-svn: 49257
2008-04-06 04:11:27 +00:00
Steve Naroff c7d38433cd Rename ScopedDecl::getContext() -> getContextDecl(). Two motivations:
#1: To be consistent with FieldDecl::getContextDecl(), which serves the same purpose.
#2: From my perspective, getContext() is too general (and used by several other classes for different purposes).

llvm-svn: 49224
2008-04-04 18:15:49 +00:00
Seo Sanghyeon 055c94f2f8 PR1963: Address of function is a constant expression
llvm-svn: 49212
2008-04-04 09:45:30 +00:00
Chris Lattner c5ffed4a66 Introduce ContextDecl, patch by Argiris Kirtzidis!
-Added ContextDecl (no TranslationUnitDecl)
-ScopedDecl class has a ContextDecl member
-FieldDecl class has a ContextDecl member, so that a Field or a ObjCIvar can be traced back to their RecordDecl/ObjCInterfaceDecl easily
-FunctionDecl, ObjCMethodDecl, TagDecl, ObjCInterfaceDecl inherit from ContextDecl. With TagDecl as ContextDecl, enum constants have a EnumDecl as their context.
-Moved Decl class to a "DeclBase.h" along with ContextDecl class
-CurContext is handled by Sema

llvm-svn: 49208
2008-04-04 06:12:32 +00:00
Sam Bishop 2f8a31ca92 trivial whitespace fix
llvm-svn: 49160
2008-04-03 14:20:28 +00:00
Sam Bishop 2289459bf6 Created a destructor so that the top-level decls can be deleted.
llvm-svn: 49142
2008-04-03 05:35:20 +00:00
Chris Lattner efdc7685d4 qualifier comparisons should be done on canonical types.
llvm-svn: 49137
2008-04-03 05:07:04 +00:00
Sam Bishop ca6226628e Call "delete" on the body of FunctionDecls.
llvm-svn: 49135
2008-04-03 05:01:04 +00:00
Chris Lattner db5f1fa3d8 add a common base class "PointerLikeType" for PointerType and ReferenceType,
allowing them to be treated the same in some contexts.  A suggestion for a
better name is welcome :)

llvm-svn: 49100
2008-04-02 17:35:06 +00:00
Chris Lattner 53be405c3a Add a citation.
llvm-svn: 49080
2008-04-02 06:06:35 +00:00
Chris Lattner a21ad8058a Fix several bugs in array -> pointer decomposition.
First, we got several CVR propagation cases wrong, which Eli pointed
out in PR2039.

Second, we didn't propagate address space qualifiers correctly, leading
to incorrect lowering of code in CodeGen/address-space.c.

Third, we didn't uniformly propagate the specifier in the array to the
pointer ("int[restrict 4]" -> "int *restrict").

This adds an ASTContext::getArrayDecayedType member that handles the 
non-trivial logic for this seemingly simple operation.

llvm-svn: 49078
2008-04-02 05:18:44 +00:00
Chris Lattner 800817bf6d remove blank line.
llvm-svn: 49075
2008-04-02 05:09:38 +00:00
Chris Lattner 091718d300 print cvr qualifiers on simplified typedefs
llvm-svn: 49074
2008-04-02 05:06:23 +00:00
Steve Naroff 257520b1b4 Fairly large "cleaup" related to changing ObjCCompatibleAliasDecl superclass (to inherit from NamedDecl, instead of ScopedDecl).
- Added a DenseMap to associate an IdentifierInfo with the ObjCCompatibleAliasDecl.
- Renamed LookupScopedDecl->LookupDecl and changed it's return type to Decl. Also added lookup for ObjCCompatibleAliasDecl's.
- Removed Sema::LookupInterfaceDecl(). Converted clients to used LookupDecl().
- Some minor indentation changes.

Will deal with ObjCInterfaceDecl and getObjCInterfaceDecl() in a separate commit...

llvm-svn: 49058
2008-04-01 23:04:06 +00:00
Chris Lattner 595cf9ff81 Update to match simplified llvm MemoryBuffer interfaces for files.
llvm-svn: 49042
2008-04-01 18:04:30 +00:00
Chris Lattner 59a2594f3f rename Decl::CompatibleAlias -> ObjCCompatibleAlias.
Fix objc ivar lookup.  Ivar lookup should occur between lookup
of method-local values and lookup of globals.  Emulate this with
some logic in the handling of Sema::ActOnIdentifierExpr.

Two todo's left:
 1) sema shouldn't turn a bare reference to an ivar into "self->ivar"
    in the AST.  This is a hack.
 2) The new ScopedDecl::isDefinedOutsideFunctionOrMethod method does
    not correctly handle typedefs and enum constants yet.

llvm-svn: 48972
2008-03-31 00:36:02 +00:00
Ted Kremenek fff4fc7e6d Bug fix in CFG construction: VisitCompoundStmt should return the last created block.
llvm-svn: 48460
2008-03-17 17:19:44 +00:00
Chris Lattner ed0e16404c clean up property memory allocation to move it into the ast classes
like the rest of the classes.

llvm-svn: 48434
2008-03-17 01:19:02 +00:00
Chris Lattner 41eec3d097 make property addition work list all other "add" methods. Do
the allocation in the class, not in sema.

llvm-svn: 48433
2008-03-16 21:23:50 +00:00
Chris Lattner 219b3e9c6c add the last two Create methods for decls, woo!
llvm-svn: 48432
2008-03-16 21:17:37 +00:00
Chris Lattner 36ac1cae1f add two more Create methods.
llvm-svn: 48428
2008-03-16 20:53:07 +00:00
Chris Lattner d77aff8232 simplify the way ObjCCategoryDecl's get their referenced protocols list
specified.  Previously, the ctor would allocate memory for the list and then
it would get filled in later.  Move the allocation+filling in to be more 
consistent with other stuff, e.g. the addMethods method.

llvm-svn: 48427
2008-03-16 20:47:45 +00:00
Chris Lattner 1dd77af9ce Add create methods for ObjCCategoryDecl, ObjCForwardProtocolDecl, ObjCClassDecl.
llvm-svn: 48426
2008-03-16 20:34:23 +00:00
Chris Lattner acc04a9261 minor cleanups, make getNumInstanceMethods always return unsigned.
llvm-svn: 48423
2008-03-16 20:19:15 +00:00
Chris Lattner f87ca0a7d1 Give ObjCProtocolDecl a Create method.
llvm-svn: 48410
2008-03-16 01:23:04 +00:00
Chris Lattner 96c501ef7e Add create methods for ObjCIvarDecl and ObjCInterfaceDecl
llvm-svn: 48408
2008-03-16 01:15:50 +00:00
Chris Lattner c557947488 remove some dead arguments to ObjCMethodDecl.
llvm-svn: 48406
2008-03-16 00:58:16 +00:00
Chris Lattner 8d8829e225 Give ObjCMethodDecl a Create method.
llvm-svn: 48405
2008-03-16 00:49:28 +00:00
Chris Lattner 893751970a Split objc decl implementation out into DeclObjC.cpp
llvm-svn: 48404
2008-03-16 00:19:01 +00:00
Chris Lattner ee1284a6e2 switch the rest of the C decl classes to do their
allocation through ASTContext.

llvm-svn: 48403
2008-03-16 00:16:02 +00:00
Chris Lattner 7a51313d8a Make a major restructuring of the clang tree: introduce a top-level
lib dir and move all the libraries into it.  This follows the main
llvm tree, and allows the libraries to be built in parallel.  The
top level now enforces that all the libs are built before Driver,
but we don't care what order the libs are built in.  This speeds
up parallel builds, particularly incremental ones.

llvm-svn: 48402
2008-03-15 23:59:48 +00:00