summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix two bugs with temporaries:Anders Carlsson2009-11-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | 1. For A f() { return A(); } we were incorrectly calling the A destructor on the returned object. 2. For void f(A); void g() { A a; f(a); } we were incorrectly not calling the copy constructor. llvm-svn: 87082
* Note to self: don't leave debugging statements in the code for four hours.John McCall2009-11-121-2/+0
| | | | llvm-svn: 86931
* Add <foo> = [<bar> nextObject] to the -Widiomatic-parentheses category,John McCall2009-11-121-8/+17
| | | | | | | and give that category an explicit test. Generalize the internal diagnostic name. llvm-svn: 86905
* Preserve source locations when building offsetof expressions featuringJohn McCall2009-11-111-1/+1
| | | | | | anonymous members. Partial fix for PR 5390. llvm-svn: 86796
* Apparently the following idiom is specifically encouraged:John McCall2009-11-111-1/+12
| | | | | | | if (self = [super init]) Recognize it and only warn if -Wparentheses is explicitly enabled. llvm-svn: 86790
* Improve parsing of template arguments to lay the foundation forDouglas Gregor2009-11-101-4/+1
| | | | | | | | | | | | | | | | | | | | | | handling template template parameters properly. This refactoring: - Parses template template arguments as id-expressions, representing the result of the parse as a template name (Action::TemplateTy) rather than as an expression (lame!). - Represents all parsed template arguments via a new parser-specific type, ParsedTemplateArgument, which stores the kind of template argument (type, non-type, template) along with all of the source information about the template argument. This replaces an ad hoc set of 3 vectors (one for a void*, which was either a type or an expression; one for a bit telling whether the first was a type or an expression; and one for a single source location pointing at the template argument). - Moves TemplateIdAnnotation into the new Parse/Template.h. It never belonged in the Basic library anyway. llvm-svn: 86708
* When trying to assign a regular string literal to an Objective-C 'id' type ↵Anders Carlsson2009-11-101-1/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | or a pointer to an NSString, emit a code insertion hint that turns it into an Objective-C string. For example: @class NSString; @interface Test + (void)test:(NSString *)string; @end void g(NSString *a); void f() { NSString *a = "Foo"; g("Foo"); [Test test:"Foo"]; } will produce t.m:10:17: warning: incompatible pointer types initializing 'char [4]', expected 'NSString *' NSString *a = "Foo"; ^~~~~ @ t.m:11:5: warning: incompatible pointer types passing 'char [4]', expected 'NSString *' g("Foo"); ^~~~~ @ t.m:12:14: warning: incompatible pointer types sending 'char [4]', expected 'NSString *' [Test test:"Foo"]; ^~~~~ @ 3 diagnostics generated. llvm-svn: 86665
* Changed error for nested type qualifier mismatch toFariborz Jahanian2009-11-091-1/+1
| | | | | | | warning, to match gcc. It used to be warning, so better keep it a warning (it broke a certain project). llvm-svn: 86597
* Test commit - minor terminology change to my recent patch suggested by John ↵Alexis Hunt2009-11-081-3/+3
| | | | | | McCall llvm-svn: 86442
* Patch to gives an error that at least points users in the direction of the ↵Fariborz Jahanian2009-11-071-0/+21
| | | | | | | | error, rather than an error about incompatible types. Patch by Sean Hunt. llvm-svn: 86402
* Don't warn -Wsign-compare if we're in an unevaluated context, and fixedJohn McCall2009-11-061-0/+4
| | | | | | a typo pointed out by Fariborz. llvm-svn: 86265
* compare.c also needs a target triple now, and improve some comments while we'reJohn McCall2009-11-061-7/+7
| | | | | | at it. llvm-svn: 86243
* Improve the -Wsign-compare heuristics:John McCall2009-11-061-4/+35
| | | | | | | | | | | | | * If the unsigned type is smaller than the signed type, never warn, because its value will not change when zero-extended to the larger type. * If we're testing for (in)equality, and the unsigned value is an integer constant whose sign bit is not set, never warn, because even though the signed value might change, it can't affect the result of the equality. Also make the comparison test cases much more rigorous, and have them expose the subtle differences between C and C++ here. llvm-svn: 86242
* Rework the fix-it hint for code likeDouglas Gregor2009-11-061-12/+32
| | | | | | | | | | | get_origin->x where get_origin is actually a function and the user has forgotten the parentheses. Instead of giving a lame note for the fix-it, give a full-fledge error, early, then build the call expression to try to recover. llvm-svn: 86238
* The signed/unsigned checker should not warn for value-dependent expressions, ↵Sebastian Redl2009-11-051-0/+5
| | | | | | and should especially not try to evaluate them. llvm-svn: 86173
* Eliminate some false positives due to a thinko in the "'blah' isDouglas Gregor2009-11-051-11/+7
| | | | | | | always zero in this context" warning logic. Also, make the diagnostic itself more precise when referring to pointer values ("NULL" vs. "zero"). llvm-svn: 86143
* Implement the conditional-operator part of -Wsign-compare. TurnJohn McCall2009-11-051-5/+7
| | | | | | | | | | | | DiagnoseSignCompare into Sema::CheckSignCompare and call it from more places. Add some enumerator tests. These seem to expose some oddities in the types we're converting C++ enumerators to; in particular, they're converting to unsigned before int, which seems to contradict 4.5 [conv.prom] p2. Note to self: stop baiting Doug in my commit messages. llvm-svn: 86128
* When instantiating a UnaryOperator, allow the resulting expression toDouglas Gregor2009-11-051-15/+27
| | | | | | | | | | | | | still be dependent or invoke an overloaded operator. Previously, we only supported builtin operators. BinaryOperator/CompoundAssignOperator didn't have this issue because we always built a CXXOperatorCallExpr node, even when name lookup didn't find any functions to save until instantiation time. Now, that code builds a BinaryOperator or CompoundAssignOperator rather than a CXXOperatorCallExpr, to save some space. llvm-svn: 86087
* Implement -Wsign-compare, or at least the actual comparison part of it.John McCall2009-11-051-0/+37
| | | | | | | | Conditional operands are next. Fixes part of rdar://problem/7289584. llvm-svn: 86083
* Preserve type source information in sizeof/alignof expressions, and pass itJohn McCall2009-11-041-8/+10
| | | | | | through to indexing. llvm-svn: 86018
* Diagnose __builtin_offsetof on incomplete types. FixesJohn McCall2009-11-041-0/+4
| | | | | | rdar://problem/7222956 llvm-svn: 85999
* Change our basic strategy for avoiding deprecation warnings when the decl useJohn McCall2009-11-041-28/+2
| | | | | | | | | | | | appears in a deprecated context. In the new strategy, we emit the warnings as usual unless we're currently parsing a declaration, where "declaration" is restricted to mean a decl group or a few special cases in Objective C. If we *are* parsing a declaration, we queue up the deprecation warnings until the declaration has been completely parsed, and then emit them only if the decl is not deprecated. We also standardize the bookkeeping for deprecation so as to avoid special cases. llvm-svn: 85998
* Implement support for parsing dependent template-ids that refer toDouglas Gregor2009-11-041-2/+7
| | | | | | | | overloaded operators, e.g., p->template operator+<T>() llvm-svn: 85989
* We have to ensure we have the canonical type to do this. This is butMike Stump2009-11-031-1/+2
| | | | | | | one instance of a large problem. assert for non-canoical types would help track down these things. llvm-svn: 85956
* Replace the code that parses member access expressions after "." orDouglas Gregor2009-11-031-7/+66
| | | | | | | | | | | | "->" with a use of ParseUnqualifiedId. Collapse ActOnMemberReferenceExpr, ActOnDestructorReferenceExpr (both of them), ActOnOverloadedOperatorReferenceExpr, ActOnConversionOperatorReferenceExpr, and ActOnMemberTemplateIdReferenceExpr into a single, new action ActOnMemberAccessExpr that does the same thing more cleanly (and can keep more source-location information). llvm-svn: 85930
* Use ParseUnqualifiedId when parsing id-expressions. This eliminatesDouglas Gregor2009-11-031-21/+38
| | | | | | | | | | | yet another copy of the unqualified-id parsing code. Also, use UnqualifiedId to simplify the Action interface for building id-expressions. ActOnIdentifierExpr, ActOnCXXOperatorFunctionIdExpr, ActOnCXXConversionFunctionExpr, and ActOnTemplateIdExpr have all been removed in favor of the new ActOnIdExpression action. llvm-svn: 85904
* Properly instantiate usage of overloaded operator []. Fixes PR5345.Sebastian Redl2009-10-291-94/+9
| | | | llvm-svn: 85524
* Track source information for template arguments and template specializationJohn McCall2009-10-291-3/+3
| | | | | | | types. Preserve it through template instantiation. Preserve it through PCH, although TSTs themselves aren't serializable, so that's pretty much meaningless. llvm-svn: 85500
* Diagnose use of data pointer member in a function callFariborz Jahanian2009-10-281-14/+19
| | | | | | expression instead of crashing. llvm-svn: 85401
* Type of a conditional expression with two distinct objective-cFariborz Jahanian2009-10-271-1/+4
| | | | | | | class pointer is the most derived common class of the two. This is <rdar://problem/7334235>. llvm-svn: 85337
* Explicit instantiation suppresses the instantiation of non-inlineDouglas Gregor2009-10-271-5/+5
| | | | | | | function template specializations and member functions of class template specializations. llvm-svn: 85300
* Implement Chris's suggestions for the precendence warnings. Reformat the ↵Sebastian Redl2009-10-271-26/+22
| | | | | | code a bit. Test the fixits. llvm-svn: 85231
* Add fixit hint to bitwise precedence warning.Sebastian Redl2009-10-261-8/+31
| | | | llvm-svn: 85129
* Implement a warning for mixing bitwise logical with comparison ops. Fixes ↵Sebastian Redl2009-10-261-0/+50
| | | | | | PR5297. llvm-svn: 85117
* Implement rdar://6756623 - use of deprecated type in deprecated typedef ↵Chris Lattner2009-10-251-5/+9
| | | | | | should not warn llvm-svn: 85073
* minor reorg: check both attributes before decl.Chris Lattner2009-10-251-6/+6
| | | | llvm-svn: 85058
* Add support for vector shifts, pretty straight forward.Nate Begeman2009-10-251-0/+4
| | | | llvm-svn: 85033
* Migrate Sema::ActOnCallExpr to Sema::FixOverloadedFunctionReference,Douglas Gregor2009-10-231-7/+1
| | | | | | | | | | | | | so that we maintain better source information after template argument deduction and overloading resolves down to a specific declaration. Found and dealt with a few more cases that FixOverloadedFunctionReference didn't cope with. (Finally) added a test case that puts together this change with the DeclRefExpr change to (optionally) include nested-name-specifiers and explicit template argument lists. llvm-svn: 84974
* Apply the special enum restrictions from [over.match.oper]p3b2 in ↵Sebastian Redl2009-10-231-2/+2
| | | | | | argument-dependent lookup too. This fixes PR5244. llvm-svn: 84963
* Eliminate QualifiedDeclRefExpr, which captured the notion of aDouglas Gregor2009-10-231-33/+17
| | | | | | | | | | | | | | | | | | | | | | | | qualified reference to a declaration that is not a non-static data member or non-static member function, e.g., namespace N { int i; } int j = N::i; Instead, extend DeclRefExpr to optionally store the qualifier. Most clients won't see or care about the difference (since QualifierDeclRefExpr inherited DeclRefExpr). However, this reduces the number of top-level expression types that clients need to cope with, brings the implementation of DeclRefExpr into line with MemberExpr, and simplifies and unifies our handling of declaration references. Extended DeclRefExpr to (optionally) store explicitly-specified template arguments. This occurs when naming a declaration via a template-id (which will be stored in a TemplateIdRefExpr) that, following template argument deduction and (possibly) overload resolution, is replaced with a DeclRefExpr that refers to a template specialization but maintains the template arguments as written. llvm-svn: 84962
* Refactor our handling of implicit member reference expressions to get most ↵Douglas Gregor2009-10-221-83/+19
| | | | | | of the logic out of BuildDeclarationNameExpr llvm-svn: 84847
* Remove default argument for ImpCastExprToType. Add appropriate argument Eli Friedman2009-10-201-64/+78
| | | | | | | | | | | | | to all callers. Switch a few other users of CK_Unknown to proper cast kinds. Note that there are still some situations where we end up with CK_Unknown; they're pretty easy to find with grep. There are still a few missing conversion kinds, specifically pointer/int/float->bool and the various combinations of real/complex float/int->real/complex float/int. llvm-svn: 84623
* Move clients to use IdentifierInfo::getNameStart() instead of getName()Daniel Dunbar2009-10-181-2/+2
| | | | llvm-svn: 84436
* Add some more cast kinds.Anders Carlsson2009-10-181-1/+36
| | | | llvm-svn: 84423
* Add another two ExtVectorComponent FIXMEs.Daniel Dunbar2009-10-181-0/+5
| | | | llvm-svn: 84393
* Fix a crash with qualified member access into a non-type, from Sean Hunt!Douglas Gregor2009-10-171-0/+6
| | | | llvm-svn: 84370
* teach getCorrespondingUnsignedType how to handle vectors of integers,Chris Lattner2009-10-171-6/+6
| | | | | | fixing PR4838. llvm-svn: 84353
* Add CK_VectorSplat and use it for casting non-pointer scalars to ExtVectors.Anders Carlsson2009-10-161-9/+18
| | | | llvm-svn: 84245
* Make CheckVectorCast return a CastKind. Reduce nesting of if statements in ↵Anders Carlsson2009-10-161-19/+31
| | | | | | CheckCastTypes. llvm-svn: 84242
* Add a ToVoid cast kind and start using it.Anders Carlsson2009-10-161-1/+5
| | | | llvm-svn: 84241
OpenPOWER on IntegriCloud