summaryrefslogtreecommitdiffstats
path: root/lib/Sema/CodeCompleteConsumer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [C++11] Use 'nullptr'. Sema edition.Craig Topper2014-05-261-5/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209613 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a bunch of mislayered clang/Lex includes from SemaAlp Toker2014-05-031-1/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207896 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow the computation of the base priority for a declaration code completion ↵Douglas Gregor2013-01-311-28/+0
| | | | | | result to consider the completion context git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174037 91177308-0d34-0410-b5e6-96231b3b80d8
* Use 'const Decl *' throughout code completion in SemaDmitri Gribenko2013-01-231-15/+16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173277 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove useless 'llvm::' qualifier from names like StringRef and others that areDmitri Gribenko2013-01-121-2/+2
| | | | | | | brought into 'clang' namespace by clang/Basic/LLVM.h git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172323 91177308-0d34-0410-b5e6-96231b3b80d8
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-4/+4
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169237 91177308-0d34-0410-b5e6-96231b3b80d8
* [libclang] Remove the ParentKind cursor kind from code-completion results.Argyrios Kyrtzidis2012-09-261-5/+2
| | | | | | This is to reduce dependency to cursors for the code-completion results. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164705 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a new libclang completion API to get brief documentation comment that isDmitri Gribenko2012-07-021-5/+14
| | | | | | | | | | | | | | | | | | attached to a declaration in the completion string. Since extracting comments isn't free, a new code completion option is introduced. A new code completion option that enables including brief comments into CodeCompletionString should be a, err, code completion option. But because ASTUnit caches global declarations during parsing before even completion consumer is created, the option is duplicated as a translation unit option (in both libclang and ASTUnit, like the option to cache code completion results). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159539 91177308-0d34-0410-b5e6-96231b3b80d8
* Bitpack CodeCompletionResults.Benjamin Kramer2012-05-201-7/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157158 91177308-0d34-0410-b5e6-96231b3b80d8
* [code-complete] Introduce CodeCompletionTUInfo which will be used for cachingArgyrios Kyrtzidis2012-04-101-52/+69
| | | | | | | | | | | | | | | | | | | code-completion related strings specific to a translation unit (ASTContext and related data) CodeCompletionAllocator does such limited caching, by caching the name assigned to a DeclContext*, but that is not the appropriate place since that object has a lifetime that can extend beyond that of an ASTContext. Introduce CodeCompletionTUInfo which will be always tied to a translation unit to do this kind of caching and move the caching of CodeCompletionAllocator into this object, and propagate it to all the places where it will be needed. The plan is to extend the caching where appropriate, using CodeCompletionTUInfo, to avoid re-calculating code-completion strings. Part of rdar://10796159. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154408 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce a new libclang API to determine the parent context of a codeDouglas Gregor2012-03-271-9/+80
| | | | | | | | | | completion item. For example, if the code completion itself represents a declaration in a namespace (say, std::vector), then this API retrieves the cursor kind and name of the namespace (std). Implements <rdar://problem/11121951>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153545 91177308-0d34-0410-b5e6-96231b3b80d8
* Move CodeCompletionBuilder's chunk adding methods out of line.Benjamin Kramer2012-03-261-0/+34
| | | | | | | This makes sense because chunk's ctor is also out of line and simplifies considerably when inlined with a constant parameter. Shrinks clang on i386-linux-Release+Asserts by 65k. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153446 91177308-0d34-0410-b5e6-96231b3b80d8
* When determining the availability of an enum constant, also considerDouglas Gregor2012-03-171-2/+11
| | | | | | | | the availability of the enumeration type itself. Fixes <rdar://problem/10996386>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152977 91177308-0d34-0410-b5e6-96231b3b80d8
* Basic: import SmallString<> into clang namespaceDylan Noblesmith2012-02-051-1/+1
| | | | | | | (I was going to fix the TODO about DenseMap too, but that would break self-host right now. See PR11922.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149799 91177308-0d34-0410-b5e6-96231b3b80d8
* Move a method from IdentifierTable.h out of line and remove the SmallString ↵Benjamin Kramer2012-02-041-0/+1
| | | | | | | | include. Fix all the transitive include users. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149783 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove unreachable code in Clang. (replace with llvm_unreachable where ↵David Blaikie2012-01-171-5/+4
| | | | | | appropriate or when GCC requires it) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148292 91177308-0d34-0410-b5e6-96231b3b80d8
* Eliminate ObjCForwardProtocolDecl, which is redundant now thatDouglas Gregor2012-01-011-2/+5
| | | | | | | ObjCProtocolDecl modules forward declarations properly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147415 91177308-0d34-0410-b5e6-96231b3b80d8
* Eliminate ObjCClassDecl, which is redundant now that ObjCInterfaceDeclDouglas Gregor2011-12-271-2/+8
| | | | | | | | covers both declarations (@class) and definitions (@interface) of an Objective-C class. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147299 91177308-0d34-0410-b5e6-96231b3b80d8
* Change operator<< for raw_ostream and NamedDecl to take a reference instead ↵Benjamin Kramer2011-10-141-1/+1
| | | | | | | | of a pointer. Passing a pointer was a bad idea as it collides with the overload for void*. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141971 91177308-0d34-0410-b5e6-96231b3b80d8
* Added clang_getCompletionAnnotation and clang_getCompletionNumAnnotations toErik Verbruggen2011-10-141-4/+28
| | | | | | | retrieve annotations from completion string. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141953 91177308-0d34-0410-b5e6-96231b3b80d8
* Added CXAvailability_NotAccessible to indicate that a declaration is ↵Erik Verbruggen2011-10-061-1/+4
| | | | | | available, but not accessible from the current code completion context. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141278 91177308-0d34-0410-b5e6-96231b3b80d8
* When performing code completion after at @interface, allow bothDouglas Gregor2011-07-301-1/+1
| | | | | | | | | already-defined and forward-declared results. Already-defined results are fine because they could be the start of a category. Fixes <rdar://problem/9811691>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136559 91177308-0d34-0410-b5e6-96231b3b80d8
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-6/+5
| | | | | | | | | LLVM.h imports them into the clang namespace. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135852 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce a new libclang aPI function,Douglas Gregor2011-07-071-1/+7
| | | | | | | | | | clang_codeCompleteGetContexts(), that provides the client with information about the context in which code completion has occurred and what kinds of entities make sense as completions at that point. Patch by Connor Wakamo! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134615 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement a new 'availability' attribute, that allows one to specifyDouglas Gregor2011-03-231-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | which versions of an OS provide a certain facility. For example, void foo() __attribute__((availability(macosx,introduced=10.2,deprecated=10.4,obsoleted=10.6))); says that the function "foo" was introduced in 10.2, deprecated in 10.4, and completely obsoleted in 10.6. This attribute ties in with the deployment targets (e.g., -mmacosx-version-min=10.1 specifies that we want to deploy back to Mac OS X 10.1). There are several concrete behaviors that this attribute enables, as illustrated with the function foo() above: - If we choose a deployment target >= Mac OS X 10.4, uses of "foo" will result in a deprecation warning, as if we had placed attribute((deprecated)) on it (but with a better diagnostic) - If we choose a deployment target >= Mac OS X 10.6, uses of "foo" will result in an "unavailable" warning (in C)/error (in C++), as if we had placed attribute((unavailable)) on it - If we choose a deployment target prior to 10.2, foo() is weak-imported (if it is a kind of entity that can be weak imported), as if we had placed the weak_import attribute on it. Naturally, there can be multiple availability attributes on a declaration, for different platforms; only the current platform matters when checking availability attributes. The only platforms this attribute currently works for are "ios" and "macosx", since we already have -mxxxx-version-min flags for them and we have experience there with macro tricks translating down to the deprecated/unavailable/weak_import attributes. The end goal is to open this up to other platforms, and even extension to other "platforms" that are really libraries (say, through a #pragma clang define_system), but that hasn't yet been designed and we may want to shake out more issues with this narrower problem first. Addresses <rdar://problem/6690412>. As a drive-by bug-fix, if an entity is both deprecated and unavailable, we only emit the "unavailable" diagnostic. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128127 91177308-0d34-0410-b5e6-96231b3b80d8
* When code-completing a case statement for a switch on a value ofDouglas Gregor2011-02-181-0/+1
| | | | | | | | enumeration type, prioritize the enumeration constants and don't provide completions for any other expressions. Fixes <rdar://problem/7283668>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125991 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement code completion results for the Objective-C Key-Value CodingDouglas Gregor2011-02-171-0/+9
| | | | | | | (KVC) and Key-Value Observing (KVO) protocols. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125696 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r124704, which uniqued code-completion strings. The spaceDouglas Gregor2011-02-021-31/+0
| | | | | | | | | | savings of 25% sounds impressive, except that this amounted to only about 360k in our standard "large" completion result set (40,000 results). Since code completion is performance-sensitive, the 4% slowdown due to uniquing outweighs the 360k benefit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124737 91177308-0d34-0410-b5e6-96231b3b80d8
* Unique code-completion strings. On Cocoa.h, this costs us about 4% inDouglas Gregor2011-02-011-0/+31
| | | | | | | speed but saves us about 25% of the memory usage for strings. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124704 91177308-0d34-0410-b5e6-96231b3b80d8
* Create a special allocator class for code completion, so that all ofDouglas Gregor2011-02-011-0/+7
| | | | | | | | the string copying goes through a single place that can have associated state. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124698 91177308-0d34-0410-b5e6-96231b3b80d8
* Allocate CodeCompletionString and all of its components in aDouglas Gregor2011-02-011-106/+31
| | | | | | | | | | | | | BumpPtrAllocator, rather than manually new/delete'ing them. This optimization also allows us to avoid allocating memory for and copying constant strings (e.g., "return", "class"). This also required embedding the priority and availability of results within the code completion string, to avoid extra memory allocation within libclang. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124673 91177308-0d34-0410-b5e6-96231b3b80d8
* Eliminate the (de-)serialization of code completion results, now thatDouglas Gregor2010-10-111-154/+0
| | | | | | | libclang does not support out-of-process code completion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116253 91177308-0d34-0410-b5e6-96231b3b80d8
* Synchronize globally-cached code completion results with the resultsDouglas Gregor2010-09-231-1/+2
| | | | | | | | | | | | | | | provided when the optimization is disabled. In particular, split the completion context CCC_Other into two contexts: CCC_Other, which means that it's an undisclosed context for which any other results are unwelcome, and CCC_Recovery, which is used in recovery cases. Since we're now using the completion context within the completion results builder, make sure that it's always set to something. Fixes <rdar://problem/8470644>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114704 91177308-0d34-0410-b5e6-96231b3b80d8
* Add code completion for C++ constructors wherever we see the class (orDouglas Gregor2010-09-211-0/+40
| | | | | | | class template) and are in a context where we can have a value. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114441 91177308-0d34-0410-b5e6-96231b3b80d8
* Give the Objective-C _cmd an "unlikely" code completion priority; it'sDouglas Gregor2010-09-181-1/+9
| | | | | | | very rarely used. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114286 91177308-0d34-0410-b5e6-96231b3b80d8
* Synchronize code-completion cursor kinds with indexing cursorDouglas Gregor2010-09-031-87/+5
| | | | | | | kinds. How shameful that this code was duplicated! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113033 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify code-completion result sorting a bitDouglas Gregor2010-09-031-8/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112968 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename DeclContext::getLookupContext to getRedeclContext and change its ↵Sebastian Redl2010-08-311-1/+1
| | | | | | semantics slightly. No functionality change in the absence of inline namespaces. Also, change a few places where inline namespaces actually make a difference to be prepared for them. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112563 91177308-0d34-0410-b5e6-96231b3b80d8
* Move the sorting of code-completion results out of the main path andDouglas Gregor2010-08-261-1/+8
| | | | | | | | | | | | into the clients, e.g., the printing code-completion consumer and c-index-test. Clients may want to re-sort the results anyway. Provide a libclang function that sorts the results. 3rd try. How embarrassing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112180 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r112149, "Move the sorting of code-completion results out of the mainDaniel Dunbar2010-08-261-8/+1
| | | | | | path and ...", it is failing tests. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112161 91177308-0d34-0410-b5e6-96231b3b80d8
* Move the sorting of code-completion results out of the main path andDouglas Gregor2010-08-261-1/+8
| | | | | | | | | | into the clients, e.g., the printing code-completion consumer and c-index-test. Clients may want to re-sort the results anyway. Provide a libclang function that sorts the results. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112149 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Move the sorting of code-completion results out of the main path andDouglas Gregor2010-08-261-8/+1
| | | | | | | | into the clients", because the C standard library sucks. Where's my stable sort, huh? git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112121 91177308-0d34-0410-b5e6-96231b3b80d8
* Move the sorting of code-completion results out of the main path andDouglas Gregor2010-08-251-1/+8
| | | | | | | | into the clients, e.g., the printing code-completion consumer and c-index-test. Clients may want to re-sort the results anyway. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112095 91177308-0d34-0410-b5e6-96231b3b80d8
* When combining the code-completion results from Sema long with theDouglas Gregor2010-08-251-0/+56
| | | | | | | | | code-completion results cached by ASTUnit, sort the resulting result set. This makes testing far, far easier, so this commit also includes tests for the previous few fixes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112070 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach Sema to live without CodeCompleteConsumer.h.John McCall2010-08-251-12/+12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112028 91177308-0d34-0410-b5e6-96231b3b80d8
* Move more stuff out of Sema.h.John McCall2010-08-251-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112026 91177308-0d34-0410-b5e6-96231b3b80d8
* Struggle mightily against header inclusion in Sema.h.John McCall2010-08-241-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111904 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce new libclang API functions that determine the availabilityDouglas Gregor2010-08-231-1/+14
| | | | | | | | | of a cursor or code-completion result, e.g., whether that result refers to an unavailable, deleted, or deprecated declaration. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111858 91177308-0d34-0410-b5e6-96231b3b80d8
* Another step in the process of making the parser depend on Sema:John McCall2010-08-201-1/+1
| | | | | | | | | | | - move DeclSpec &c into the Sema library - move ParseAST into the Parse library Reflect this change in a thousand different includes. Reflect this change in the link orders. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111667 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement caching of code-completion results for macro definitionsDouglas Gregor2010-08-131-75/+89
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | when the CXTranslationUnit_CacheCompletionResults option is given to clang_parseTranslationUnit(). Essentially, we compute code-completion results for macro definitions after we have parsed the file, then store an ASTContext-agnostic version of those results (completion string, cursor kind, priority, and active contexts) in the ASTUnit. When performing code completion in that ASTUnit, we splice the macro definition results into the results provided by the actual code-completion (which has had macros turned off) before libclang gets those results. We use completion context information to only splice in those results that make sense for that context. With a completion involving all of the macros from Cocoa.h and a few other system libraries (totally ~8500 macro definitions) living in a precompiled header, we get about a 9% performance improvement from code completion, since we no longer have to deserialize all of the macro definitions from the precompiled header. Note that macro definitions are merely the canary; the cache is designed to also support other top-level declarations, which should be a bigger performance win. That optimization will be next. Note also that there is no mechanism for determining when to throw away the cache and recompute its contents. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111051 91177308-0d34-0410-b5e6-96231b3b80d8