Commit Graph

219 Commits

Author SHA1 Message Date
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