Граф коммитов

1041 Коммитов

Автор SHA1 Сообщение Дата
Chris Lattner 2777e494c9 Make control flow in Expr::isConstantExpr more simple and
local, making the code easier to read.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43104 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-18 00:20:32 +00:00
Chris Lattner 01c5748c29 Add new API to rewrite one stmt/expr with another.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43101 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-17 22:35:30 +00:00
Chris Lattner 5075477aad Add rewriter support for @encode expressions. For example,
we currently turn:

    c = @encode(char *)[2] + 4;

into:

    c = "foo"[2] + 4;

Right now the foo string is hard coded, but you can imagine a world
where it wouldn't be :)




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43093 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-17 21:28:00 +00:00
Chris Lattner 9d62a5b31e The size returned by Rewriter::getRangeSize should include
the size of the last token.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43092 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-17 21:23:07 +00:00
Chris Lattner fd1f344f87 Fix assertion for raw lexer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43091 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-17 21:22:38 +00:00
Chris Lattner 9a61194376 Move token length calculation out of the diagnostics machinery into
the lexer, where it can be shared.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43090 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-17 21:18:47 +00:00
Chris Lattner 2b65a9ddab wean the diagnostics machinery off the preprocessor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43085 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-17 20:53:57 +00:00
Chris Lattner 168ae2d44a Add a new type of lexer: a raw lexer, which does not require a preprocessor
object in order to do its thing.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43084 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-17 20:41:00 +00:00
Steve Naroff 417c909e63 rename test file for builtin "id"...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43082 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-17 18:39:04 +00:00
Ted Kremenek 91d1d7a448 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).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43080 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-17 18:36:42 +00:00
Chris Lattner e5956bd273 add some comments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43079 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-17 18:28:59 +00:00
Steve Naroff 3b8e891be6 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!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43077 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-17 17:53:50 +00:00
Fariborz Jahanian 390d50a725 Implementation of AST for @protocol expression.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43075 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-17 16:58:11 +00:00
Hartmut Kaiser 7b66000bdf 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?


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43074 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-17 15:00:17 +00:00
Chris Lattner 338128bea1 fix problems with test/sema/Cocoa.m etc on non-apple machines.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43067 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-17 06:04:46 +00:00
Anders Carlsson 1a86b33c18 Generate code for static variables that don't have initializers. Also, report an error if a static initializer is not constant.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43058 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-17 00:52:43 +00:00
Anders Carlsson adc9b13208 Fix the build.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43057 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-17 00:50:25 +00:00
Ted Kremenek 5a59d92fb0 Added Driver/SerializationTest.cpp to the XCode project.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43054 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 23:40:12 +00:00
Ted Kremenek bfa82c4c23 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43052 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 23:37:27 +00:00
Fariborz Jahanian 2a35fa9b5e Fix location processing of @selector: the range should include the @ sign.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43051 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 23:21:02 +00:00
Steve Naroff 81bfde990c Add Sema::CheckMessageArgumentTypes()...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43050 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 23:12:48 +00:00
Chris Lattner 674af95412 Fix location processing of @encode: the range should include the @ sign.
@selector probably gets this wrong also.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43048 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 22:51:17 +00:00
Chris Lattner 311ff02fae 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43047 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 22:36:42 +00:00
Fariborz Jahanian 3e7fd152aa Patch to diagnose duplicate method implementations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43046 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 21:52:23 +00:00
Steve Naroff 3bea81bbae Remove ObjcMethodDecl::getNumMethodParams/getMethodParamDecl, they aren't used/needed.
Change ObjcMethodDecl::getMethodType to getResultType, to match FunctionDecl.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43045 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 21:36:54 +00:00
Chris Lattner 05de8bc173 publish location info
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43044 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 21:21:26 +00:00
Fariborz Jahanian c5c42f5311 Steve, pointer out that getName() is available for selectors. Made code much smaller, thanks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43042 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 21:07:53 +00:00
Chris Lattner 2c64b7b938 Push the rewriter forward a bit more. Now it rewrites
#import to #include's as a test.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43041 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 21:07:07 +00:00
Chris Lattner 10864b4725 these aren't const.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43040 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 21:04:49 +00:00
Fariborz Jahanian f24d95acc1 Fix problem dumping/printing method names with null selector.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43039 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 20:52:13 +00:00
Fariborz Jahanian b62f681340 Patch to implement AST generation for objective-c's @selector expression.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43038 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 20:40:23 +00:00
Steve Naroff 983df5b228 Emit diagnostics for methods not found.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43037 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 20:39:36 +00:00
Anton Korobeynikov bd0be39f4c Unbreak mingw32. Maybe there should be something like libClandSystem? :)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43029 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 09:09:44 +00:00
Chris Lattner 943140ee64 initialization of references should not do default fn/array promotions.
This fixes a bug Anders noticed.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43024 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 02:55:40 +00:00
Steve Naroff a1fe1176a4 Bad cast...need to use dyn_cast_or_null. Also changed Sema::InitBuiltinVaListType (which had the same bug).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43023 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 00:00:18 +00:00
Fariborz Jahanian a0818e3cd7 Patch to parse @selector expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43022 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 23:39:13 +00:00
Steve Naroff 2198891824 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).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43021 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 23:35:17 +00:00
Steve Naroff a642beb9f1 Fix a parser bug with message expressions - need to call ParsePostfixExpressionSuffix().
Now were correctly allow the following...

    i = [str rangeOfString:@"]"].length;



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43012 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 20:55:58 +00:00
Steve Naroff ec0550fa36 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).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43009 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 20:41:53 +00:00
Anders Carlsson 7c50aca2fe Add code generation and sema checking for __builtin_va_arg.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43006 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 20:28:48 +00:00
Fariborz Jahanian be127ba477 Several name lookup conflict detection fixes involving objective-c names.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43000 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 19:16:57 +00:00
Steve Naroff 7e219e47de Added ASTContext::setObjcIdType/getObjcIdType(), set by Sema.
Also noticed ASTContext::BuiltinVaListType wasn't being initialized to the null type (so I set it).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42983 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 14:41:52 +00:00
Steve Naroff 954ea17353 Teach the type checker about "id". This removes the following bogus warning...
[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang t.m
t.m:29:18: warning: incompatible pointer types assigning 'id' to 'NSString *'
    resultString = [[NSString alloc] initWithFormat:0 arguments:0];
    ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42975 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 03:14:16 +00:00
Anders Carlsson ee98ac5a13 Add support for Pascal strings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42974 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 02:50:23 +00:00
Anders Carlsson 1ff8b58fa0 Fix a warning
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42973 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 02:50:04 +00:00
Steve Naroff ff1afdb4f5 - 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42971 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-14 23:13:51 +00:00
Steve Naroff 3d58138992 Add category lookup (removing a couple FIXME's).
Changed ObjcInterfaceDecl::ListCategories->CategoryList.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42968 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-14 18:27:41 +00:00
Steve Naroff 8de2826e4d Fix -ast-dump for ObjC.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42967 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-14 17:03:01 +00:00
Steve Naroff 58ff9e8f06 - 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).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42957 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-14 00:58:41 +00:00
Anders Carlsson 23af9f2128 Fix an incorrect assertion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42951 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-13 05:52:34 +00:00