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! :)
Steve Naroff [Wed, 10 Oct 2007 23:24:43 +0000 (23:24 +0000)]
Refinements to Sema::GetObjcIdType()...
- Cache the typedef, not the type (avoids importing AST/Type.h).
- Emit an error if "id" cannot be found.
- Comment the routine and add a FIXME to reconsider how we emulate GCC's new fangled behavior. This isn't a priority for now, since almost no code depends on having "id" built-in.
- Add a test.
Steve Naroff [Wed, 10 Oct 2007 21:53:07 +0000 (21:53 +0000)]
- Make sure default return/argument types (for methods) default to "id".
- Cache the "id" type in Sema...initialize ObjcIdType and TUScope (oops).
- Fix ActOnInstanceMessage to allow for "id" type receivers...still work to do (next).
Chris Lattner [Tue, 9 Oct 2007 22:10:18 +0000 (22:10 +0000)]
Make a significant change to invert the control flow handling
predefined macros. Previously, these were handled by the driver,
now they are handled by the preprocessor.
Some fallout of this:
1. Instead of preprocessing two buffers (the predefines, then the
main source file) we now start preprocessing the main source
file and inject the predefines as a "psuedo #include" from the
main source file.
2. #1 allows us to nuke the Lexer::IsMainFile flag and simplify
Preprocessor::isInPrimaryFile.
3. The driver doesn't have to know about standard #defines, the
preprocessor knows, which is nice for people wanting to define
their own drivers.
4. This allows us to put normal tokens in the predefine buffer,
for example a definition for __builtin_va_list that is
target-specific, and a typedef for id in objc.
Steve Naroff [Tue, 9 Oct 2007 22:01:59 +0000 (22:01 +0000)]
Make sure methods with no return type default to "id".
This fixes a crasher in Sema::MatchTwoMethodDeclarations(), identified by selector-overload.m (just added).
Added Action::ActOnTranslationUnitScope() and renamed Action::PopScope to ActOnPopScope.
Added a Translation Unit Scope instance variable to Sema (will be very useful to ObjC-related actions, since ObjC declarations are always file-scoped).
Remove addition of protocol names to declaration scopes, use a separate
DenseMap to keep track of such declarations and derive ObjcProtocolDecl
directyly from NamedScope.