summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Introduce Decl::hasBody() and FunctionDecl::hasBody() and use them instead ↵Argyrios Kyrtzidis2010-07-071-1/+1
| | | | | | | | of getBody() when we are just checking the existence of a body, to avoid de-serialization of the body from PCH. Makes de-serialization of the function body even more "lazier". llvm-svn: 107768
* implement PR7569, warning about assignment to null, which Chris Lattner2010-07-071-0/+17
| | | | | | | | people seem to write when they want a deterministic trap. Suggest instead that they use a volatile pointer or __builtin_trap. llvm-svn: 107756
* Fix multiple emission of the this-> fixit for each instantiation by fixing theNick Lewycky2010-07-061-5/+23
| | | | | | AST during the instantiation. Fixes PR7417! llvm-svn: 107690
* fix a bug I introduced in r107624Chris Lattner2010-07-051-5/+2
| | | | llvm-svn: 107626
* rearrange some logic, no functionality change.Chris Lattner2010-07-051-19/+30
| | | | llvm-svn: 107624
* Fix vector literal/cast confusion - bug 6895.John Thompson2010-06-301-2/+13
| | | | llvm-svn: 107347
* Fix rdar://8139785 "implement warning on dead expression in comma operator"Argyrios Kyrtzidis2010-06-301-0/+2
| | | | | | | | | | As a bonus, fix the warning for || and && operators; it was emitted even if one of the operands had side effects, e.g: x || test_logical_foo1(); emitted a bogus "expression result unused" for 'x'. llvm-svn: 107274
* When typo correction produces a result that is not of the kind we'reDouglas Gregor2010-06-291-0/+4
| | | | | | | looking for, reset the name within the LookupResult structure in addition to clearing out the results. Fixes PR7508. llvm-svn: 107197
* Vector types are not arithmetic types, either. Note that we now banDouglas Gregor2010-06-221-2/+3
| | | | | | | | | __real myvec and __imag myvec, since they aren't all that useful (it's just an identity function) but we might want to use them in more restricted cases in the future (e.g., "__real mycomplexvec" could extract the real parts of a vector of complex numbers). llvm-svn: 106601
* Change Type::isFloatingType() to reflect the actual definition of aDouglas Gregor2010-06-221-6/+6
| | | | | | | | | | | "floating type" in C, which does not include vector types. Introduce Type::hasFloatingRepresentation() for the places where we want to know whether the underlying representation is one or more floating-point values. Remove some hacks we had where the former behavior of Type::isFloatingType() was at odds with the language definition of the term. llvm-svn: 106584
* Zero out a stale pointerDouglas Gregor2010-06-211-0/+1
| | | | llvm-svn: 106497
* Given Decl::isUsed() a flag indicating when to consider the "used"Douglas Gregor2010-06-171-5/+5
| | | | | | | | | attribute as part of the calculation. Sema::MarkDeclReferenced(), and a few other places, want only to consider the "used" bit to determine, e.g, whether to perform template instantiation. Fixes a linkage issue with Boost.Serialization. llvm-svn: 106252
* Do not treat @selector as lvalue (unlike g++).Fariborz Jahanian2010-06-171-0/+2
| | | | | | Patch by Nico Weber (pr7390). llvm-svn: 106242
* Fix a point of semantics with using declaration hiding: method templatesJohn McCall2010-06-161-60/+30
| | | | | | | | | | | | | | | | | introduced by using decls are hidden even if their template parameter lists or return types differ from the "overriding" declaration. Propagate using shadow declarations around more effectively when looking up template-ids. Reperform lookup for template-ids in member expressions so that access control is properly set up. Fix some number of latent bugs involving template-ids with totally invalid base types. You can only actually get these with a scope specifier, since otherwise the template-id won't parse as a template-id. Fixes PR7384. llvm-svn: 106093
* Give Type::isIntegralType() an ASTContext parameter, so that itDouglas Gregor2010-06-161-3/+3
| | | | | | | | | | | | provides C "integer type" semantics in C and C++ "integral type" semantics in C++. Note that I still need to update isIntegerType (and possibly other predicates) using the same approach I've taken for isIntegralType(). The two should have the same meaning, but currently don't (!). llvm-svn: 106074
* Introduce Type::isIntegralOrEnumerationType(), to cover those placesDouglas Gregor2010-06-161-1/+2
| | | | | | | | | | in C++ that involve both integral and enumeration types. Convert all of the callers to Type::isIntegralType() that are meant to work with both integral and enumeration types over to Type::isIntegralOrEnumerationType(), to prepare to eliminate enumeration types as integral types. llvm-svn: 106071
* Update equality and relationship comparisons of pointers to reflectDouglas Gregor2010-06-151-26/+30
| | | | | | | | | C++ semantics, eliminating an extension diagnostic that doesn't match C++ semantics (ordered comparison with NULL) and tightening some extwarns to errors in C++ to match GCC and maintain conformance in SFINAE contexts. Fixes <rdar://problem/7941392>. llvm-svn: 106050
* tidy upChris Lattner2010-06-151-1/+1
| | | | llvm-svn: 106011
* Another chunk of the new RecursiveASTVisitor implementation: switch the returnChandler Carruth2010-06-101-1/+1
| | | | | | | value semantics such that we recurse while the visitors return true, and halt as soon as one returns false. Patch by csilvers. llvm-svn: 105787
* Major redesign of the RecursiveASTVisitor. This implements the majority of theChandler Carruth2010-06-091-14/+15
| | | | | | | | | | new design discussed on cfe-dev, with further steps in that direction to come. It is already much more complete than the previous visitor. Patch by Zhanyong and Craig with 80 column wraps and one missing declaration added by me. llvm-svn: 105709
* Warn about comparisons between arrays and improve self-comparisonDouglas Gregor2010-06-081-11/+45
| | | | | | warnings, from Troy Straszheim! Fixes PR6163. llvm-svn: 105631
* Fixes a typo which prevented proper code gen. forFariborz Jahanian2010-06-081-2/+1
| | | | | | copy-in of c++ class objects into blocks. llvm-svn: 105622
* 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
OpenPOWER on IntegriCloud