summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Patch for ObjCIvarRefExpr containing the fieldFariborz Jahanian2008-12-131-3/+6
| | | | | | matching the storage layout for this ivar llvm-svn: 60996
* fix rdar://6097892 - gcc incompat: clang rejects __func__, __FUNCTION__, and ↵Chris Lattner2008-12-121-6/+8
| | | | | | | | __PRETTY_FUNCTION__ outside func Yeah, this is "useful". llvm-svn: 60921
* Unifies the name-lookup mechanisms used in various parts of the ASTDouglas Gregor2008-12-111-10/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Make sure to promote expressions of the form (floating point + complex ↵Anders Carlsson2008-12-101-2/+10
| | | | | | integer) correctly, to (complex floating point + complex floating point) llvm-svn: 60862
* Added a warning when referencing an if's condition variable in theDouglas Gregor2008-12-101-0/+21
| | | | | | | | | | | | | | | "else" clause, e.g., if (int X = foo()) { } else { if (X) { // warning: X is always zero in this context } } Fixes rdar://6425550 and lets me think about something other than DeclContext. llvm-svn: 60858
* Fix PR clang/3175: CheckAddressOfOperand does not handle references to class ↵Douglas Gregor2008-12-101-1/+4
| | | | | | vars llvm-svn: 60849
* Some cleanups to the dependent-types commit, as suggested by SebastianDouglas Gregor2008-12-101-37/+37
| | | | llvm-svn: 60848
* Patch to allow a getter call using property dot-syntax notation.Fariborz Jahanian2008-12-101-1/+8
| | | | llvm-svn: 60816
* Add support for calls to dependent names within templates, e.g.,Douglas Gregor2008-12-061-5/+51
| | | | | | | | | | | | | | | | | | template<typename T> void f(T x) { g(x); // g is a dependent name, so don't even bother to look it up g(); // error: g is not a dependent name } Note that when we see "g(", we build a CXXDependentNameExpr. However, if none of the call arguments are type-dependent, we will force the resolution of the name "g" and replace the CXXDependentNameExpr with its result. GCC actually produces a nice error message when you make this mistake, and even offers to compile your code with -fpermissive. I'll do the former next, but I don't plan to do the latter. llvm-svn: 60618
* Introduce basic support for dependent types, type-dependentDouglas Gregor2008-12-051-5/+73
| | | | | | | | | | | | expressions, and value-dependent expressions. This permits us to parse some template definitions. This is not a complete solution; we're missing type- and value-dependent computations for most of the expression types, and we're missing checks for dependent types and type-dependent expressions throughout Sema. llvm-svn: 60615
* change getCurFunctionDecl to skip through Block contexts to findChris Lattner2008-12-041-4/+4
| | | | | | | | 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
* Fix typo in index operator overloading.Sebastian Redl2008-12-031-1/+1
| | | | llvm-svn: 60483
* Revert change that made isNullPointerConstant start emitting warnings. We ↵Anders Carlsson2008-12-011-22/+2
| | | | | | don't want that :) llvm-svn: 60333
* Add Sema::isNullPointerConstant which extwarns if necessary. Use it in ↵Anders Carlsson2008-12-011-2/+22
| | | | | | Sema::CheckConditionalOperands. llvm-svn: 60319
* Add Sema::VerifyIntegerConstantExpressionAnders Carlsson2008-11-301-0/+33
| | | | llvm-svn: 60305
* Implement the GNU __null extensionDouglas Gregor2008-11-291-0/+12
| | | | llvm-svn: 60235
* Don't complain about block pointer to void* conversionsDouglas Gregor2008-11-271-6/+3
| | | | llvm-svn: 60138
* Fix a minor typo in the handling of the conditional operator for Objective-C ↵Douglas Gregor2008-11-261-1/+1
| | | | | | interface pointers llvm-svn: 60096
* Tweak the new ResolveOverloadedCallFn to just return a FunctionDecl. It ↵Douglas Gregor2008-11-261-4/+8
| | | | | | makes ActOnCallExpr simpler llvm-svn: 60094
* Move the overloading logic of Sema::ActOnCallExpr to a separate functionDouglas Gregor2008-11-261-30/+4
| | | | llvm-svn: 60093
* Change a whole lot of diagnostics to take QualType's directly Chris Lattner2008-11-241-57/+43
| | | | | | | | instead of converting them to strings first. This also fixes a bunch of minor inconsistencies in the diagnostics emitted by clang and adds a bunch of FIXME's to DiagnosticKinds.def. llvm-svn: 59948
* Rename NamedDecl::getName() to getNameAsString(). Replace a bunch of Chris Lattner2008-11-241-17/+17
| | | | | | | | | | | 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
* Convert IdentifierInfo's to be printed the same as DeclarationNames Chris Lattner2008-11-231-2/+2
| | | | | | | | | | | | | | | | | | | | | with implicit quotes around them. This has a bunch of follow-on effects and requires tweaking to a whole lot of code. This causes a regression in two tests (xfailed) by causing it to emit things like: Line 10: duplicate interface declaration for category 'MyClass1' ('Category1') instead of: Line 10: duplicate interface declaration for category 'MyClass1(Category1)' I will fix this in a follow-up commit. As part of this, I had to start switching stuff to use ->getDeclName() instead of Decl::getName() for consistency. This is good, but I was planning to do this as an independent patch. There will be several follow-on patches to clean up some of the mess, but this patch is already too big. llvm-svn: 59917
* Add support for sending QualType's directly into diags and convert twoChris Lattner2008-11-231-12/+11
| | | | | | | | | | 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
* Support for implicit property assignment. Error assigning toFariborz Jahanian2008-11-221-3/+41
| | | | | | 'implicit' property with no 'setter'. llvm-svn: 59878
* New AST node to access "implicit" setter/getter using property dor syntax.Fariborz Jahanian2008-11-221-35/+7
| | | | | | | Issuing diagnostics when assigning to read-only properties. This is work in progress. llvm-svn: 59874
* Implement a %plural modifier for complex plural forms in diagnostics. Use it ↵Sebastian Redl2008-11-221-10/+5
| | | | | | in the overload diagnostics. llvm-svn: 59871
* merge some simple call diagnostics.Chris Lattner2008-11-211-15/+9
| | | | llvm-svn: 59831
* print a type in a diagnostic.Chris Lattner2008-11-211-2/+2
| | | | llvm-svn: 59829
* Change CheckIncrementDecrementOperand to test for common cases firstChris Lattner2008-11-211-21/+24
| | | | | | and fall through better. llvm-svn: 59799
* Add support for overloaded operator-> when used in a member accessDouglas Gregor2008-11-201-0/+2
| | | | | | expression (smart_ptr->mem). llvm-svn: 59732
* 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-201-2/+2
| | | | llvm-svn: 59714
* remove another old-school Diag method.Chris Lattner2008-11-201-31/+30
| | | | llvm-svn: 59712
* instead of looking up super at startup time, Chris Lattner2008-11-201-1/+1
| | | | | | | just check for it when needed. It doesn't incur real cost in any hot paths. llvm-svn: 59708
* Support for calling overloaded function call operators (operator())Douglas Gregor2008-11-191-1/+5
| | | | | | | | | | | | | | 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
* Support overloading of the subscript operator[], including support forDouglas Gregor2008-11-191-2/+84
| | | | | | | | | 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
* Added operator overloading for unary operators, post-increment, andDouglas Gregor2008-11-191-20/+199
| | | | | | | | | | | | | 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
* stop calling II::getName() unnecesarily in semaChris Lattner2008-11-191-15/+9
| | | | llvm-svn: 59609
* remove one more old-style Diag method.Chris Lattner2008-11-191-33/+33
| | | | llvm-svn: 59589
* Switch several more Sema Diag methods over. This simplifies theChris Lattner2008-11-191-108/+98
| | | | | | | | __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-191-13/+16
| | | | | | | | | | | | | | | | 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-181-19/+16
| | | | | | | | | | | | | | | | | | | | | | | | 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-181-44/+44
| | | | llvm-svn: 59561
* As threatened previously: consolidate name lookup and the creation ofDouglas Gregor2008-11-181-12/+37
| | | | | | | | | | | | | | 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-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* minor cleanups and tidying, no functionality change.Chris Lattner2008-11-181-68/+70
| | | | llvm-svn: 59485
* implement a fixme by making warnings for ++/-- on non-modifiable-lvalues better.Chris Lattner2008-11-181-7/+2
| | | | llvm-svn: 59484
* factor some code out into a helper functionChris Lattner2008-11-181-34/+48
| | | | llvm-svn: 59483
* Implement effects of 'mutable', and a few comments from Chris on its parsing.Sebastian Redl2008-11-171-0/+4
| | | | llvm-svn: 59470
OpenPOWER on IntegriCloud