summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Add BasePath arguments to all cast expr constructors.Anders Carlsson2010-04-241-1/+3
| | | | llvm-svn: 102258
* Pass the base specifiers through to CheckDerivedToBaseConversion. No ↵Anders Carlsson2010-04-241-1/+1
| | | | | | functionality change yet. llvm-svn: 102250
* CastExpr should not hold a pointer to the base path. More cleanup.Anders Carlsson2010-04-241-3/+0
| | | | llvm-svn: 102249
* Add an InheritancePath parameter to the ImplicitCastExpr constructor.Anders Carlsson2010-04-231-2/+5
| | | | llvm-svn: 102218
* Implement template instantiation for Objective-C++ message sends. WeDouglas Gregor2010-04-221-0/+5
| | | | | | | | | | | | support dependent receivers for class and instance messages, along with dependent message arguments (of course), and check as much as we can at template definition time. This commit also deals with a subtle aspect of template instantiation in Objective-C++, where the type 'T *' can morph from a dependent PointerType into a non-dependent ObjCObjectPointer type. llvm-svn: 102071
* Whenever we complain about a failed initialization of a function orDouglas Gregor2010-04-221-1/+7
| | | | | | | | | | | | | | | | | method parameter, provide a note pointing at the parameter itself so the user does not have to manually look for the function/method being called and match up parameters to arguments. For example, we now get: t.c:4:5: warning: incompatible pointer types passing 'long *' to parameter of type 'int *' [-pedantic] f(long_ptr); ^~~~~~~~ t.c:1:13: note: passing argument to parameter 'x' here void f(int *x); ^ llvm-svn: 102038
* Overhaul the AST representation of Objective-C message sendDouglas Gregor2010-04-211-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | expressions, to improve source-location information, clarify the actual receiver of the message, and pave the way for proper C++ support. The ObjCMessageExpr node represents four different kinds of message sends in a single AST node: 1) Send to a object instance described by an expression (e.g., [x method:5]) 2) Send to a class described by the class name (e.g., [NSString method:5]) 3) Send to a superclass class (e.g, [super method:5] in class method) 4) Send to a superclass instance (e.g., [super method:5] in instance method) Previously these four cases where tangled together. Now, they have more distinct representations. Specific changes: 1) Unchanged; the object instance is represented by an Expr*. 2) Previously stored the ObjCInterfaceDecl* referring to the class receiving the message. Now stores a TypeSourceInfo* so that we know how the class was spelled. This both maintains typedef information and opens the door for more complicated C++ types (e.g., dependent types). There was an alternative, unused representation of these sends by naming the class via an IdentifierInfo *. In practice, we either had an ObjCInterfaceDecl *, from which we would get the IdentifierInfo *, or we fell into the case below... 3) Previously represented by a class message whose IdentifierInfo * referred to "super". Sema and CodeGen would use isStr("super") to determine if they had a send to super. Now represented as a "class super" send, where we have both the location of the "super" keyword and the ObjCInterfaceDecl* of the superclass we're targetting (statically). 4) Previously represented by an instance message whose receiver is a an ObjCSuperExpr, which Sema and CodeGen would check for via isa<ObjCSuperExpr>(). Now represented as an "instance super" send, where we have both the location of the "super" keyword and the ObjCInterfaceDecl* of the superclass we're targetting (statically). Note that ObjCSuperExpr only has one remaining use in the AST, which is for "super.prop" references. The new representation of ObjCMessageExpr is 2 pointers smaller than the old one, since it combines more storage. It also eliminates a leak when we loaded message-send expressions from a precompiled header. The representation also feels much cleaner to me; comments welcome! This patch attempts to maintain the same semantics we previously had with Objective-C message sends. In several places, there are massive changes that boil down to simply replacing a nested-if structure such as: if (message has a receiver expression) { // instance message if (isa<ObjCSuperExpr>(...)) { // send to super } else { // send to an object } } else { // class message if (name->isStr("super")) { // class send to super } else { // send to class } } with a switch switch (E->getReceiverKind()) { case ObjCMessageExpr::SuperInstance: ... case ObjCMessageExpr::Instance: ... case ObjCMessageExpr::SuperClass: ... case ObjCMessageExpr::Class:... } There are quite a few places (particularly in the checkers) where send-to-super is effectively ignored. I've placed FIXMEs in most of them, and attempted to address send-to-super in a reasonable way. This could use some review. llvm-svn: 101972
* Switch Sema::FindCompositePointerType() over to InitializationSequence. Douglas Gregor2010-04-161-2/+2
| | | | | | | This is the last of the uses of TryImplicitConversion outside of overload resolution and InitializationSequence itself. llvm-svn: 101569
* Collapse the three separate initialization paths inDouglas Gregor2010-04-161-18/+3
| | | | | | | | | | | | | | | | | | TryStaticImplicitCast (for references, class types, and everything else, respectively) into a single invocation of InitializationSequence. One of the paths (for class types) was the only client of Sema::TryInitializationByConstructor, which I have eliminated. This also simplified the interface for much of the cast-checking logic, eliminating yet more code. I've kept the representation of C++ functional casts with <> 1 arguments the same, despite the fact that I hate it. That fix will come soon. To satisfy my paranoia, I've bootstrapped + tested Clang with these changes. llvm-svn: 101549
* Expand the argument diagnostics for too many arguments and giveEric Christopher2010-04-161-1/+2
| | | | | | | | both number seen and number expected. Finishes fixing PR6501. llvm-svn: 101442
* Expand argument diagnostic for too few arguments to give the numberEric Christopher2010-04-161-1/+2
| | | | | | | | of arguments both seen and expected. Fixes PR6501. llvm-svn: 101441
* Thread a Scope pointer into BuildRecoveryCallExpr to help typoDouglas Gregor2010-04-141-1/+1
| | | | | | | correction find names when a call failed. Fixes <rdar://problem/7853795>. llvm-svn: 101278
* Teach typo correction about various language keywords. We can'tDouglas Gregor2010-04-141-33/+46
| | | | | | | | | | | | | generally recover from typos in keywords (since we would effectively have to mangle the token stream). However, there are still benefits to typo-correcting with keywords: - We don't make stupid suggestions when the user typed something that is similar to a keyword. - We can suggest the keyword in a diagnostic (did you mean "static_cast"?), even if we can't recover and therefore don't have a fix-it. llvm-svn: 101274
* When diagnosing suspicious precedence or assignments, move the fix-itDouglas Gregor2010-04-141-20/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | that adds parentheses from the main diagnostic down to a new note. This way, when the fix-it represents a choice between two options, each of the options is associted with a note. There is no default option in such cases. For example: /Users/dgregor/t.c:2:9: warning: & has lower precedence than ==; == will be evaluated first [-Wparentheses] if (x & y == 0) { ^~~~~~~~ /Users/dgregor/t.c:2:9: note: place parentheses around the & expression to evaluate it first if (x & y == 0) { ^ ( ) /Users/dgregor/t.c:2:9: note: place parentheses around the == expression to silence this warning if (x & y == 0) { ^ ( ) llvm-svn: 101249
* Use ASTVector instead of std::vector for the Exprs in InitListExpr. PerformanceTed Kremenek2010-04-131-4/+5
| | | | | | | measurements of '-fsyntax-only' on combine.c (403.gcc) shows no real performance change, but now the vector isn't leaked. llvm-svn: 101195
* Implement C++ [temp.local]p4, which specifies how we eliminateDouglas Gregor2010-04-121-2/+4
| | | | | | | | | name-lookup ambiguities when there are multiple base classes that are all specializations of the same class template. This is part of a general cleanup for ambiguities in template-name lookup. Fixes PR6717. llvm-svn: 101065
* change Scope::WithinElse to be a normal scope flag, widen theChris Lattner2010-04-121-4/+3
| | | | | | fields to two 16-bit values instead of using bitfields. llvm-svn: 101020
* fix a fixme, stop evaluating getCurMethodDecl() repeatedly Chris Lattner2010-04-121-6/+5
| | | | | | in "LookupInObjCMethod". llvm-svn: 101014
* fix PR6811 by not parsing 'super' as a magic expression inChris Lattner2010-04-111-16/+4
| | | | | | | | | | | | | LookupInObjCMethod. Doing so allows all sorts of invalid code to slip through to codegen. This patch does not change the AST representation of super, though that would now be a natural thing to do since it can only be in the receiver position and in the base of a ObjCPropertyRefExpr. There are still several ugly areas handling super in the parser, but this is definitely a step in the right direction. llvm-svn: 100959
* actually the interface grossness in the previous patch was due toChris Lattner2010-04-111-3/+1
| | | | | | | | typo correction. However, now that the code has been factored out of LookupMemberExpr, it can recurse to itself instead of to LookupMemberExpr! Remove grossness. llvm-svn: 100958
* factor the code that handles "expr.field" when expr is aChris Lattner2010-04-111-99/+6
| | | | | | | | pointer to an objc interface out to a method in SemaExprObjC. This is *much* uglier than it should be due to grossness in LookupMemberExpr :( llvm-svn: 100957
* Remove fixit for string literal comparison. Telling the user to use ↵Ted Kremenek2010-04-091-5/+1
| | | | | | | | | 'strcmp' is bad, and we don't have enough information to tell them how to use 'strncmp'. Instead, change the diagnostic to indicate they should use 'strncmp'. llvm-svn: 100890
* Improve diagnostics when we fail to convert from a source type to aDouglas Gregor2010-04-091-1/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | destination type for initialization, assignment, parameter-passing, etc. The main issue fixed here is that we used rather confusing wording for diagnostics such as t.c:2:9: warning: initializing 'char const [2]' discards qualifiers, expected 'char *' [-pedantic] char *name = __func__; ^ ~~~~~~~~ We're not initializing a 'char const [2]', we're initializing a 'char *' with an expression of type 'char const [2]'. Similar problems existed for other diagnostics in this area, so I've normalized them all with more precise descriptive text to say what we're initializing/converting/assigning/etc. from and to. The warning for the code above is now: t.c:2:9: warning: initializing 'char *' from an expression of type 'char const [2]' discards qualifiers [-pedantic] char *name = __func__; ^ ~~~~~~~~ Fixes <rdar://problem/7447179>. llvm-svn: 100832
* Make CXXScopeSpec invalid when incomplete, and propagate that into anyJeffrey Yasskin2010-04-081-7/+7
| | | | | | | Declarator that depends on it. This fixes several redundant errors and bad recoveries. llvm-svn: 100779
* Return early from Sema::MarkDeclarationReferenced when we know thereDouglas Gregor2010-04-071-2/+7
| | | | | | | | | isn't any extra work to perform. Also, don't check for unused parameters when the warnings will be suppressed anyway. Improves performance of -fsyntax-only on 403.gcc's combine.c by ~2.5%. <rdar://problem/7836787> llvm-svn: 100686
* Implement the protected access restriction ([class.protected]), which requiresJohn McCall2010-04-061-25/+8
| | | | | | | | that protected members be used on objects of types which derive from the naming class of the lookup. My first N attempts at this were poorly-founded, largely because the standard is very badly worded here. llvm-svn: 100562
* Diagnose invalid code with -fobjc-nonfragile-abi2 whenFariborz Jahanian2010-04-021-5/+0
| | | | | | | property is being accessed without the dot-syntax notation. (radar 7822344). llvm-svn: 100212
* Reinstate my CodeModificationHint -> FixItHint renaming patch, withoutDouglas Gregor2010-03-311-37/+31
| | | | | | the C-only "optimization". llvm-svn: 100022
* Revert r100008, which inexplicably breaks the clang-i686-darwin10 builderDouglas Gregor2010-03-311-31/+37
| | | | llvm-svn: 100018
* Rename CodeModificationHint to FixItHint, since we've been using theDouglas Gregor2010-03-311-37/+31
| | | | | | | term "fix-it" everywhere and even *I* get tired of long names sometimes. No functionality change. llvm-svn: 100008
* Remove silly temporary comment.John McCall2010-03-301-2/+0
| | | | llvm-svn: 99964
* Introduce a new kind of derived-to-base cast which bypasses the need forJohn McCall2010-03-301-4/+4
| | | | | | | null checks, and make sure we elide null checks when accessing base class members. llvm-svn: 99963
* Remember the regparm attribute in FunctionType::ExtInfo.Rafael Espindola2010-03-301-2/+2
| | | | | | Fixes PR3782. llvm-svn: 99940
* Propagate the "found declaration" (i.e. the using declaration instead ofJohn McCall2010-03-301-35/+95
| | | | | | | | | | | | | the underlying/instantiated decl) through a lot of API, including "intermediate" MemberExprs required for (e.g.) template instantiation. This is necessary because of the access semantics of member accesses to using declarations: only the base class *containing the using decl* need be accessible from the naming class. This allows us to complete an access-controlled selfhost, if there are no recent regressions. llvm-svn: 99936
* the big refactoring bits of PR3782.Rafael Espindola2010-03-301-4/+4
| | | | | | | | This introduces FunctionType::ExtInfo to hold the calling convention and the noreturn attribute. The next patch will extend it to include the regparm attribute and fix the bug. llvm-svn: 99920
* Optimize PartialDiagnostic's memory-allocation behavior by placing aDouglas Gregor2010-03-291-8/+8
| | | | | | | | | | | | | | cache of PartialDiagnostic::Storage objects into an allocator within the ASTContext. This eliminates a significant amount of malloc traffic, for a 10% performance improvement in -fsyntax-only wall-clock time with 403.gcc's combine.c. Also, eliminate the RequireNonAbstractType hack I put in earlier, which was but a symptom of this larger problem. Fixes <rdar://problem/7806091>. llvm-svn: 99849
* Allow conversion of qualified Class type to unqualifiedFariborz Jahanian2010-03-241-2/+4
| | | | | | Class type to match gcc's. Fixes radar 7789113. llvm-svn: 99425
* Only perform CFG-based warnings on 'static inline' functions thatTed Kremenek2010-03-231-2/+3
| | | | | | | are called (transitively) by regular functions/blocks within a translation untion. llvm-svn: 99233
* -Wshadow should only warn about parameter declarations when we'reJohn McCall2010-03-221-1/+9
| | | | | | | | | entering a function or block definition, not on every single declaration. Unfortunately we don't have previous-lookup results around when it's time to make this decision, so we have to redo the lookup. The alternative is to use delayed diagnostics. llvm-svn: 99172
* Refactor CFG-based warnings in Sema to be run by a worked object called ↵Ted Kremenek2010-03-201-4/+5
| | | | | | | | | | | | | | | AnalysisBasedWarnings. This object controls when the warnings are executed, allowing the client code in Sema to selectively disable warnings as needed. Centralizing the logic for analysis-based warnings allows us to optimize when and how they are run. Along the way, remove the redundant logic for the 'check fall-through' warning for blocks; now the same logic is used for both blocks and functions. llvm-svn: 99085
* Diagnose conversion of 'Class' to/from objective-c Fariborz Jahanian2010-03-191-1/+11
| | | | | | | object pointer types. Fixes radar 7634850. llvm-svn: 98970
* Some cleanup, change diagnostic when assigning toFariborz Jahanian2010-03-181-3/+0
| | | | | | a property which is not lvalue. llvm-svn: 98848
* objective-c patch to provide type safty when blocks are passing orFariborz Jahanian2010-03-171-1/+5
| | | | | | | returning objc objects. There will be a corresponding objective-c++ patch soon. llvm-svn: 98696
* Issue error when a byref array is accessed in a blockFariborz Jahanian2010-03-161-1/+1
| | | | | | literal. Fixes radar 7760213. llvm-svn: 98693
* Audit all Preprocessor::getSpelling() callers, improving failureDouglas Gregor2010-03-161-2/+8
| | | | | | recovery for those that need it. llvm-svn: 98689
* Add support for -Wwrite-strings. Patch by Mike M! Fixes PR 4804.John McCall2010-03-151-1/+1
| | | | llvm-svn: 98541
* Use SmallString instead of SmallVectorKovarththanan Rajaratnam2010-03-131-173/+173
| | | | llvm-svn: 98436
* Warn about comparing an unsigned expression with 0 in tautological ways.John McCall2010-03-111-3/+2
| | | | | | Patch by mikem! llvm-svn: 98279
* Statement expressions can be used in global- or namespace-scoped blocksDouglas Gregor2010-03-101-1/+2
| | | | llvm-svn: 98135
* Allow use of byref (__block attributed) arrays insideFariborz Jahanian2010-03-061-1/+1
| | | | | | the block. Fixes radar 7671883. llvm-svn: 97863
OpenPOWER on IntegriCloud