Steve Naroff [Thu, 18 Oct 2007 18:55:53 +0000 (18:55 +0000)]
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).
Ted Kremenek [Thu, 18 Oct 2007 18:19:31 +0000 (18:19 +0000)]
Refactored StmtIterator into classes StmtIteratorBase (non-templated)
and StmtIteratorImpl (templated), which StmtIterator and
ConstStmtIterator now succintly subclass.
Implemented iteration over the initializers in DeclStmts. This is not
thoroughly tested, so there may be bugs.
Steve Naroff [Thu, 18 Oct 2007 05:13:08 +0000 (05:13 +0000)]
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...
Chris Lattner [Thu, 18 Oct 2007 03:50:33 +0000 (03:50 +0000)]
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.
Ted Kremenek [Thu, 18 Oct 2007 00:24:38 +0000 (00:24 +0000)]
Implemented 90% functionality of new child_iterator for Stmt objects
that will (soon) allow iteration over the initializers in
declarations. This new iterator mechanism is implemented by the
classes StmtIterator and ConstStmtIterator.
Patched a few files to use "operator++" instead of "operator+" on
child_iterators.
Friendship added in VarDecl to StmtIterator to allow returning a
reference to the initializer within the VarDecl. We may not wish this
as a permanent solution.
Ted Kremenek [Wed, 17 Oct 2007 18:36:42 +0000 (18:36 +0000)]
Fixed includes of "clang/AST/DeclObjC.h" to work on case-sensitive
filesystems (was "#include "clang/AST/DeclObjc.h", which worked fine
on a case-insensitive HFS+ volume on the Mac).
Steve Naroff [Wed, 17 Oct 2007 17:53:50 +0000 (17:53 +0000)]
Predefine all the ObjC goodies from <objc/objc.h>. Removed all the ObjC goodies from the respective test files. Moving forward, it will be very nice to assume these builtin!
Hartmut Kaiser [Wed, 17 Oct 2007 15:00:17 +0000 (15:00 +0000)]
Updated VC++ build system.
Silenced some VC++ warnings.
Had to rephrase a partial specialization of the IntrospectionTrait struct in SerializationTest.cpp, please review.
Added a compiler specific workaround in IdentifierTable.h. Is that the way to fix this kind of issues?
Ted Kremenek [Tue, 16 Oct 2007 23:37:27 +0000 (23:37 +0000)]
Started work on clang object serialization. Experimental
serialization logic as well as driver code is now in
Driver/SerializationTest.cpp. The status of this code is that it
should be used by no clients.
Added --test-pickling option to driver to run the serialization code.
Modified IdentifierInfo and IdentifierTable to have friend classes
that permit object serialization. Such friendship may not be needed
in the final design.
Chris Lattner [Tue, 16 Oct 2007 22:36:42 +0000 (22:36 +0000)]
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.
Steve Naroff [Tue, 16 Oct 2007 21:36:54 +0000 (21:36 +0000)]
Remove ObjcMethodDecl::getNumMethodParams/getMethodParamDecl, they aren't used/needed.
Change ObjcMethodDecl::getMethodType to getResultType, to match FunctionDecl.
Steve Naroff [Mon, 15 Oct 2007 23:35:17 +0000 (23:35 +0000)]
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).
Steve Naroff [Mon, 15 Oct 2007 20:41:53 +0000 (20:41 +0000)]
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;
}
- 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).
Steve Naroff [Sun, 14 Oct 2007 23:13:51 +0000 (23:13 +0000)]
- Teach ObjcInterfaceDecl::lookupInstance/ClassMethod to look through protocols.
- Start looking up methods in the global method pools (for "id").
- Start integrating interface types into the type system.
Steve Naroff [Sun, 14 Oct 2007 00:58:41 +0000 (00:58 +0000)]
- Added Sema::AddFactoryMethodToGlobalPool and Sema::AddInstanceMethodToGlobalPool and DenseMaps. This will allow us to efficiently lookup a method from a selector given no type information (for the "id" data type).
- Fixed some funky "}
else {" indentation in Sema::ActOnAddMethodsToObjcDecl(). I'd prefer we stay away from this style...it wastes space and isn't any easier to read (from my perspective, at least:-)
- Changed Parser::ParseObjCInterfaceDeclList() to only call Action::ActOnAddMethodsToObjcDecl() when it actually has methods to add (since most interface have methods, this is a very minor cleanup).
Ted Kremenek [Fri, 12 Oct 2007 20:51:52 +0000 (20:51 +0000)]
Added notion of '*' specified format width/specifiers when checking
printf format strings. Added type checking to see if the matching
width/precision argument was of type 'int'.
Thanks to Anders Carlsson for reporting this missing feature.
Steve Naroff [Fri, 12 Oct 2007 18:49:25 +0000 (18:49 +0000)]
Replace one FIXME with another. We handle protocols just fine now. The ObjC decl will only be 0 when we have an error on the ObjC decl. I would prefer we pass in a decl that is marked as invalid. I don't think this is critical to fix now, however I'd like us to be consistent. There are currently many places that don't mark the decl as invalid (which need to be fixed)...
Chris Lattner [Thu, 11 Oct 2007 18:38:32 +0000 (18:38 +0000)]
Push the rewriting APIs along. Build a trivial client that replaces tabs
with x's for now. The APIs are all unimplemented, so it doesn't do
anything yet! :)