summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* When using property-dot assignment syntax to call a setter method,Fariborz Jahanian2010-06-071-2/+13
| | | | | | | type of rhs need be compared to setter's argument and not the getter type. Fixes radar 8062778 llvm-svn: 105560
* Use MaybeCreateCXXExprWithTemporaries for potential destruction ofFariborz Jahanian2010-06-071-2/+3
| | | | | | | created temporary. Use own initialized entity for copied in block variables. llvm-svn: 105533
* Alter the interface of GetTypeForDeclarator to return a TypeSourceInfo*.John McCall2010-06-041-2/+2
| | | | | | This is never null, but the associated type might be. llvm-svn: 105503
* Build AST for copy-construction of copied-inFariborz Jahanian2010-06-041-2/+22
| | | | | | class object in blocks and carry it to IRGen. llvm-svn: 105487
* Preserve more information from a block's original function declarator, if oneJohn McCall2010-06-041-26/+58
| | | | | | | was given. Remove some unnecessary accounting from BlockScopeInfo. Handle typedef'ed function types until such time as we decide not. llvm-svn: 105478
* Restructure how we interpret block-literal declarators. Correctly handleJohn McCall2010-06-041-71/+63
| | | | | | | the case where we pick up block arguments from a typedef. Save the block signature as it was written, and preserve same through PCH. llvm-svn: 105466
* Remove a couple of unnecessary uses of IsStandardConversion.John McCall2010-06-041-17/+6
| | | | llvm-svn: 105445
* Fix unintentional method call due to false -> pointer conversion; patch by ↵Daniel Dunbar2010-06-021-1/+1
| | | | | | Dimitry Andric! llvm-svn: 105327
* In C++, one cannot assign from an arithmetic type to an enumerationDouglas Gregor2010-05-231-1/+2
| | | | | | type. Fixes PR7051. llvm-svn: 104475
* Complain about sizeof(overloaded function) rather than crashing.Douglas Gregor2010-05-231-0/+6
| | | | llvm-svn: 104470
* Provide the overloaded functions for UnresolvedLookupExpr andDouglas Gregor2010-05-231-4/+3
| | | | | | | UnresolvedMemberExpr in their constructors, rather than adding them after the fact. No functionality change. llvm-svn: 104468
* Improve our handling of reference binding for subobjects ofDouglas Gregor2010-05-221-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | temporaries. There are actually several interrelated fixes here: - When converting an object to a base class, it's only an lvalue cast when the original object was an lvalue and we aren't casting pointer-to-derived to pointer-to-base. Previously, we were misclassifying derived-to-base casts of class rvalues as lvalues, causing various oddities (including problems with reference binding not extending the lifetimes of some temporaries). - Teach the code for emitting a reference binding how to look through no-op casts and parentheses directly, since Expr::IgnoreParenNoOpCasts is just plain wrong for this. Also, make sure that we properly look through multiple levels of indirection from the temporary object, but destroy the actual temporary object; this fixes the reference-binding issue mentioned above. - Teach Objective-C message sends to bind the result as a temporary when needed. This is actually John's change, but it triggered the reference-binding problem above, so it's included here. Now John can actually test his return-slot improvements. llvm-svn: 104434
* Improve parser recovery when we encounter a dependent template nameDouglas Gregor2010-05-211-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | that is missing the 'template' keyword, e.g., t->getAs<T>() where getAs is a member of an unknown specialization. C++ requires that we treat "getAs" as a value, but that would fail to parse since T is the name of a type. We would then fail at the '>', since a type cannot be followed by a '>'. This is a very common error for C++ programmers to make, especially since GCC occasionally allows it when it shouldn't (as does Visual C++). So, when we are in this case, we use tentative parsing to see if the tokens starting at "<" can only be parsed as a template argument list. If so, we produce a diagnostic with a fix-it that states that the 'template' keyword is needed: test/SemaTemplate/dependent-template-recover.cpp:5:8: error: 'template' keyword is required to treat 'getAs' as a dependent template name t->getAs<T>(); ^ template This is just a start of this patch; I'd like to apply the same approach to everywhere that a template-id with dependent template name can be parsed. llvm-svn: 104406
* Introduce a method to get from an anonymous struct or union record declarationJohn McCall2010-05-211-30/+1
| | | | | | to the associated object declaration. llvm-svn: 104309
* Reinstate r104117, Chandler Carruth's change that "[provides] a namingDouglas Gregor2010-05-201-11/+6
| | | | | | | class for UnresolvedLookupExprs, even when occuring on template names" along with a fix for an Objective-C++ crasher it introduced. llvm-svn: 104277
* Renamed misleading getSourceRange -> getLocalSourceRange and ↵Abramo Bagnara2010-05-201-1/+1
| | | | | | getFullSourceRange -> getSourceRange for TypeLoc. llvm-svn: 104220
* Support implicitly closing on 'this' in a block. Fixed PR7165.John McCall2010-05-201-5/+8
| | | | | | (the codegen works here, too, but that's annoying to test without execution) llvm-svn: 104202
* Revert r104117, "Provide a naming class for UnresolvedLookupExprs, even whenDaniel Dunbar2010-05-191-6/+11
| | | | | | | occuring on..." which breaks some Objective-C code. Working on getting a test case... llvm-svn: 104150
* Provide a naming class for UnresolvedLookupExprs, even when occuring onChandler Carruth2010-05-191-11/+6
| | | | | | | | | | | template names. We were completely missing naming classes for many unqualified lookups, but this didn't trigger code paths that need it. This removes part of an optimization that re-uses the template name lookup done by the parser to determine if explicit template arguments actually form a template-id. Unfortunately the technique for avoiding the duplicate lookup lost needed data such as the class context in which the lookup succeeded. llvm-svn: 104117
* Implement C++ builtin operator candidates for vector types.Douglas Gregor2010-05-191-1/+7
| | | | llvm-svn: 104105
* Tweak typo-correction logic a bit regarding "super", so that weDouglas Gregor2010-05-181-3/+3
| | | | | | | | | consider "super" as a candidate whenever we're parsing an expression within an Objective-C method in an interface that has a superclass. At some point, we'd like to give "super" a little edge over non-local names; that will come later. llvm-svn: 104022
* Determine when the instantiation of a friend function defined inside aDouglas Gregor2010-05-171-1/+1
| | | | | | | class template conflicts with an existing (non-template) definition. This is another part of PR6952. llvm-svn: 103948
* PR7117: Make sure we don't lose the calling convention for K&R-styleEli Friedman2010-05-171-1/+2
| | | | | | | definitions. llvm-svn: 103932
* fix rdar://7985267 - Don't emit an error about a non-pod argumentChris Lattner2010-05-161-7/+13
| | | | | | passed to va_start, it doesn't actually pass it. llvm-svn: 103899
* Substantially alter the design of the Objective C type AST by introducingJohn McCall2010-05-151-17/+17
| | | | | | | | | | | | | | | | | | | | | ObjCObjectType, which is basically just a pair of one of {primitive-id, primitive-Class, user-defined @class} with a list of protocols. An ObjCObjectPointerType is therefore just a pointer which always points to one of these types (possibly sugared). ObjCInterfaceType is now just a kind of ObjCObjectType which happens to not carry any protocols. Alter a rather large number of use sites to use ObjCObjectType instead of ObjCInterfaceType. Store an ObjCInterfaceType as a pointer on the decl rather than hashing them in a FoldingSet. Remove some number of methods that are no longer used, at least after this patch. By simplifying ObjCObjectPointerType, we are now able to easily remove and apply pointers to Objective-C types, which is crucial for a certain kind of ObjC++ metaprogramming common in WebKit. llvm-svn: 103870
* Rework when and how vtables are emitted, by tracking where vtables areDouglas Gregor2010-05-131-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "used" (e.g., we will refer to the vtable in the generated code) and when they are defined (i.e., because we've seen the key function definition). Previously, we were effectively tracking "potential definitions" rather than uses, so we were a bit too eager about emitting vtables for classes without key functions. The new scheme: - For every use of a vtable, Sema calls MarkVTableUsed() to indicate the use. For example, this occurs when calling a virtual member function of the class, defining a constructor of that class type, dynamic_cast'ing from that type to a derived class, casting to/through a virtual base class, etc. - For every definition of a vtable, Sema calls MarkVTableUsed() to indicate the definition. This happens at the end of the translation unit for classes whose key function has been defined (so we can delay computation of the key function; see PR6564), and will also occur with explicit template instantiation definitions. - For every vtable defined/used, we mark all of the virtual member functions of that vtable as defined/used, unless we know that the key function is in another translation unit. This instantiates virtual member functions when needed. - At the end of the translation unit, Sema tells CodeGen (via the ASTConsumer) which vtables must be defined (CodeGen will define them) and which may be used (for which CodeGen will define the vtables lazily). From a language perspective, both the old and the new schemes are permissible: we're allowed to instantiate virtual member functions whenever we want per the standard. However, all other C++ compilers were more lazy than we were, and our eagerness was both a performance issue (we instantiated too much) and a portability problem (we broke Boost test cases, which now pass). Notes: (1) There's a ton of churn in the tests, because the order in which vtables get emitted to IR has changed. I've tried to isolate some of the larger tests from these issues. (2) Some diagnostics related to implicitly-instantiated/implicitly-defined virtual member functions have moved to the point of first use/definition. It's better this way. (3) I could use a review of the places where we MarkVTableUsed, to see if I missed any place where the language effectively requires a vtable. Fixes PR7114 and PR6564. llvm-svn: 103718
* When we encounter a non-dependent type during template instantiation,Douglas Gregor2010-05-071-0/+43
| | | | | | | mark any declarations we see inside of that type as "referenced". Fixes PR7079. llvm-svn: 103323
* A correct fix for bug 6466.Sebastian Redl2010-05-071-0/+3
| | | | llvm-svn: 103250
* Revert 103247, it causes lots of test failures.Sebastian Redl2010-05-071-1/+1
| | | | llvm-svn: 103248
* Pass the correct type to BuildMemberReferenceExpr. Fixes bug 6466.Sebastian Redl2010-05-071-1/+1
| | | | llvm-svn: 103247
* After some discussion, conservatively extend our sentinel check to discardJohn McCall2010-05-061-10/+13
| | | | | | casts, but still require the (casted) type to be a pointer. Fixes PR5685. llvm-svn: 103216
* Fixed DISABLE_SMART_POINTERS breakageDouglas Gregor2010-05-061-2/+2
| | | | llvm-svn: 103198
* Rework our handling of temporary objects within the conditions ofDouglas Gregor2010-05-061-0/+14
| | | | | | | | | | | | | | | | | | | if/switch/while/do/for statements. Previously, we would end up either: (1) Forgetting to destroy temporaries created in the condition (!), (2) Destroying the temporaries created in the condition *before* converting the condition to a boolean value (or, in the case of a switch statement, to an integral or enumeral value), or (3) In a for statement, destroying the condition's temporaries at the end of the increment expression (!). We now destroy temporaries in conditions at the right times. This required some tweaking of the Parse/Sema interaction, since the parser was building full expressions too early in many places. Fixes PR7067. llvm-svn: 103187
* Rearchitect -Wconversion and -Wsign-compare. Instead of computing themJohn McCall2010-05-061-4/+0
| | | | | | | | | | | | | | "bottom-up" when implicit casts and comparisons are inserted, compute them "top-down" when the full expression is finished. Makes it easier to coordinate warnings and thus implement -Wconversion for signedness conversions without double-warning with -Wsign-compare. Also makes it possible to realize that a signedness conversion is okay because the context is performing the inverse conversion. Also simplifies some logic that was trying to calculate the ultimate comparison/result type and getting it wrong. Also fixes a problem with the C++ explicit casts which are often "implemented" in the AST with a series of implicit cast expressions. llvm-svn: 103174
* When instantiating a function that was declared via a typedef, e.g.,Douglas Gregor2010-05-041-2/+2
| | | | | | | | | | | | | typedef int functype(int, int); functype func; also instantiate the synthesized function parameters for the resulting function declaration. With this change, Boost.Wave builds and passes all of its regression tests. llvm-svn: 103025
* Complete reimplementation of the synthesis for implicitly-defined copyDouglas Gregor2010-05-011-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | assignment operators. Previously, Sema provided type-checking and template instantiation for copy assignment operators, then CodeGen would synthesize the actual body of the copy constructor. Unfortunately, the two were not in sync, and CodeGen might pick a copy-assignment operator that is different from what Sema chose, leading to strange failures, e.g., link-time failures when CodeGen called a copy-assignment operator that was not instantiation, run-time failures when copy-assignment operators were overloaded for const/non-const references and the wrong one was picked, and run-time failures when by-value copy-assignment operators did not have their arguments properly copy-initialized. This implementation synthesizes the implicitly-defined copy assignment operator bodies in Sema, so that the resulting ASTs encode exactly what CodeGen needs to do; there is no longer any special code in CodeGen to synthesize copy-assignment operators. The synthesis of the body is relatively simple, and we generate one of three different kinds of copy statements for each base or member: - For a class subobject, call the appropriate copy-assignment operator, after overload resolution has determined what that is. - For an array of scalar types or an array of class types that have trivial copy assignment operators, construct a call to __builtin_memcpy. - For an array of class types with non-trivial copy assignment operators, synthesize a (possibly nested!) for loop whose inner statement calls the copy constructor. - For a scalar type, use built-in assignment. This patch fixes at least a few tests cases in Boost.Spirit that were failing because CodeGen picked the wrong copy-assignment operator (leading to link-time failures), and I suspect a number of undiagnosed problems will also go away with this change. Some of the diagnostics we had previously have gotten worse with this change, since we're going through generic code for our type-checking. I will improve this in a subsequent patch. llvm-svn: 102853
* Added an RAII object that helps set up/tear down the Sema contextDouglas Gregor2010-05-011-1/+1
| | | | | | | | | | | information required to implicitly define a C++ special member function. Use it rather than explicitly setting CurContext on entry and exit, which is fragile. Use this RAII object for the implicitly-defined default constructor, copy constructor, copy assignment operator, and destructor. llvm-svn: 102840
* It turns out that basically every caller to RequireCompleteDeclContextJohn McCall2010-05-011-2/+2
| | | | | | | already knows what context it's looking in. Just pass that context in instead of (questionably) recalculating it. llvm-svn: 102818
* Teach __builtin_offsetof to compute the offsets of members of baseDouglas Gregor2010-04-291-0/+14
| | | | | | | | classes, since we only warn (not error) on offsetof() for non-POD types. We store the base path within the OffsetOfExpr itself, then evaluate the offsets within the constant evaluator. llvm-svn: 102571
* Ensure that cv-qualifiers are correctly removed for post-inc/decrementsAlexis Hunt2010-04-281-19/+25
| | | | | | | as well as pre- and post-inc/decrements in C (not that I think it matters for any C code). llvm-svn: 102552
* Diagnose __builtin_offsetof expressions that refer to bit-fieldsDouglas Gregor2010-04-281-3/+25
| | | | llvm-svn: 102548
* Completely reimplement __builtin_offsetof, based on a patch by RobertoDouglas Gregor2010-04-281-32/+173
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Amadini. This change introduces a new expression node type, OffsetOfExpr, that describes __builtin_offsetof. Previously, __builtin_offsetof was implemented using a unary operator whose subexpression involved various synthesized array-subscript and member-reference expressions, which was ugly and made it very hard to instantiate as a template. OffsetOfExpr represents the AST more faithfully, with proper type source information and a more compact representation. OffsetOfExpr also has support for dependent __builtin_offsetof expressions; it can be value-dependent, but will never be type-dependent (like sizeof or alignof). This commit introduces template instantiation for __builtin_offsetof as well. There are two major caveats to this patch: 1) CodeGen cannot handle the case where __builtin_offsetof is not a constant expression, so it produces an error. So, to avoid regressing in C, we retain the old UnaryOperator-based __builtin_offsetof implementation in C while using the shiny new OffsetOfExpr implementation in C++. The old implementation can go away once we have proper CodeGen support for this case, which we expect won't cause much trouble in C++. 2) __builtin_offsetof doesn't work well with non-POD class types, particularly when the designated field is found within a base class. I will address this in a subsequent patch. Fixes PR5880 and a bunch of assertions when building Boost.Python tests. llvm-svn: 102542
* When the qualifier of a id-expression is non-dependent but notDouglas Gregor2010-04-281-3/+4
| | | | | | | | | complete, return an error rather than falling back to building a dependent declaration reference, since we might not be in a dependent context. Fixes a fiendish crash-on-invalid in Boost.FunctionTypes that I wasn't able to reduce to anything useful. llvm-svn: 102491
* It's okay to refer to non-type template parameters anywhere they areDouglas Gregor2010-04-271-1/+4
| | | | | | visible. Fixes the remaining two failures in Boost.ScopeExit. llvm-svn: 102466
* During template instantiation, set the naming class ofDouglas Gregor2010-04-271-0/+24
| | | | | | | | | | | | | | | | | | | UnresolvedLookupExpr and UnresolvedMemberExpr by substituting the naming class we computed when building the expression in the template... ... which we didn't always do correctly. Teach UnresolvedMemberExpr::getNamingClass() all about the new representation of injected-class-names in templates, so that it can return a naming class that is the current instantiation. Also, when decomposing a template-id into its template name and its arguments, be sure to set the naming class on the LookupResult structure. Fixes PR6947 the right way. llvm-svn: 102448
* Improve the diagnostic you get when making a qualified member accessJohn McCall2010-04-271-5/+2
| | | | | | with a qualifier referencing a different type. llvm-svn: 102409
* When name lookup finds a single declaration that was imported via aDouglas Gregor2010-04-251-1/+3
| | | | | | | | using declaration, look at its underlying declaration to determine the lookup result kind (e.g., overloaded, unresolved). Fixes at least one issue in Boost.Bimap. llvm-svn: 102317
* Improve the diagnostic when we find something we did not expect in aDouglas Gregor2010-04-251-9/+10
| | | | | | | member expression (p-> or x.), by showing the type we looked into and what we did actually find. llvm-svn: 102315
* Add base paths to CK_UncheckedDerivedToBase and CK_DerivedToBaseMemberPointer.Anders Carlsson2010-04-241-9/+10
| | | | llvm-svn: 102260
* Actually produce base paths for CastExprs of kind CK_DerivedToBase.Anders Carlsson2010-04-241-3/+4
| | | | llvm-svn: 102259
OpenPOWER on IntegriCloud