Commit Graph

593 Commits

Author SHA1 Message Date
Fariborz Jahanian ac73ff8868 Remaining work to collect objective-c's type qualifiers and use them to encode
method types.

llvm-svn: 43617
2007-11-01 17:18:37 +00:00
Devang Patel 32714064b1 Propagate bitfield info.
llvm-svn: 43613
2007-11-01 16:29:56 +00:00
Fariborz Jahanian 7a9c47480d 1) More additions for objective-c's qualifier type.
2) Fixed a test failure (which should have failed all along!).

llvm-svn: 43589
2007-10-31 23:53:01 +00:00
Fariborz Jahanian 95b6076c77 Fixed problem with rewriting stand-alone @implementation (with no matching @interface).
A new test case added.

llvm-svn: 43568
2007-10-31 18:48:14 +00:00
Steve Naroff 6d40db0dde Implement a more sensible strategy for ObjC built-in types (addressing a long standing FIXME in Sema::GetObjcIdType()).
This removes several gross hacks to work around the previous "lazy" behavior.

Two notes:
- MinimalActions still needs to be taught about the built-in types (This breaks one of the -noop test cases). I started this, then added a FIXME.
- I didn't convert Sema::GetObjcProtoType() yet.

llvm-svn: 43567
2007-10-31 18:42:27 +00:00
Fariborz Jahanian d728e949bb After Anders check-in, we can now encode 'Class' type.
llvm-svn: 43556
2007-10-31 16:00:13 +00:00
Anders Carlsson f56a7aee2f Encode Class, SEL and Objective-C objects.
llvm-svn: 43540
2007-10-31 02:53:19 +00:00
Fariborz Jahanian ca5338196f Added new type and bitfield fields in some decl types in preparation for objective-c's type qualifiers.
Added initialization of Class/SEMA types.

llvm-svn: 43534
2007-10-31 00:12:35 +00:00
Steve Naroff 5cdcd9b61c Stop pre-defining objc_msgSend/objc_getClass in the preprocessor. Instead, I generate these declaration on the fly when rewriting a message expression.
llvm-svn: 43529
2007-10-30 23:14:51 +00:00
Ted Kremenek 78036cdd5c Tightened IgnoreParen.
llvm-svn: 43517
2007-10-30 21:03:09 +00:00
Chris Lattner 0b11172e8c minor tweaks
llvm-svn: 43515
2007-10-30 20:57:56 +00:00
Fariborz Jahanian 18d7b30241 Revisited my last patch to be able to do encoding of ivar types with 'id'.
llvm-svn: 43507
2007-10-30 18:27:03 +00:00
Fariborz Jahanian 509d8d6fc6 Added type encoding for 'id' type.
llvm-svn: 43504
2007-10-30 17:06:23 +00:00
Steve Naroff 5448cf6d61 - Add location info to category/protocol AST's
- Rewrite categories.

llvm-svn: 43501
2007-10-30 13:30:57 +00:00
Steve Naroff 4cd61acc33 Remove a couple FIXME's for rewriting ObjC interfaces (which are now being rewritten properly).
llvm-svn: 43494
2007-10-30 03:43:13 +00:00
Steve Naroff c54840433f More support for rewriting ObjC intefaces. Still some edge cases to handle...
llvm-svn: 43493
2007-10-30 02:23:23 +00:00
Steve Naroff 33a1e80dd1 This commit contains lot's of small tweaks to how we pass around and store SourceLocation's for interfaces/protocols/categories/implementations.
llvm-svn: 43475
2007-10-29 21:38:07 +00:00
Ted Kremenek e2763b0948 Added some comments.
Moved a dependent predicate in an if statement to be an assertion
within the if statement body.

llvm-svn: 43453
2007-10-29 17:13:39 +00:00
Ted Kremenek e451eae8d7 For non-floating point types, added check for expressions of the form
"x == x" and "x != x".  We emit a warning for these since they always evaluate
to a constant value and often indicate a logical error.

Added test case for this check.

llvm-svn: 43450
2007-10-29 16:58:49 +00:00
Ted Kremenek fa907b8168 For floating point equality check, we now ignore parentheses. e.g.:
(x) == x  is the treated the same as x == x.

llvm-svn: 43448
2007-10-29 16:45:23 +00:00
Ted Kremenek d4ecc6da67 For checking for floating point comparison using == or !=, we now suppress
errors for cases such as "x == x".

