summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
* move the Diag method for Sema to be inline. This shrinks the release-assertsChris Lattner2008-11-222-8/+11
| | | | | | | | | 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-222-2/+2
| | | | | | | | | | 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
* Implementation of new and delete parsing and sema.Sebastian Redl2008-11-213-8/+227
| | | | | | This version uses VLAs to represent arrays. I'll try an alternative way next, but I want this safe first. llvm-svn: 59835
* merge some simple call diagnostics.Chris Lattner2008-11-213-23/+19
| | | | llvm-svn: 59831
* print a type in a diagnostic.Chris Lattner2008-11-211-2/+2
| | | | llvm-svn: 59829
* Allow redeclaration of typedefs in C++Douglas Gregor2008-11-211-1/+8
| | | | llvm-svn: 59822
* Fix overloading of non-static member functions that differ in their ↵Douglas Gregor2008-11-211-1/+1
| | | | | | cv-qualifiers llvm-svn: 59819
* merge 3 more diagnostics into 1.Chris Lattner2008-11-211-5/+6
| | | | llvm-svn: 59805
* Add the concept of "modifiers" to the clang diagnostic format Chris Lattner2008-11-211-23/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | strings. This allows us to have considerable flexibility in how these things are displayed and provides extra information that allows us to merge away diagnostics that are very similar. Diagnostic modifiers are a string of characters with the regex [-a-z]+ that occur between the % and digit. They may optionally have an argument that can parameterize them. For now, I've added two example modifiers. One is a very useful tool that allows you to factor commonality across diagnostics that need single words or phrases combined. Basically you can use %select{a|b|c}4 with with an integer argument that selects either a/b/c based on an integer value in the range [0..3). The second modifier is also an integer modifier, aimed to help English diagnostics handle plurality. "%s3" prints to 's' if integer argument #3 is not 1, otherwise it prints to nothing. I'm fully aware that 's' is an English concept and doesn't apply to all situations (mouse vs mice). However, this is very useful and we can add other crazy modifiers once we add support for polish! ;-) I converted a couple C++ diagnostics over to use this as an example, I'd appreciate it if others could merge the other likely candiates. If you have other modifiers that you want, lets talk on cfe-dev. llvm-svn: 59803
* Change CheckIncrementDecrementOperand to test for common cases firstChris Lattner2008-11-211-21/+24
| | | | | | and fall through better. llvm-svn: 59799
* Cleanup memory management in overloading of operator->, slightlyDouglas Gregor2008-11-211-8/+9
| | | | llvm-svn: 59791
* Don't print canonical types in overloading-related diagnosticsDouglas Gregor2008-11-212-7/+27
| | | | llvm-svn: 59789
* __weak ivar need not warn.Fariborz Jahanian2008-11-201-1/+1
| | | | llvm-svn: 59743
* Add support for overloaded operator-> when used in a member accessDouglas Gregor2008-11-203-0/+86
| | | | | | expression (smart_ptr->mem). llvm-svn: 59732
* Fix strange quote charactersDouglas Gregor2008-11-201-4/+4
| | | | llvm-svn: 59729
* Daniel really really likes = instead of += :)Chris Lattner2008-11-201-1/+1
| | | | llvm-svn: 59716
* remove the last old-fashioned Diag method. Transition complete!Chris Lattner2008-11-209-89/+79
| | | | llvm-svn: 59714
* remove another old Diag method.Chris Lattner2008-11-205-52/+43
| | | | llvm-svn: 59713
* remove another old-school Diag method.Chris Lattner2008-11-2011-125/+109
| | | | llvm-svn: 59712
* remove the type_info identifier cache. Compared to the costChris Lattner2008-11-203-17/+7
| | | | | | | | | | | 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-203-3/+2
| | | | | | | 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-203-15/+15
| | | | | | used in one cold place. llvm-svn: 59709
* instead of looking up super at startup time, Chris Lattner2008-11-204-7/+2
| | | | | | | just check for it when needed. It doesn't incur real cost in any hot paths. llvm-svn: 59708
* Rename IdentifierInfo::isName to ::isStr. Use a nifty trickChris Lattner2008-11-201-3/+3
| | | | | | | from Sebastian to enforce that a literal string is passed in, and use this to avoid having to call strlen on it. llvm-svn: 59706
* More objc gc stuff. Read/Write barriers for local static/extern,Fariborz Jahanian2008-11-201-1/+4
| | | | | | | diagnostics on use of __weak attribute on fields, Early support for read/write barriers for objc fields. llvm-svn: 59682
* Implement the rest of C++ [over.call.object], which permits the objectDouglas Gregor2008-11-193-10/+170
| | | | | | | | | | being called to be converted to a reference-to-function, pointer-to-function, or reference-to-pointer-to-function. This is done through "surrogate" candidate functions that model the conversions from the object to the function (reference/pointer) and the conversions in the arguments. llvm-svn: 59674
* Support for calling overloaded function call operators (operator())Douglas Gregor2008-11-193-1/+160
| | | | | | | | | | | | | | with function call syntax, e.g., Functor f; f(x, y); This is the easy part of handling calls to objects of class type (C++ [over.call.object]). The hard part (coping with conversions from f to function pointer or reference types) will come later. Nobody uses that stuff anyway, right? :) llvm-svn: 59663
* Some tweaks suggested by ArgirisDouglas Gregor2008-11-192-24/+23
| | | | llvm-svn: 59661
* Take care another assert:Argyrios Kyrtzidis2008-11-191-3/+3
| | | | | | | | | | | | | | | | | | | | struct A { struct B; }; struct A::B { void m() {} // Assertion failed: getContainingDC(DC) == CurContext && "The next DeclContext should be lexically contained in the current one." }; Introduce DeclContext::getLexicalParent which may be different from DeclContext::getParent when nested-names are involved, e.g: namespace A { struct S; } struct A::S {}; // getParent() == namespace 'A' // getLexicalParent() == translation unit llvm-svn: 59650
* Support overloading of the subscript operator[], including support forDouglas Gregor2008-11-192-4/+87
| | | | | | | | | built-in operator candidates. Test overloading of '&' and ','. In C++, a comma expression is an lvalue if its right-hand subexpression is an lvalue. Update Expr::isLvalue accordingly. llvm-svn: 59643
* Fix <rdar://problem/6150376> [sema] crash on invalid message send.Steve Naroff2008-11-192-18/+35
| | | | | | The core fix in Sema::ActOnClassMessage(). All the other changes have to do with passing down the SourceLocation for the receiver (to properly position the cursor when producing an error diagnostic). llvm-svn: 59639
* Added operator overloading for unary operators, post-increment, andDouglas Gregor2008-11-193-59/+414
| | | | | | | | | | | | | post-decrement, including support for generating all of the built-in operator candidates for these operators. C++ and C have different rules for the arguments to the builtin unary '+' and '-'. Implemented both variants in Sema::ActOnUnaryOp. In C++, pre-increment and pre-decrement return lvalues. Update Expr::isLvalue accordingly. llvm-svn: 59638
* Fix silly code, use IdentifierInfo* instead of std::string inDaniel Dunbar2008-11-192-7/+6
| | | | | | PragmaPackStack. Thanks Chris! llvm-svn: 59616
* stop calling II::getName() unnecesarily in semaChris Lattner2008-11-1910-167/+146
| | | | llvm-svn: 59609
* Allow sending IdentifierInfo*'s into Diagnostics without turning them into ↵Chris Lattner2008-11-191-1/+1
| | | | | | | | strings first. This should allow removal of a bunch of II->getName() calls. llvm-svn: 59601
* convert some diags to use numbers instead of strings.Chris Lattner2008-11-192-8/+2
| | | | llvm-svn: 59600
* add direct support for signed and unsigned integer arguments to diagnostics.Chris Lattner2008-11-191-1/+1
| | | | llvm-svn: 59598
* remove one more old-style Diag method.Chris Lattner2008-11-1911-145/+134
| | | | llvm-svn: 59589
* Switch several more Sema Diag methods over. This simplifies theChris Lattner2008-11-1911-534/+430
| | | | | | | | __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
* Built-in equality and relational operators have return type "bool" in C++,Douglas Gregor2008-11-192-25/+66
| | | | | | | | | | | | | | | | not "int". Fix a typo in the promotion of enumeration types that was causing some integral promotions to look like integral conversions (leading to extra ambiguities in overload resolution). Check for "acceptable" overloaded operators based on the types of the arguments. This is a somewhat odd check that is specified by the standard, but I can't see why it actually matters: the overload candidates it suppresses don't seem like they would ever be picked as the best candidates. llvm-svn: 59583
* Partial expansion of C++ operator overloading (for binary operators)Douglas Gregor2008-11-183-32/+299
| | | | | | | | | | | | | | | | | | | | | | | | to support operators defined as member functions, e.g., struct X { bool operator==(X&); }; Overloading with non-member operators is supported, and the special rules for the implicit object parameter (e.g., the ability for a non-const *this to bind to an rvalue) are implemented. This change also refactors and generalizes the code for adding overload candidates for overloaded operator calls (C++ [over.match.expr]), both to match the rules more exactly (name lookup of non-member operators actually ignores member operators) and to make this routine more reusable for the other overloaded operators. Testing for the initialization of the implicit object parameter is very light. More tests will come when we get support for calling member functions directly (e.g., o.m(a1, a2)). llvm-svn: 59564
* start converting Sema over to using its canonical Diag method.Chris Lattner2008-11-189-164/+137
| | | | llvm-svn: 59561
* introduce the one true Diag method for Sema. Next up: kill all the others off.Chris Lattner2008-11-182-6/+5
| | | | llvm-svn: 59556
* Fix <rdar://problem/6329769> [sema] crash on duplication definition of ↵Steve Naroff2008-11-181-3/+6
| | | | | | | | | | interface with protocols. As soon as we detect duplicate interfaces, discontinue further semantic checks (returning the original interface). This is now consistent with how we handle protocols (and less error prone in general). llvm-svn: 59541
* As threatened previously: consolidate name lookup and the creation ofDouglas Gregor2008-11-183-80/+46
| | | | | | | | | | | | | | DeclRefExprs and BlockDeclRefExprs into a single function Sema::ActOnDeclarationNameExpr, eliminating a bunch of duplicate lookup-name-and-check-the-result code. Note that we still have the three parser entry points for identifiers, operator-function-ids, and conversion-function-ids, since the parser doesn't (and shouldn't) know about DeclarationNames. This is a Good Thing (TM), and there will be more entrypoints coming (e.g., for C++ pseudo-destructor expressions). llvm-svn: 59527
* Extend DeclarationName to support C++ overloaded operators, e.g.,Douglas Gregor2008-11-184-1/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | operator+, directly, using the same mechanism as all other special names. Removed the "special" identifiers for the overloaded operators from the identifier table and IdentifierInfo data structure. IdentifierInfo is back to representing only real identifiers. Added a new Action, ActOnOperatorFunctionIdExpr, that builds an expression from an parsed operator-function-id (e.g., "operator +"). ActOnIdentifierExpr used to do this job, but operator-function-ids are no longer represented by IdentifierInfo's. Extended Declarator to store overloaded operator names. Sema::GetNameForDeclarator now knows how to turn the operator name into a DeclarationName for the overloaded operator. Except for (perhaps) consolidating the functionality of ActOnIdentifier, ActOnOperatorFunctionIdExpr, and ActOnConversionFunctionExpr into a common routine that builds an appropriate DeclRefExpr by looking up a DeclarationName, all of the work on normalizing declaration names should be complete with this commit. llvm-svn: 59526
* 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
* Attribute nonnull can be applied to block pointers.Ted Kremenek2008-11-181-3/+6
| | | | llvm-svn: 59499
* 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
* minor cleanups and tidying, no functionality change.Chris Lattner2008-11-182-69/+71
| | | | llvm-svn: 59485
OpenPOWER on IntegriCloud