summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/Sema.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Addressed the issue in <rdar://problem/6479085>, where we failed toDouglas Gregor2009-01-091-1/+1
| | | | | | | | | | | | | | | rewrite @class declarations that showed up within linkage specifications because those @class declarations never made it any place where the rewriter could find them. Moved all of the ObjC*Decl nodes over to ScopedDecls, so that they can live in the appropriate top-level or transparent DeclContext near the top level, e.g., TranslationUnitDecl or LinkageSpecDecl. Objective-C declarations now show up in a traversal of the declarations in a DeclContext (they didn't before!). This way, the rewriter finds all Objective-C declarations within linkage specifications. llvm-svn: 61966
* This is a large/messy diff that unifies the ObjC AST's with DeclContext.Steve Naroff2009-01-081-1/+1
| | | | | | | | | | | | | | | - ObjCContainerDecl's (ObjCInterfaceDecl/ObjCCategoryDecl/ObjCProtocolDecl), ObjCCategoryImpl, & ObjCImplementation are all DeclContexts. - ObjCMethodDecl is now a ScopedDecl (so it can play nicely with DeclContext). - ObjCContainerDecl now does iteration/lookup using DeclContext infrastructure (no more linear search:-) - Removed ASTContext argument to DeclContext::lookup(). It wasn't being used and complicated it's use from an ObjC AST perspective. - Added Sema::ProcessPropertyDecl() and removed Sema::diagnosePropertySetterGetterMismatch(). - Simplified Sema::ActOnAtEnd() considerably. Still more work to do. - Fixed an incorrect casting assumption in Sema::getCurFunctionOrMethodDecl(), now that ObjCMethodDecl is a ScopedDecl. - Removed addPropertyMethods from ObjCInterfaceDecl/ObjCCategoryDecl/ObjCProtocolDecl. This passes all the tests on my machine. Since many of the changes are central to the way ObjC finds it's methods, I expect some fallout (and there are still a handful of FIXME's). Nevertheless, this should be a step in the right direction. llvm-svn: 61929
* Expr and Stmt must be destroyed with Destroy, not delete. Fixes PR/3245.Sebastian Redl2008-12-221-2/+2
| | | | llvm-svn: 61335
* Unifies the name-lookup mechanisms used in various parts of the ASTDouglas Gregor2008-12-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and separates lexical name lookup from qualified name lookup. In particular: * Make DeclContext the central data structure for storing and looking up declarations within existing declarations, e.g., members of structs/unions/classes, enumerators in C++0x enums, members of C++ namespaces, and (later) members of Objective-C interfaces/implementations. DeclContext uses a lazily-constructed data structure optimized for fast lookup (array for small contexts, hash table for larger contexts). * Implement C++ qualified name lookup in terms of lookup into DeclContext. * Implement C++ unqualified name lookup in terms of qualified+unqualified name lookup (since unqualified lookup is not purely lexical in C++!) * Limit the use of the chains of declarations stored in IdentifierInfo to those names declared lexically. * Eliminate CXXFieldDecl, collapsing its behavior into FieldDecl. (FieldDecl is now a ScopedDecl). * Make RecordDecl into a DeclContext and eliminates its Members/NumMembers fields (since one can just iterate through the DeclContext to get the fields). llvm-svn: 60878
* change getCurFunctionDecl to skip through Block contexts to findChris Lattner2008-12-041-0/+20
| | | | | | | | the containing block. Introduce a new getCurFunctionOrMethodDecl method to check to see if we're in a function or objc method. Minor cleanups to other related places. This fixes rdar://6405429. llvm-svn: 60564
* Overload resolution for the operator new function. Member version is still ↵Sebastian Redl2008-12-031-1/+2
| | | | | | untested. llvm-svn: 60503
* Rename Selector::getName() to Selector::getAsString(), and addChris Lattner2008-11-241-3/+14
| | | | | | | | | | | | | 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
* add support for inserting a DeclarationName into a diagnostic directlyChris Lattner2008-11-231-5/+12
| | | | | | | without calling getAsString(). This implicitly puts quotes around the name, so diagnostics need to be tweaked to accommodate this. llvm-svn: 59916
* Genericize the qualtype formating callback to support any diag argument.Chris Lattner2008-11-231-3/+4
| | | | | | No functionality change. llvm-svn: 59908
* Add support for sending QualType's directly into diags and convert twoChris Lattner2008-11-231-0/+19
| | | | | | | | | | diags over to use this. QualTypes implicitly print single quotes around them for uniformity and future extension. Doing this requires a little function pointer dance to prevent libbasic from depending on libast. llvm-svn: 59907
* move the Diag method for Sema to be inline. This shrinks the release-assertsChris Lattner2008-11-221-6/+2
| | | | | | | | | clang executable (when built with gcc 4.2 on the mac) from 14519740 to 14495028 bytes. This shrinks individual object files as well: SemaChecking from 23580->22248, SemaDeclObjc from 61368->57376, SemaExpr from 115628->110516, as well as several others. llvm-svn: 59867
* Split the DiagnosticInfo class into two disjoint classes:Chris Lattner2008-11-221-1/+1
| | | | | | | | | | one for building up the diagnostic that is in flight (DiagnosticBuilder) and one for pulling structured information out of the diagnostic when formatting and presenting it. There is no functionality change with this patch. llvm-svn: 59849
* remove the last old-fashioned Diag method. Transition complete!Chris Lattner2008-11-201-5/+0
| | | | llvm-svn: 59714
* remove another old Diag method.Chris Lattner2008-11-201-6/+0
| | | | llvm-svn: 59713
* remove another old-school Diag method.Chris Lattner2008-11-201-6/+0
| | | | llvm-svn: 59712
* remove the type_info identifier cache. Compared to the costChris Lattner2008-11-201-2/+0
| | | | | | | | | | | of doing the lookup_decl, the hash lookup is cheap. Also, typeid doesn't happen enough in real world code to worry about it. I'd like to eventually get rid of KnownFunctionIDs from Sema also, but today is not that day. llvm-svn: 59711
* compared to the rest of the code in Sema::GetStdNamespace(),Chris Lattner2008-11-201-1/+0
| | | | | | | looking up the "std" identifier is trivial. Just do it, particularly since this is only done if the namespace hasn't already been looked up. llvm-svn: 59710
* remove some other identifiers that are looked up really early and onlyChris Lattner2008-11-201-6/+0
| | | | | | used in one cold place. llvm-svn: 59709
* instead of looking up super at startup time, Chris Lattner2008-11-201-2/+0
| | | | | | | just check for it when needed. It doesn't incur real cost in any hot paths. llvm-svn: 59708
* remove one more old-style Diag method.Chris Lattner2008-11-191-7/+2
| | | | llvm-svn: 59589
* Switch several more Sema Diag methods over. This simplifies theChris Lattner2008-11-191-21/+4
| | | | | | | | __builtin_prefetch code to only emit one diagnostic per builtin_prefetch. While this has nothing to do with the rest of the patch, the code seemed like overkill when I was updating it. llvm-svn: 59588
* start converting Sema over to using its canonical Diag method.Chris Lattner2008-11-181-17/+0
| | | | llvm-svn: 59561
* introduce the one true Diag method for Sema. Next up: kill all the others off.Chris Lattner2008-11-181-3/+3
| | | | llvm-svn: 59556
* This reworks some of the Diagnostic interfaces a bit to change how diagnosticsChris Lattner2008-11-181-23/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Change the diagnostics interface to take an array of pointers to Chris Lattner2008-11-181-8/+11
| | | | | | | | strings instead of array of strings. This reduces string copying in some not-very-important cases, but paves the way for future improvements. llvm-svn: 59494
* Fix <rdar://problem/6320086> parser rejects block capturing ivar.Steve Naroff2008-11-171-1/+4
| | | | llvm-svn: 59444
* Implement support for operator overloading using candidate operatorDouglas Gregor2008-11-121-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Implement C++ 'typeid' parsing and sema.Sebastian Redl2008-11-111-0/+4
| | | | llvm-svn: 59042
* Implement Sema support for C++ nested-name-specifiers.Argyrios Kyrtzidis2008-11-081-3/+3
| | | | llvm-svn: 58916
* Some cleanup of the cast checkers. Don't canonicalize types when not needed. ↵Sebastian Redl2008-11-041-7/+0
| | | | | | Use distinct diagnostics for distinct errors. llvm-svn: 58700
* Semantic analysis for C++ reinterpret_cast and const_cast. Patch by ↵Douglas Gregor2008-10-241-0/+7
| | | | | | Sebastian Redl. llvm-svn: 58094
* Add Sema implementation of #pragma pack stack. Daniel Dunbar2008-10-141-1/+1
| | | | | | | | | | | - Follows the MSVC (original) implementation, including support of pack(show) (useful for testing). - Implements support for named pack records which gcc seems to ignore (or implements incorrectly). - Not currently wired to anything, only functionality change is the type checking of the pragma. llvm-svn: 57476
* Add support for format string checking of object-size checkingDaniel Dunbar2008-10-021-11/+16
| | | | | | | versions of sprintf and friends. - Added FIXME that this mechanism should be generalized. llvm-svn: 56962
* Add a LangOptions member to IdentifierResolver.Argyrios Kyrtzidis2008-09-091-1/+2
| | | | | | Make Sema pass the LangOptions to IdentifierResolver's constructor. llvm-svn: 56015
* Tweak implementation for allowing ObjC builtin type redefinitions.Steve Naroff2008-09-091-6/+6
| | | | | | | | | | | - Replace string comparisons with pre-defined idents. - Avoid calling isBuiltinObjCType() to avoid two checks. - Remove isBuiltinObjCType(), since it was only used in Sema::MergeTypeDefDecl(). - Have Sema::MergeTypeDefDecl() set the new type. This is a moidified version of an patch by David Chisnall. llvm-svn: 55990
* Remove "NextDecl" from RecordDecl. This change touches many files that ↵Ted Kremenek2008-09-051-2/+2
| | | | | | | | 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
* Generate error if we try to implicit cast between different addressMon P Wang2008-09-041-5/+20
| | | | | | spaces llvm-svn: 55765
* Add semantic analysis for "blocks". Steve Naroff2008-09-031-1/+1
| | | | | | | | | | | | | | | Highlights... - 4 new AST nodes, BlockExpr, BlockStmtExpr, BlockExprExpr, BlockDeclRefExpr. - Sema::ActOnBlockStart(), ActOnBlockError(), ActOnBlockStmtExpr(), ActOnBlockExprExpr(), ActOnBlockReturnStmt(). Next steps... - hack Sema::ActOnIdentifierExpr() to deal with block decl refs. - add attribute handler for byref decls. - add test cases. llvm-svn: 55710
* Pass SourceRanges by reference to the various Diag methods.Argyrios Kyrtzidis2008-08-241-7/+8
| | | | llvm-svn: 55284
* Make sure to create CXX record decls for the implicit Obj-C type ↵Anders Carlsson2008-08-231-14/+16
| | | | | | declarations. This lets us compile Cocoa.h as Objective-C++ llvm-svn: 55261
* make sure that ParseAST invokes the action for end of translation unit.Chris Lattner2008-08-231-0/+8
| | | | llvm-svn: 55222
* minor cleanup, remove finalize method.Chris Lattner2008-08-231-2/+0
| | | | llvm-svn: 55216
* Change Parser & Sema to use interned "super" for comparions.Daniel Dunbar2008-08-141-0/+2
| | | | | | | | | | | | | | - Added as private members for each because it is not clear where to put the common definition. Perhaps the IdentifierInfos all of these "pseudo-keywords" should be collected into one place (this would KnownFunctionIDs and Objective-C property IDs, for example). Remove Token::isNamedIdentifier. - There isn't a good reason to use strcmp when we have interned strings, and there isn't a good reason to encourage clients to do so. llvm-svn: 54794
* More #include cleaningDaniel Dunbar2008-08-111-1/+0
| | | | | | | | | | | - Kill unnecessary #includes in .cpp files. This is an automatic sweep so some things removed are actually used, but happen to be included by a previous header. I tried to get rid of the obvious examples and this was the easiest way to trim the #includes in one fell swoop. - We now return to regularly scheduled development. llvm-svn: 54632
* More #include cleaningDaniel Dunbar2008-08-111-0/+5
| | | | | | | | - Drop {Decl.h,DeclObjC.h,IdentifierTable.h} from Expr.h - Moved Sema::getCurMethodDecl() out of line (dependent on ObjCMethodDecl via dyn_cast). llvm-svn: 54629
* More #include cleaningDaniel Dunbar2008-08-111-0/+1
| | | | | | | | - Drop Expr.h,RecordLayout.h from ASTContext.h (for DeclBase.h and SourceLocation.h) - Move ASTContext constructor into implementation llvm-svn: 54627
* change more instances of QualType::getCanonicalType to callChris Lattner2008-07-261-1/+2
| | | | | | ASTContext::getCanonicalType instead (PR2189) llvm-svn: 54105
* Move isObjCObjectPointerType() from Sema to ASTContext.Ted Kremenek2008-07-241-21/+0
| | | | llvm-svn: 53998
* Switch initialization of the protocol list for an interface decl to useChris Lattner2008-07-211-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | the standard "set these as the list of protocols" interface instead of a strange "set this as the size and then set each one to the value" interface. The problem with the later is that it a) is completely different from everything else, b) is awkward, and c) doesn't handle the case when a referenced protocol is invalid: it set it to null. This meant that all clients downstream would have to handle null protocols in the protocol list, and empirically they didn't. Fix this by not setting invalid protocols in the referenced protocol list, fixing the crash on test/Sema/objc-interface-1.m While I'm at it, clean up some locations so that we produce: t.m:1:25: error: cannot find interface declaration for 'NSObject', superclass of 'NSWhatever' @interface NSWhatever : NSObject <NSCopying> ~~~~~~~~~~~~~~~~~~~~~ ^ instead of: t.m:1:1: error: cannot find interface declaration for 'NSObject', superclass of 'NSWhatever' @interface NSWhatever : NSObject <NSCopying> ^ llvm-svn: 53846
* improve comments yet again, now I know what this does :)Chris Lattner2008-07-211-1/+3
| | | | llvm-svn: 53821
OpenPOWER on IntegriCloud