Added test case to test this feature.

llvm-svn: 43447
2007-10-29 16:40:01 +00:00
Chris Lattner b104d31bd9 when checking for type equality, ignore typedefs.
llvm-svn: 43441
2007-10-29 05:15:40 +00:00
Chris Lattner 3bc4d20862 casting to void is ok for structs (C99 6.5.4p2), this fixes
one bogus error on PR1750.

llvm-svn: 43436
2007-10-29 04:26:44 +00:00
Chris Lattner 73c56c0735 Implement *skeletal* support for representing GNU inline asm stmts in the AST,
resolving a crash on a .i file in PR1750.  We now generate 49 errors on the
.i file in that bug.

llvm-svn: 43433
2007-10-29 04:04:16 +00:00
Steve Naroff 161a92b976 Start rewriting ObjC interfaces. As a start, we comment out all the methods. This involved refining how the parser/AST passes/manages SourceLocations for ObjcMethodDecl's.
llvm-svn: 43404
2007-10-26 20:53:56 +00:00
Fariborz Jahanian 3339d0d14e This patch allows synthesis generation of ivar offset for legacy objective-c @implementation
decl without an @interface decl.

llvm-svn: 43403
2007-10-26 20:50:24 +00:00
Fariborz Jahanian 99e96b0f11 Patch to synthesize computation of Ivar offset in rewritten c file.
Thanks to Steve N. to point out using of offsetof for this.

llvm-svn: 43391
2007-10-26 19:46:17 +00:00
Chris Lattner 8beb9dee0e Fix a crash on test/Sema/invalid-decl.c
llvm-svn: 43188
2007-10-19 20:10:30 +00:00
Steve Naroff 684dc4107f Fix the previous (short lived:-) FIXME.
I didn't realize that GCC considers this a hard error (I thought it was built-in).

Since it's not, we should simply emit an error.

[dylan:~/llvm/tools/clang] admin% cc -c trivial.m
trivial.m:6: error: cannot find interface declaration for 'NSConstantString'

[administrators-powerbook59:~/llvm/tools/clang] admin% ../../Debug/bin/clang trivial.m 
trivial.m:6:16: error: cannot find interface declaration for 'NSConstantString'
NSString *s = @"123";
               ^
1 diagnostic generated.

llvm-svn: 43157
2007-10-18 23:53:51 +00:00
Fariborz Jahanian e183a8259d Check for Nullness of value built in GetObjcProtoType.
llvm-svn: 43155
2007-10-18 22:59:23 +00:00
Steve Naroff eee59ebb15 Add a FIXME to an assert.
Change a dyn_cast_or_null back to cast (which is more efficient).

llvm-svn: 43152
2007-10-18 22:17:45 +00:00
Fariborz Jahanian c34409c281 Patch to rewrite ivar tables metadata for classes defined.
llvm-svn: 43151
2007-10-18 22:09:03 +00:00
Steve Naroff 1bb21df47f Tweak a recent fix to UsualArithmeticConversions (made by Chris - r43113). The benefit of this tweak is it guarantees the entire routine operates on unqualified types (which I believe is a bit clearer).
llvm-svn: 43142
2007-10-18 18:55:53 +00:00
Steve Naroff a78c464c9e Fix a bug in Sema::CheckConditionalOperands(). When mixing pointers and null pointer constants, we need to promote the null pointer constant (which is an integer) to the pointer type. Test case is self explanatory.
This surfaced yesterday, when compiling test/Sema/cocoa.m on Leopard. Since this has nothing to do with ObjC, it's kind of bizarre this hasn't shown up before. I imagine Cocoa.h on Leopard may have changed recently? 

Thanks to Ted for localizing the bug and giving me a useful AST dump...

llvm-svn: 43114
2007-10-18 05:13:08 +00:00
Chris Lattner fac7ac4130 UsualArithmeticConversions is crashing with an assert
when comparing "float" and "const float".  This "fixes" the
issue, but may not be the right fix.  Steve, please review.

Testcase here: test/Sema/usual-float.c

llvm-svn: 43113
2007-10-18 03:50:33 +00:00
Steve Naroff 8569d77349 Fix the following bug...
unsigned char asso_values[] = { 34 };
int legal2() { 
  return asso_values[0]; 
}

The code that creates the new constant array type was operating on the original type.

As a result, the constant type being generated was "unsigned char [1][]" (which is wrong).

