summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/CodeCompleteConsumer.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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. llvm-svn: 135852
* 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! llvm-svn: 134615
* 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. llvm-svn: 128127
* 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>. llvm-svn: 125991
* Implement code completion results for the Objective-C Key-Value CodingDouglas Gregor2011-02-171-0/+9
| | | | | | (KVC) and Key-Value Observing (KVO) protocols. llvm-svn: 125696
* 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. llvm-svn: 124737
* 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. llvm-svn: 124704
* 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. llvm-svn: 124698
* 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. llvm-svn: 124673
* Eliminate the (de-)serialization of code completion results, now thatDouglas Gregor2010-10-111-154/+0
| | | | | | libclang does not support out-of-process code completion. llvm-svn: 116253
* 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>. llvm-svn: 114704
* 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. llvm-svn: 114441
* Give the Objective-C _cmd an "unlikely" code completion priority; it'sDouglas Gregor2010-09-181-1/+9
| | | | | | very rarely used. llvm-svn: 114286
* Synchronize code-completion cursor kinds with indexing cursorDouglas Gregor2010-09-031-87/+5
| | | | | | kinds. How shameful that this code was duplicated! llvm-svn: 113033
* Simplify code-completion result sorting a bitDouglas Gregor2010-09-031-8/+0
| | | | llvm-svn: 112968
* 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. llvm-svn: 112563
* 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. llvm-svn: 112180
* Revert r112149, "Move the sorting of code-completion results out of the mainDaniel Dunbar2010-08-261-8/+1
| | | | | | path and ...", it is failing tests. llvm-svn: 112161
* 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. llvm-svn: 112149
* 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? llvm-svn: 112121
* 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. llvm-svn: 112095
* 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. llvm-svn: 112070
* Teach Sema to live without CodeCompleteConsumer.h.John McCall2010-08-251-12/+12
| | | | llvm-svn: 112028
* Move more stuff out of Sema.h.John McCall2010-08-251-0/+1
| | | | llvm-svn: 112026
* Struggle mightily against header inclusion in Sema.h.John McCall2010-08-241-0/+1
| | | | llvm-svn: 111904
* 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. llvm-svn: 111858
* 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. llvm-svn: 111667
* 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. llvm-svn: 111051
* Move Sema's headers into include/clang/Sema, renaming a few along the way.Douglas Gregor2010-08-121-1/+1
| | | | llvm-svn: 110945
* Once code completion has completed, pass a "completion context" on toDouglas Gregor2010-08-111-0/+2
| | | | | | | the code-completion consumer. The consumer can use this information to augument, filter, or display the code-completion results. llvm-svn: 110858
* Add code-completion support directly to ASTUnit, which performs codeDouglas Gregor2010-08-041-54/+46
| | | | | | | | | | | | | | completion within the translation unit using the same command-line arguments for parsing the translation unit. Eventually, we'll reuse the precompiled preamble to improve code-completion performance, and this also gives us a place to cache results. Expose this function via the new libclang function clang_codeCompleteAt(), which performs the code completion within a CXTranslationUnit. The completion occurs in-process (clang_codeCompletion() runs code completion out-of-process). llvm-svn: 110210
* Minor code simplification.Dan Gohman2010-07-261-2/+1
| | | | llvm-svn: 109443
* Introduce priorities into the code-completion results.Douglas Gregor2010-05-261-13/+34
| | | | llvm-svn: 104751
* Improve code completion in failure cases in two ways:Douglas Gregor2010-05-251-20/+0
| | | | | | | | | | | 1) Suppress diagnostics as soon as we form the code-completion token, so we don't get any error/warning spew from the early end-of-file. 2) If we consume a code-completion token when we weren't expecting one, go into a code-completion recovery path that produces the best results it can based on the context that the parser is in. llvm-svn: 104585
* Add raw_ostream operators to NamedDecl for convenience. Switch over all ↵Benjamin Kramer2010-04-171-1/+1
| | | | | | | | users of getNameAsString on a stream. The next step is to print the name directly into the stream, avoiding a temporary std::string copy. llvm-svn: 101632
* Implement code completion for Objective-C method declarations andDouglas Gregor2010-04-071-1/+1
| | | | | | | | | | | | | | | | 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
* Code completion results that refer to macros now get the cursor kindDouglas Gregor2010-04-051-2/+5
| | | | | | | of macro definitions when passed to CIndex. Add test for code completion of macros via CIndex. llvm-svn: 100431
* Remove unused headers.Duncan Sands2010-03-081-1/+0
| | | | llvm-svn: 97941
* Eliminate cursor kinds used to express definitions. Instead, provideDouglas Gregor2010-01-191-2/+2
| | | | | | | | | | | | CIndex functions that (1) map from a reference or declaration to the corresponding definition, if available, and (2) determine whether a given declaration cursor is also a definition. This eliminates a lot of duplication in the cursor kinds, and maps more closely to the Clang ASTs. This is another API + ABI breaker with no deprecation. Yay, progress. llvm-svn: 93893
* Improve the sorting of code-completion results. We now always sort byDouglas Gregor2010-01-131-6/+5
| | | | | | | | 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
* Improve code completion by introducing patterns for the various C andDouglas Gregor2010-01-101-0/+40
| | | | | | | | | | | | | | | | | | | | | | 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
* Extend code-completion results with the type of each resultDouglas Gregor2009-12-181-1/+16
| | | | llvm-svn: 91702
* 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
* Switch the clang-to-CIndex interface for code-completion to a binary format, ↵Douglas Gregor2009-12-011-319/+172
| | | | | | for a massive speedup llvm-svn: 90209
* Remove remaining VISIBILITY_HIDDEN from anonymous namespaces.Benjamin Kramer2009-11-281-1/+0
| | | | llvm-svn: 90044
* Improve code-completion results for the flags in an @propertyDouglas Gregor2009-11-191-0/+61
| | | | | | | | | declaration by providing patterns for "getter = <method>" and "setter = <method>". As part of this, invented a new "pattern" result kind that is merely a semantic string. The "pattern" result kind should help with other kinds of code templates. llvm-svn: 89277
* StringRef'ify CodeCompletionStringDouglas Gregor2009-11-171-4/+6
| | | | llvm-svn: 89102
* Rework Sema code completion interface.Daniel Dunbar2009-11-131-4/+8
| | | | | | | | | | | | | - Provide Sema in callbacks, instead of requiring it in constructor. This eliminates the need for a factory function. Clients now just pass the object to consume the results in directly. - CodeCompleteConsumer is cheap to construct, so building it whenever we are doing code completion is reasonable. Doug, please review. llvm-svn: 87099
* Spell empty StringRef correctly (0 is a null StringRef, which is not the same).Daniel Dunbar2009-11-121-1/+1
| | | | llvm-svn: 87011
* Various improvements to Clang's code-completion infrastructure:Douglas Gregor2009-11-071-8/+465
| | | | | | | | | | | | | | - Introduce more code-completion string "chunk" kinds that describe symbols, the actual text that the user is expected to type, etc. - Make the generation of macro results optional, since it can be slow - Make code-completion accessible through the C API, marshalling the code-completion results through a temporary file (ick) to maintain process separation. The last doesn't have tests yet. llvm-svn: 86306
OpenPOWER on IntegriCloud