summaryrefslogtreecommitdiffstats
path: root/clang/Driver/RewriteObjC.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Add a couple FIXME's.Steve Naroff2008-12-021-0/+6
| | | | llvm-svn: 60427
* Make sure synthesized properties get inserted into the classes/categories ↵Steve Naroff2008-12-021-3/+22
| | | | | | meta data. llvm-svn: 60426
* Simplify previous commit.Steve Naroff2008-12-021-17/+14
| | | | llvm-svn: 60416
* More work to rewrite synthesize properties (<rdar://problem/6213955>)Steve Naroff2008-12-021-0/+50
| | | | llvm-svn: 60414
* -Add several ObjC types to Decl::getDeclKindName(), a useful debug hook.Steve Naroff2008-12-011-0/+11
| | | | | | -Start adding support for rewriting @synthesize. llvm-svn: 60368
* Rename NamedDecl::getName() to getNameAsString(). Replace a bunch of Chris Lattner2008-11-241-66/+66
| | | | | | | | | | | uses of getName() with uses of getDeclName(). This upgrades a bunch of diags to take DeclNames instead of std::strings. This also tweaks a couple of diagnostics to be cleaner and changes CheckInitializerTypes/PerformInitializationByConstructor to pass around DeclarationNames instead of std::strings. llvm-svn: 59947
* Rename NamedDecl::getIdentifierName() to ::getNameAsCString() and make itChris Lattner2008-11-241-19/+19
| | | | | | | | | assert if the name is not an identifier. Update callers to do the right thing and avoid this method in unsafe cases. This also fixes an objc warning that was missing a space, and migrates a couple more to taking IdentifierInfo and QualTypes instead of std::strings. llvm-svn: 59936
* Rename Selector::getName() to Selector::getAsString(), and addChris Lattner2008-11-241-15/+13
| | | | | | | | | | | | | a new NamedDecl::getAsString() method. Change uses of Selector::getName() to just pass in a Selector where possible (e.g. to diagnostics) instead of going through an std::string. This also adds new formatters for objcinstance and objcclass as described in the dox. llvm-svn: 59933
* Fix <rdar://problem/6291588> assertion failure: SourceManager.h line 489.Steve Naroff2008-11-191-2/+14
| | | | llvm-svn: 59664
* This reworks some of the Diagnostic interfaces a bit to change how diagnosticsChris Lattner2008-11-181-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | are formed. In particular, a diagnostic with all its strings and ranges is now packaged up and sent to DiagnosticClients as a DiagnosticInfo instead of as a ton of random stuff. This has the benefit of simplifying the interface, making it more extensible, and allowing us to do more checking for things like access past the end of the various arrays passed in. In addition to introducing DiagnosticInfo, this also substantially changes how Diagnostic::Report works. Instead of being passed in all of the info required to issue a diagnostic, Report now takes only the required info (a location and ID) and returns a fresh DiagnosticInfo *by value*. The caller is then free to stuff strings and ranges into the DiagnosticInfo with the << operator. When the dtor runs on the DiagnosticInfo object (which should happen at the end of the statement), the diagnostic is actually emitted with all of the accumulated information. This is a somewhat tricky dance, but it means that the accumulated DiagnosticInfo is allowed to keep pointers to other expression temporaries without those pointers getting invalidated. This is just the minimal change to get this stuff working, but this will allow us to eliminate the zillions of variant "Diag" methods scattered throughout (e.g.) sema. For example, instead of calling: Diag(BuiltinLoc, diag::err_overload_no_match, typeNames, SourceRange(BuiltinLoc, RParenLoc)); We will soon be able to just do: Diag(BuiltinLoc, diag::err_overload_no_match) << typeNames << SourceRange(BuiltinLoc, RParenLoc)); This scales better to support arbitrary types being passed in (not just strings) in a type-safe way. Go operator overloading?! llvm-svn: 59502
* Introduction the DeclarationName class, as a single, general method ofDouglas Gregor2008-11-171-19/+21
| | | | | | | | representing the names of declarations in the C family of languages. DeclarationName is used in NamedDecl to store the name of the declaration (naturally), and ObjCMethodDecl is now a NamedDecl. llvm-svn: 59441
* Fix <rdar://problem/6372970> clang ObjC rewriter: incorrect cast when ↵Steve Naroff2008-11-141-0/+1
| | | | | | | | passing block argument SynthBlockInitExpr() was not adding by-ref arguments to the init expr. llvm-svn: 59322
* Fix <rdar://problem/6370288> clang ObjC rewriter: Too many _objc_symtab, ↵Steve Naroff2008-11-141-9/+9
| | | | | | _OBJC_SYMBOLS llvm-svn: 59301
* Fix an obscure rewriter bug when rewriting implementations that don't have a ↵Steve Naroff2008-11-131-6/+15
| | | | | | corresponding interface (found while doing random testing on another bug). llvm-svn: 59259
* Fix <rdar://problem/6343942> clang ObjC rewriter: crash rewriting blocks Steve Naroff2008-11-131-1/+1
| | | | | | and <rdar://problem/6344601> clang ObjC rewriter: crash passing Block parameter? llvm-svn: 59251
* [LLVM up] Update for raw_fd_ostream change. This fixes a FIXME thatDaniel Dunbar2008-11-131-2/+2
| | | | | | | | the Backend output should be done in binary mode. - I'd appreciate it if someone who has a Windows build could verify this. llvm-svn: 59221
* Implement support for operator overloading using candidate operatorDouglas Gregor2008-11-121-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | functions for built-in operators, e.g., the builtin bool operator==(int const*, int const*) can be used for the expression "x1 == x2" given: struct X { operator int const*(); } x1, x2; The scheme for handling these built-in operators is relatively simple: for each candidate required by the standard, create a special kind of candidate function for the built-in. If overload resolution picks the built-in operator, we perform the appropriate conversions on the arguments and then let the normal built-in operator take care of it. There may be some optimization opportunity left: if we can reduce the number of built-in operator overloads we generate, overload resolution for these cases will go faster. However, one must be careful when doing this: GCC generates too few operator overloads in our little test program, and fails to compile it because none of the overloads it generates match. Note that we only support operator overload for non-member binary operators at the moment. The other operators will follow. As part of this change, ImplicitCastExpr can now be an lvalue. llvm-svn: 59148
* Introduce a single AST node SizeOfAlignOfExpr for all sizeof and alignof ↵Sebastian Redl2008-11-111-3/+4
| | | | | | expressions, both of values and types. llvm-svn: 59057
* Add a new expression class, ObjCSuperExpr, to handle the Objective-C ↵Douglas Gregor2008-11-041-3/+2
| | | | | | 'super'. Remove ObjCThis from PredefinedExpr llvm-svn: 58698
* Fix <rdar://problem/6339636> clang ObjC rewriter: Assertion failed: FileID-1 ↵Steve Naroff2008-11-031-28/+28
| | | | | | < FileIDs.size() && "Invalid FileID!", file c:\cygwin\home\Administrator\llvm\tools\clang\include\clang/Basic/SourceManager.h, line 513 llvm-svn: 58654
* Fix <rdar://problem/6336774> clang block rewriter: Assertion failed: ↵Steve Naroff2008-11-031-0/+3
| | | | | | Offset+NumBytes <= size() && "Invalid region to erase!", file c:\cygwin\home\Administrator\llvm\to ols\clang\include\clang/Rewrite/RewriteRope.h, line 219. llvm-svn: 58607
* Make sure RewriteObjCMethodDecl() does a block pointer rewrite.Steve Naroff2008-10-301-1/+6
| | | | llvm-svn: 58430
* Add a couple fixes for rewriting ivars/methods that use/contain blocks.Steve Naroff2008-10-301-2/+9
| | | | | | | | | | | | | | | | | | | Now this: @interface Test { void (^ivar)(void); } - (void)name; @end @implementation Test - (void)name { ivar = ^{ printf("hello\n"); }; // ((struct Test_IMPL *)self)->ivar = (void (*)(void))&__name_block_impl_0((void *)__name_block_func_0); ivar(); // ((void (*)(struct __block_impl *))((struct __block_impl *)((struct Test_IMPL *)self)->ivar)->FuncPtr)((struct __block_impl *)((struct Test_IMPL *)self)->ivar); } llvm-svn: 58428
* Convert SynthesizeBlockCall() from test->AST based implementation.Steve Naroff2008-10-301-37/+52
| | | | llvm-svn: 58427
* Convert SynthBlockInitExpr() from text->AST based implementation.Steve Naroff2008-10-291-16/+28
| | | | llvm-svn: 58396
* Handle block literals at file scope, remove some dead code, etc.Steve Naroff2008-10-291-109/+23
| | | | llvm-svn: 58390
* Make sure internally synthesized block pointer types are converted before ↵Steve Naroff2008-10-291-0/+5
| | | | | | pretty printing. llvm-svn: 58380
* More changes necessary to integrate the objc and blocks rewriters.Steve Naroff2008-10-281-310/+409
| | | | | | | | | | | | | | With this commit, stuff like this is very close to working... [foo barf:^(int){ printf("whatever\n"); }]; Here is what is currently translates to... ((id (*)(id, SEL, void (^)(int)))(void *)objc_msgSend)((id)foo, sel_registerName("barf:"), (void (*)(int))__main_block_func_0); I just need make sure the funky cast on objc_msgSend() is converted from "void (^)(int)" to "void (*)(int)". Since the cast doesn't appear in the source code, it needs to be converted in RewriteObjC::SynthMessageExpr(). llvm-svn: 58348
* Rename ExplicitCCastExpr to CStyleCastExprDouglas Gregor2008-10-281-18/+18
| | | | llvm-svn: 58331
* Fix testsuite regression for "crash.m".Steve Naroff2008-10-271-1/+3
| | | | llvm-svn: 58269
* Refactor the expression class hierarchy for casts. Most importantly:Douglas Gregor2008-10-271-30/+41
| | | | | | | | | | | | | | | | | | | | | | - CastExpr is the root of all casts - ImplicitCastExpr is (still) used for all explicit casts - ExplicitCastExpr is now the root of all *explicit* casts - ExplicitCCastExpr (new name needed!?) is a C-style cast in C or C++ - CXXFunctionalCastExpr inherits from ExplicitCastExpr - CXXNamedCastExpr inherits from ExplicitCastExpr and is the root of all of the C++ named cast expression types (static_cast, dynamic_cast, etc.) - Added classes CXXStaticCastExpr, CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr to Also, fixed returned-stack-addr.cpp, which broke once when we fixed reinterpret_cast to diagnose double->int* conversions and again when we eliminated implicit conversions to reference types. The fix is in both testcase and SemaChecking.cpp. Most of this patch is simply support for the renaming. There's very little actual change in semantics. llvm-svn: 58264
* Some fixups to the previous objc/blocks rewriter smerge.Steve Naroff2008-10-271-11/+21
| | | | llvm-svn: 58262
* Integrate the blocks and objc rewriters.Steve Naroff2008-10-271-13/+840
| | | | llvm-svn: 58253
* Remember whether an initlist had a designator in the AST.Chris Lattner2008-10-261-3/+4
| | | | llvm-svn: 58218
* Don't give a default argument to ASTContext::getFunctionType for the ↵Argyrios Kyrtzidis2008-10-261-12/+12
| | | | | | | | | TypeQuals parameter, it causes subtle bugs where TypeQuals, while necessary, are omitted from the call. -Remove the default argument. -Update all call sites of ASTContext::getFunctionType. llvm-svn: 58187
* Preliminary support for function overloadingDouglas Gregor2008-10-211-1/+2
| | | | llvm-svn: 57909
* Fix <rdar://problem/6297052> confused in some way by embedded /* */ comments.Steve Naroff2008-10-211-2/+2
| | | | llvm-svn: 57903
* Remove unneeded EncodingRecordTypes argument to getObjCEncodingForType.Daniel Dunbar2008-10-171-7/+3
| | | | llvm-svn: 57716
* Explicitly access the first Decl* referenced by a DeclStmt instead of using ↵Ted Kremenek2008-10-061-3/+9
| | | | | | "getDecl()." Added a FIXME indicating that the call to RewriteObjCQualifiedInterfaceTypes() is meant to modifying the type-specifier; hopefully this will be a little more clean once DeclGroups contain type specifiers. llvm-svn: 57216
* Use "DeclStmt::getSolitaryDecl()" when accessing the DeclStmt of an @catch.Ted Kremenek2008-10-061-1/+1
| | | | llvm-svn: 57215
* Use DeclStmt::getSolitaryDecl() instead of DeclStmt::getDecl() when ↵Ted Kremenek2008-10-061-2/+3
| | | | | | rewriting Objective-c foreach statements. llvm-svn: 57212
* Patch by Csaba Hruska!Ted Kremenek2008-09-131-12/+19
| | | | | | | "Here is a patch what replaces std::ostream with llvm::raw_ostream. This patch covers the AST library, but ignores Analysis lib." llvm-svn: 56185
* Fix <rdar://problem/6210791> clang ObjC rewriter: @try / @catch block with ↵Steve Naroff2008-09-111-2/+15
| | | | | | | | no @finally does not call objc_exception_try_exit. Need a couple tweaks to RewriteObjCTryStmt(). Need to deal with implicit finally clauses (to make sure objc_exception_try_exit is called). Also fixed a related bug where we need to generate an implicit @catch else clause (to again make sure objc_exception_try_exit is called). llvm-svn: 56104
* Fix <rdar://problem/6197841> try, finally with no catch stops the exception ↵Steve Naroff2008-09-091-0/+5
| | | | | | from being propagated llvm-svn: 56004
* Change struct forward declarations and definitions to use unique ↵Ted Kremenek2008-09-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | RecordDecls, as opposed to creating a single RecordDecl and reusing it. This change effects both RecordDecls and CXXRecordDecls, but does not effect EnumDecls (yet). The motivation of this patch is as follows: - Capture more source information, necessary for refactoring/rewriting clients. - Pave the way to resolve ownership issues with RecordDecls with the forthcoming addition of DeclGroups. Current caveats: - Until DeclGroups are in place, we will leak RecordDecls not explicitly referenced by the AST. For example: typedef struct { ... } x; The RecordDecl for the struct will be leaked because the TypedefDecl doesn't refer to it. This will be solved with DeclGroups. - This patch also (temporarily) breaks CodeGen. More below. High-level changes: - As before, TagType still refers to a TagDecl, but it doesn't own it. When a struct/union/class is first referenced, a RecordType and RecordDecl are created for it, and the RecordType refers to that RecordDecl. Later, if a new RecordDecl is created, the pointer to a RecordDecl in RecordType is updated to point to the RecordDecl that defines the struct/union/class. - TagDecl and RecordDecl now how a method 'getDefinition()' to return the TagDecl*/RecordDecl* that refers to the TagDecl* that defines a particular enum/struct/class/union. This is useful from going from a RecordDecl* that defines a forward declaration to the RecordDecl* that provides the actual definition. Note that this also works for EnumDecls, except that in this case there is no distinction between forward declarations and definitions (yet). - Clients should no longer assume that 'isDefinition()' returns true from a RecordDecl if the corresponding struct/union/class has been defined. isDefinition() only returns true if a particular RecordDecl is the defining Decl. Use 'getDefinition()' instead to determine if a struct has been defined. - The main changes to Sema happen in ActOnTag. To make the changes more incremental, I split off the processing of enums and structs et al into two code paths. Enums use the original code path (which is in ActOnTag) and structs use the ActOnTagStruct. Eventually the two code paths will be merged, but the idea was to preserve the original logic both for comparison and not to change the logic for both enums and structs all at once. - There is NO CHAINING of RecordDecls for the same RecordType. All RecordDecls that correspond to the same type simply have a pointer to that type. If we need to figure out what are all the RecordDecls for a given type we can build a backmap. - The diff in CXXRecordDecl.[cpp,h] is actually very small; it just mimics the changes to RecordDecl. For some reason 'svn' marks the entire file as changed. Why is CodeGen broken: - Codegen assumes that there is an equivalence between RecordDecl* and RecordType*. This was true before because we only created one RecordDecl* for a given RecordType*, but it is no longer true. I believe this shouldn't be too hard to change, but the patch was big enough as it is. I have tested this patch on both the clang test suite, and by running the static analyzer over Postgresql and a large Apple-internal project (mix of Objective-C and C). llvm-svn: 55839
* Remove "NextDecl" from RecordDecl. This change touches many files that ↵Ted Kremenek2008-09-051-6/+6
| | | | | | | | where RecordDecl or CXXRecordDecl was constructed, always with an argument of 'NULL' for the previous declaration. The motivation behind this change is that chaining the RecordDecls is simply unnecessary. Once we create multiple RecordDecls for the same struct/union/class, clients that care about all the declarations of the same struct can build a back map by seeing which Decls refer to the same RecordType. llvm-svn: 55821
* RewriteObjC::RewriteObjCSynchronizedStmt(): Make sure the sync expr is cast ↵Steve Naroff2008-08-211-3/+7
| | | | | | | | to "id". This fixes <rdar://problem/6163088> clang ObjC rewriter: @synchronized ([foo class]) {} does not cast properly. llvm-svn: 55118
* Fix crasher in RewriteObjC::RewriteObjCSynchronizedStmt(). Can't depend on ↵Steve Naroff2008-08-191-5/+7
| | | | | | | | the source locations of the sync expression (since it may have been rewritten. Fixes <rdar://problem/6156363> clang ObjC rewriter: rewriting attached file causes assertion failure: invalid FileID llvm-svn: 54986
* Add ExplicitCastExpr to replace the current CastExpr, and have ↵Argyrios Kyrtzidis2008-08-181-17/+20
| | | | | | | | | | | ImplicitCastExpr and ExplicitCastExpr derive from a common base class (CastExpr): Expr -> CastExpr -> ExplicitCastExpr -> ImplicitCastExpr llvm-svn: 54955
* rename PreDefinedExpr -> PredefinedExprChris Lattner2008-08-101-2/+2
| | | | llvm-svn: 54605
OpenPOWER on IntegriCloud