summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaCodeComplete.cpp
Commit message (Collapse)AuthorAgeFilesLines
* It turns out that basically every caller to RequireCompleteDeclContextJohn McCall2010-05-011-1/+1
| | | | | | | already knows what context it's looking in. Just pass that context in instead of (questionably) recalculating it. llvm-svn: 102818
* Recommit my change to how C++ does elaborated type lookups, now withJohn McCall2010-04-231-5/+14
| | | | | | two bugfixes which fix selfhost and (hopefully) the nightly tests. llvm-svn: 102198
* Revert "C++ doesn't really use "namespaces" for different kinds of names the ↵Daniel Dunbar2010-04-231-15/+5
| | | | | | same", which seems to break most C++ nightly test apps. llvm-svn: 102174
* C++ doesn't really use "namespaces" for different kinds of names the sameJohn McCall2010-04-231-5/+15
| | | | | | | | | | | | | way that C does. Among other differences, elaborated type specifiers are defined to skip "non-types", which, as you might imagine, does not include typedefs. Rework our use of IDNS masks to capture the semantics of different kinds of declarations better, and remove most current lookup filters. Removing the last remaining filter is more complicated and will happen in a separate patch. Fixes PR 6885 as well some spectrum of unfiled bugs. llvm-svn: 102164
* Rework the Parser-Sema interaction for Objective-C messageDouglas Gregor2010-04-211-47/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sends. Major changes include: - Expanded the interface from two actions (ActOnInstanceMessage, ActOnClassMessage), where ActOnClassMessage also handled sends to "super" by checking whether the identifier was "super", to three actions (ActOnInstanceMessage, ActOnClassMessage, ActOnSuperMessage). Code completion has the same changes. - The parser now resolves the type to which we are sending a class message, so ActOnClassMessage now accepts a TypeTy* (rather than an IdentifierInfo *). This opens the door to more interesting types (for Objective-C++ support). - Split ActOnInstanceMessage and ActOnClassMessage into parser action functions (with their original names) and semantic functions (BuildInstanceMessage and BuildClassMessage, respectively). At present, this split is onyl used by ActOnSuperMessage, which decides which kind of super message it has and forwards to the appropriate Build*Message. In the future, Build*Message will be used by template instantiation. - Use getObjCMessageKind() within the disambiguation of Objective-C message sends vs. array designators. Two notes about substandard bits in this patch: - There is some redundancy in the code in ParseObjCMessageExpr and ParseInitializerWithPotentialDesignator; this will be addressed shortly by centralizing the mapping from identifiers to type names for the message receiver. - There is some #if 0'd code that won't likely ever be used---it handles the use of 'super' in methods whose class does not have a superclass---but could be used to model GCC's behavior more closely. This code will die in my next check-in, but I want it in Subversion. llvm-svn: 102021
* Overhaul the AST representation of Objective-C message sendDouglas Gregor2010-04-211-7/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Eliminate the ForceRValue parameter to Sema::AddOverloadCandidateDouglas Gregor2010-04-161-1/+1
| | | | llvm-svn: 101494
* Feed proper source-location information into Sema::LookupSingleResult,Douglas Gregor2010-04-151-8/+12
| | | | | | | | in case it ends up doing something that might trigger diagnostics (template instantiation, ambiguity reporting, access reporting). Noticed while working on PR6831. llvm-svn: 101412
* Make CXXScopeSpec invalid when incomplete, and propagate that into anyJeffrey Yasskin2010-04-081-1/+1
| | | | | | | Declarator that depends on it. This fixes several redundant errors and bad recoveries. llvm-svn: 100779
* Implement code completion for Objective-C method declarations andDouglas Gregor2010-04-071-0/+221
| | | | | | | | | | | | | | | | definitions, e.g., after - or - (id) we'll find all of the "likely" instance methods that one would want to declare or define at this point. In the latter case, we only produce results whose return types match "id". llvm-svn: 100587
* When code completion produces an overload set as its results (e.g.,Douglas Gregor2010-04-061-3/+2
| | | | | | | while we're completing in the middle of a function call), also produce "ordinary" name results that show what can be typed at that point. llvm-svn: 100558
* Do not produce semicolons at the end of code-completion resultsDouglas Gregor2010-04-061-14/+0
| | | | llvm-svn: 100557
* Only prove macros as code-completion results when we're in a caseDouglas Gregor2010-04-061-19/+1
| | | | | | | statement or for ordinary names. This means that we won't show macros when completing, e.g., member expressions such as "p->". llvm-svn: 100555
* When sending a message to "id", apply some heuristics to try to narrowDouglas Gregor2010-04-061-0/+68
| | | | | | | down the set of code-completion results based on Objective-C conventions. llvm-svn: 100548
* Make code-completion for Objective-C message sends to "id" work in theDouglas Gregor2010-04-061-4/+34
| | | | | | | | presence of precompiled headers by forcibly loading all of the methods we know about from the PCH file before constructing our code-completion list. llvm-svn: 100535
* Implement support for code completion of an Objective-C message send toDouglas Gregor2010-04-061-9/+49
| | | | | | | | | | "id" or an expression of type "id". In these cases, we produce a list of all of the (class or instance) methods, respectively, that we know about. Note that this implementation does not yet work well with precompiled headers; that's coming soon. llvm-svn: 100528
* Extend the type printing policy to allow one to turn off the printingDouglas Gregor2010-04-051-1/+4
| | | | | | | of file locations for anonymous tag types (e.g., "enum <anonymous at t.h:15:6>"), which can get rather long. llvm-svn: 100470
* Remember the "found declaration" for an overload candidate, which is theJohn McCall2010-03-191-1/+2
| | | | | | | | | | | | | | | | entity (if applicable) which was actually looked up. If a candidate was found via a using declaration, this is the UsingShadowDecl; otherwise, if the candidate is template specialization, this is the template; otherwise, this is the function. The point of this exercise is that "found declarations" are the entities we do access control for, not their underlying declarations. Broadly speaking, this patch fixes access control for using declarations. There is a *lot* of redundant code calling into the overload-resolution APIs; we really ought to clean that up. llvm-svn: 98945
* Split C++ friend declarations into their own header/implementation file.John McCall2010-03-111-2/+1
| | | | | | | | | I'm expecting this portion of the AST to grow and change, and I'd like to be able to do that with minimal recompilation. If this proves unnecessary when access control is fully-implemented, I'll fold the classes back into DeclCXX.h. llvm-svn: 98249
* Keep an explicit stack of function and block scopes, each element ofDouglas Gregor2010-03-011-2/+3
| | | | | | | | | | | | | | | | | | | | which has the label map, switch statement stack, etc. Previously, we had a single set of maps in Sema (for the function) along with a stack of block scopes. However, this lead to funky behavior with nested functions, e.g., in the member functions of local classes. The explicit-stack approach is far cleaner, and we retain a 1-element cache so that we're not malloc/free'ing every time we enter a function. Fixes PR6382. Also, tweaked the unused-variable warning suppression logic to look at errors within a given Scope rather than within a given function. The prior code wasn't looking at the right number-of-errors count when dealing with blocks, since the block's count would be deallocated before we got to ActOnPopScope. This approach works with nested blocks/functions, and gives tighter error recovery. llvm-svn: 97518
* Add some spacing in the code-completion results for a return statementDouglas Gregor2010-02-181-1/+3
| | | | llvm-svn: 96567
* Thread a source location into the template-argument deduction routines. ThereJohn McCall2010-02-081-4/+7
| | | | | | | may be some other places that could take advantage of this new information, but I haven't really looked yet. llvm-svn: 95600
* Implement the lvalue-to-rvalue conversion where needed. TheDouglas Gregor2010-02-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | lvalue-to-rvalue conversion adjusts lvalues of qualified, non-class type to rvalue expressions of the unqualified variant of that type. For example, given: const int i; (void)(i + 17); the lvalue-to-rvalue conversion for the subexpression "i" will turn it from an lvalue expression (a DeclRefExpr) with type 'const int' into an rvalue expression with type 'int'. Both C and C++ mandate this conversion, and somehow we've slid through without implementing it. We now have both DefaultFunctionArrayConversion and DefaultFunctionArrayLvalueConversion, and which gets used depends on whether we do the lvalue-to-rvalue conversion or not. Generally, we do the lvalue-to-rvalue conversion, but there are a few notable exceptions: - the left-hand side of a '.' operator - the left-hand side of an assignment - a C++ throw expression - a subscript expression that's subscripting a vector Making this change exposed two issues with blocks: - we were deducing const-qualified return types of non-class type from a block return, which doesn't fit well - we weren't always setting the known return type of a block when it was provided with the ^return-type syntax Fixes the current Clang-on-Clang compile failure and PR6076. llvm-svn: 95167
* Pass access specifiers around in overload resolution.John McCall2010-01-261-1/+2
| | | | llvm-svn: 94485
* Teach code-completion to deal with calls to functions without prototypes.Douglas Gregor2010-01-211-15/+21
| | | | llvm-svn: 94076
* Switch a few callers of MaybeAddResult over to AddResult, when theDouglas Gregor2010-01-141-10/+12
| | | | | | declarations we're adding do not need any name-hiding checks. llvm-svn: 93431
* Switch code-completion's ivar lookup over to LookupVisibleDecls,Douglas Gregor2010-01-141-5/+11
| | | | | | eliminating yet one more ResultBuilder::MaybeAddResult caller. llvm-svn: 93430
* Start migrating code-completion results fromDouglas Gregor2010-01-141-117/+129
| | | | | | ResultBuilder::MaybeAddResult over to ResultBuilder::AddResult. llvm-svn: 93429
* Switch the remaining code completions over to LookupVisibleDecls,Douglas Gregor2010-01-141-106/+15
| | | | | | | | after adding the ability to determine whether our lookup is a base-class lookup. Eliminate CollectMemberLookupResults, since it is no longer used (yay). llvm-svn: 93428
* Move code completion for qualified name lookup (foo::) toDouglas Gregor2010-01-141-1/+2
| | | | | | LookupVisibleDecls. Also, a function does not hide another function. llvm-svn: 93421
* Eliminate the code-completion-specifier CollectLookupResults in favorDouglas Gregor2010-01-141-73/+10
| | | | | | of the more general LookupVisibleDecls. llvm-svn: 93419
* Simplify the code-completion logic for nested-name-specifiers: ratherDouglas Gregor2010-01-141-31/+43
| | | | | | | than traversing visible declarations twice, only perform one traversal and recognize nested-name-specifiers as special. llvm-svn: 93418
* When providing completions for a member access expression in C++,Douglas Gregor2010-01-141-8/+3
| | | | | | | provided nested-name-specifier results for base classes (only), rather than everything that could possibly be a nested-name-specifier. llvm-svn: 93398
* Switch code-completion for ordinary names over to the new(ish)Douglas Gregor2010-01-141-4/+80
| | | | | | | | | | LookupVisibleDecls, unifying the name lookup mechanisms used by code completion and typo correction. Aside from the software-engineering improvements, this makes code-completion see through using directives and see ivars when performing unqualified name lookup in an Objective-C instance method. llvm-svn: 93397
* More refactoring of ResultBuilder::MaybeAddResult. No intendedDouglas Gregor2010-01-141-40/+39
| | | | | | functionality change. llvm-svn: 93386
* Refactor the "is this declaration interesting" logic inDouglas Gregor2010-01-141-33/+51
| | | | | | code-completion's ResultBuilder::MaybeAddResult for later reuse. llvm-svn: 93379
* Banish the notion of a "rank" for code-completion results, since weDouglas Gregor2010-01-131-256/+197
| | | | | | are no longer using it for anything. No intended functionality change. llvm-svn: 93376
* Improve the sorting of code-completion results. We now always sort byDouglas Gregor2010-01-131-38/+41
| | | | | | | | the "typed" text, first, then take into account nested-name-specifiers, name hiding, etc. This means that the resulting sort is actually alphabetical :) llvm-svn: 93370
* Code-completion for @public, @protected, @private, @package.Douglas Gregor2010-01-131-1/+30
| | | | llvm-svn: 93361
* Whenever completing ordinary names for an Objective-C source, alsoDouglas Gregor2010-01-131-99/+159
| | | | | | | | | | | provide completions for @ keywords. Previously, we only provided @-completions after an @ was actually typed, which is useful but probably not the common case. Also, make sure a few Objective-C 2.0 completions only show up when Objective-C 2.0 support is enabled (the default). llvm-svn: 93354
* Use horizontal-space markers in code-completion results rather thanDouglas Gregor2010-01-121-14/+21
| | | | | | embedding single space characters. <rdar://problem/7485503> llvm-svn: 93231
* Improve code completion by introducing patterns for the various C andDouglas Gregor2010-01-101-20/+529
| | | | | | | | | | | | | | | | | | | | | | C++ grammatical constructs that show up in top-level (namespace-level) declarations, member declarations, template declarations, statements, expressions, conditions, etc. For example, we now provide a pattern for static_cast<type>(expr) when we can have an expression, or using namespace identifier; when we can have a using directive. Also, improves the results of code completion at the beginning of a top-level declaration. Previously, we would see value names (function names, global variables, etc.); now we see types, namespace names, etc., but no values. llvm-svn: 93134
* remove extraneous #includeChris Lattner2009-12-301-1/+0
| | | | llvm-svn: 92310
* Typo correction for type names when they appear in declarations, e.g., givenDouglas Gregor2009-12-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | tring str2; we produce the following diagnostic + fix-it: typo.cpp:15:1: error: unknown type name 'tring'; did you mean 'string'? tring str2; ^~~~~ string To make this really useful, we'll need to introduce typo correction in many more places (wherever we do name lookup), and implement declaration-vs-expression heuristics that cope with typos better. However, for now this will handle the simple cases where we already get good "unknown type name" diagnostics. The LookupVisibleDecls functions are intended to be used by code completion as well as typo correction; that refactoring will happen later. llvm-svn: 92308
* Remove some dead variables clang-analyzer found.Benjamin Kramer2009-12-251-1/+0
| | | | llvm-svn: 92162
* Objective-C methods can be variadic, too. Who knew.Douglas Gregor2009-12-231-0/+7
| | | | llvm-svn: 91951
* Extend code-completion results with the type of each resultDouglas Gregor2009-12-181-0/+36
| | | | llvm-svn: 91702
* Shift things around so that it's easier to recover from a missingJohn McCall2009-12-161-22/+13
| | | | | | | | | function in a C++ call using an arbitrary call-expression type. Actually exploit this to fix the recovery implemented earlier. The diagnostic is still iffy, though. llvm-svn: 91538
* update to match LLVM API change:Chris Lattner2009-12-151-7/+0
| | | | | | | | | Remove isPod() from DenseMapInfo, splitting it out to its own isPodLike type trait. This is a generally useful type trait for more than just DenseMap, and we really care about whether something acts like a pod, not whether it really is a pod. llvm-svn: 91422
* Un-namespace-qualify llvm_unreachable. It's a macro, so the qualification gaveJeffrey Yasskin2009-12-121-1/+1
| | | | | | no extra safety anyway. llvm-svn: 91207
OpenPOWER on IntegriCloud