The fix is to operate on the element type - in this case, the correct type is "unsigned char [1]"

I added this case to array-init.c, which clearly didn't catch this bogosity...

llvm-svn: 43112
2007-10-18 03:27:23 +00:00
Fariborz Jahanian a32aaefadc Implementation of AST for @protocol expression.
llvm-svn: 43075
2007-10-17 16:58:11 +00:00
Anders Carlsson f94cd1ffe6 Generate code for static variables that don't have initializers. Also, report an error if a static initializer is not constant.
llvm-svn: 43058
2007-10-17 00:52:43 +00:00
Fariborz Jahanian 6bd1d612ac Fix location processing of @selector: the range should include the @ sign.
llvm-svn: 43051
2007-10-16 23:21:02 +00:00
Steve Naroff 077c83bddb Add Sema::CheckMessageArgumentTypes()...
llvm-svn: 43050
2007-10-16 23:12:48 +00:00
Chris Lattner 37390bed4d Fix location processing of @encode: the range should include the @ sign.
@selector probably gets this wrong also.

llvm-svn: 43048
2007-10-16 22:51:17 +00:00
Chris Lattner a7c19feca2 Add a new Rewriter::getRangeSize method.
Rename SourceRange::Begin()/End() to getBegin()/getEnd() for
consistency with other code.
Start building the rewriter towards handling @encode.

llvm-svn: 43047
2007-10-16 22:36:42 +00:00
Fariborz Jahanian ebac2cb235 Patch to diagnose duplicate method implementations.
llvm-svn: 43046
2007-10-16 21:52:23 +00:00
Steve Naroff d275426449 Remove ObjcMethodDecl::getNumMethodParams/getMethodParamDecl, they aren't used/needed.
Change ObjcMethodDecl::getMethodType to getResultType, to match FunctionDecl.

llvm-svn: 43045
2007-10-16 21:36:54 +00:00
Fariborz Jahanian 4bef462a3e Patch to implement AST generation for objective-c's @selector expression.
llvm-svn: 43038
2007-10-16 20:40:23 +00:00
Steve Naroff 55f52da24c Emit diagnostics for methods not found.
llvm-svn: 43037
2007-10-16 20:39:36 +00:00
Chris Lattner e6dcd505d0 initialization of references should not do default fn/array promotions.
This fixes a bug Anders noticed.

llvm-svn: 43024
2007-10-16 02:55:40 +00:00
Steve Naroff 698495522d Bad cast...need to use dyn_cast_or_null. Also changed Sema::InitBuiltinVaListType (which had the same bug).
llvm-svn: 43023
2007-10-16 00:00:18 +00:00
Steve Naroff f73b784a5e Change the type of ObjCStringLiteral from "struct __builtin_CFString *" to "NSConstantString *".
This makes the typecheck much happier. Without this change, the type checker would have to special case "struct __builtin_CFString *". This change does assume the interface for NSConstantString is declared in the translation unit.

I left ASTContext::getCFConstantStringType() around for now (with a comment that says it is currently unused).

llvm-svn: 43021
2007-10-15 23:35:17 +00:00
Steve Naroff 32e44c0032 Move type compatibility predicates from Type to ASTContext. In addition, the predicates are now instance methods (they were previously static class methods on Type).
This allowed me to fix the following hack from this weekend...

// FIXME: Devise a way to do this without using strcmp.
// Would like to say..."return getAsStructureType() == IdStructType;", but
// we don't have a pointer to ASTContext.
bool Type::isObjcIdType() const {
  if (const RecordType *RT = getAsStructureType())
    return !strcmp(RT->getDecl()->getName(), "objc_object");
  return false;
}

...which is now...

bool isObjcIdType(QualType T) const {
  return T->getAsStructureType() == IdStructType;
}

Side notes:

- I had to remove a convenience function from the TypesCompatibleExpr class.

int typesAreCompatible() const {return Type::typesAreCompatible(Type1,Type2);}

Which required a couple clients get a little more verbose...

-    Result = TCE->typesAreCompatible();
+    Result = Ctx.typesAreCompatible(TCE->getArgType1(), TCE->getArgType2());

Overall, I think this change also makes sense for a couple reasons...

1) Since ASTContext vends types, it makes sense for the type compatibility API to be there.
2) This allows the type compatibility predeciates to refer to data not strictly present in the AST (which I have found problematic on several occasions).

llvm-svn: 43009
2007-10-15 20:41:53 +00:00