summaryrefslogtreecommitdiff
path: root/tools/libclang/CIndexCodeCompletion.cpp
Commit message (Collapse)AuthorAge
* Remove 'const' from MemoryBuffers used through the SourceManagerDavid Blaikie2014-06-27
| | | | | | | | | | | | | | This removes a const_cast added in r211884 that occurred due to an inconsistency in how MemoryBuffers are handled between some parts of clang and LLVM. MemoryBuffers are immutable and the general convention in the LLVM project is to omit const from immutable types as it's simply redundant/verbose (see llvm::Type, for example). While this change doesn't remove "const" from /every/ MemoryBuffer, it at least makes this chain of ownership/usage consistent. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211915 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Use 'nullptr'. Tools edition.Craig Topper2014-06-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210422 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't leak the CXStoredDiagnostics returned by clang_codeCompleteGetDiagnostic()Nico Weber2014-05-09
| | | | | | | | | | | | | | | | | | r144269 changed clang_disposeDiagnostic() to be a no-op, but didn't update code completion diagnostics. Let CXCodeCompleteResults store all diagnostics returned by clang_codeCompleteGetDiagnostic() and then free them up in clang_disposeCodeCompleteResults(). Code completion diagnostics referred to data stored in CXCodeCompleteResults before already, so it wasn't possible to refer to the results of clang_codeCompleteGetDiagnostic() after clang_disposeCodeCompleteResults() before this change already -- hence this should be a safe, backwards-compatible change. Leak found by LSan, fixes PR19690. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208454 91177308-0d34-0410-b5e6-96231b3b80d8
* Honour -ivfsoverlay in ASTUnit to match clangBen Langmuir2014-04-15
| | | | | | | This allows code indexing, etc. to use the VFS in the same way as the compiler. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206309 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-15
| | | | | | class. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204002 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Use std::atomic instead of LLVM's.Benjamin Kramer2014-03-02
| | | | | | No intended functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202652 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a typo in the function name that I just introduced (r201155)Dmitri Gribenko2014-02-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201156 91177308-0d34-0410-b5e6-96231b3b80d8
* libclang: audit all APIs that accept a CXTranslationUnit to make sure thatDmitri Gribenko2014-02-11
| | | | | | | | checks for invalid translation unit are in place. Also, while there, add log output for this case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201155 91177308-0d34-0410-b5e6-96231b3b80d8
* ASTUnit: ArrayRef'ize RemappedFilesDmitri Gribenko2014-02-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200975 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove unnecessary inclusion of Sema.hDavid Blaikie2013-09-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Let me tell you a tale... Within some twisted maze of debug info I've ended up implementing an insane man's Include What You Use device. When the debugger emits debug info it really shouldn't, I find out why & then realize the code could be improved too. In this instance CIndexDiagnostics.cpp had a lot more debug info with Clang than GCC. Upon inspection a major culprit was all the debug info describing clang::Sema. This was emitted because clang::Sema is befriended by DiagnosticEngine which was rightly required, but GCC doesn't emit debug info for friends so it never emitted anything for Clang. Clang does emit debug info for friends (will be fixed/changed to reduce debug info size). But why didn't Clang just emit a declaration of Sema if this entire TU didn't require a definition? 1) Diagnostic.h did the right thing, only using a declaration of Sema and not including Sema.h at all. 2) Some other dependency of CIndexDiagnostics.cpp didn't do the right thing. ASTUnit.h, only needing a declaration, still included Sema.h (hence this commit which removes that include and adds the necessary includes to the cpp files that were relying on this) 3) -flimit-debug-info didn't save us because of EnterExpressionEvaluationContext, defined inline in Sema.h which fires the "requiresCompleteType" check/flag (since it uses nested types from Sema and calls Sema member functions) and thus, if debug info is ever emitted for the type, the whole type is emitted and not just a declaration. Improving -flimit-debug-info to account for this would be... hard. Modifying the code so that's not 'required to be complete' might be possible, but probably only by moving EnterExpressionEvaluationContext either into Sema, or out of Sema.h. That might be a bit too much of a contortion to be bothered with. Also, this is only one of the cases where emitting debug info for friends caused us to emit a lot more debug info (this change reduces Clang's DWO size by 0.93%, dropping friends entirely reduces debug info by 3.2%) - I haven't hunted down the other cases, but I assume they might be similar (Sema or something like it). IWYU or a similar tool might help us reduce build times a bit, but analyzing debug info to find these differences isn't worthwhile. I'll take the 3.2% win, provide this small improvement to the code itself, and move on. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190715 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't use PathV1.h in CIndexCodeCompletion.cpp.Rafael Espindola2013-06-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184940 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify a loop in ProcessCodeCompleteResults(). Pointed out by David BlaikieDmitri Gribenko2013-06-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184169 91177308-0d34-0410-b5e6-96231b3b80d8
* ArrayRef'ize CodeCompletionContext::getNumSelIdents()Dmitri Gribenko2013-06-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184168 91177308-0d34-0410-b5e6-96231b3b80d8
* Use the sys::ExecuteAndWait that takes StringRefs.Rafael Espindola2013-06-13
| | | | | | Also don't depend on Program.h including PathV1.h. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183935 91177308-0d34-0410-b5e6-96231b3b80d8
* libclang: reduce CXString abuseDmitri Gribenko2013-02-07
| | | | | | | | | | ContainerUSR is not really a CXString, but it should own the underlying memory buffer. Thus, it is better to change the type to std::string. This will not introduce extra copying overhead, since the workaround that is being removed was already making a copy. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174647 91177308-0d34-0410-b5e6-96231b3b80d8
* libclang: remove 'using namespace cxstring'Dmitri Gribenko2013-02-03
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174285 91177308-0d34-0410-b5e6-96231b3b80d8
* libclang: introduce cxstring::{createRef,createDup} for StringRefsDmitri Gribenko2013-02-02
| | | | | | | Also migrate all clients from the old API. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174263 91177308-0d34-0410-b5e6-96231b3b80d8
* libclang: introduce cxstring::{createRef,createDup} for C stringsDmitri Gribenko2013-02-02
| | | | | | | Also migrate all clients from the old API. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174238 91177308-0d34-0410-b5e6-96231b3b80d8
* libclang: itroduce cxstring::createEmpty()Dmitri Gribenko2013-02-01
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174174 91177308-0d34-0410-b5e6-96231b3b80d8
* libclang: introduce cxstring::createNull()Dmitri Gribenko2013-02-01
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174173 91177308-0d34-0410-b5e6-96231b3b80d8
* libclang: type safety for CXTranslationUnitImpl::CIdxDmitri Gribenko2013-01-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173590 91177308-0d34-0410-b5e6-96231b3b80d8
* libclang: factor out the frequent pattern static_cast<ASTUnit *>(TU->TUData)Dmitri Gribenko2013-01-26
| | | | | | | into a getter cxtu::getASTUnit(TU) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173585 91177308-0d34-0410-b5e6-96231b3b80d8
* Re-sort all the headers. Lots of regressions have crept in here.Chandler Carruth2013-01-19
| | | | | | | | | | Manually fix the order of UnwrappedLineParser.cpp as that one didn't have its associated header as the first header. This also uncovered a subtle inclusion order dependency as CLog.h didn't include LLVM.h to pick up using declarations it relied upon. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172892 91177308-0d34-0410-b5e6-96231b3b80d8
* [libclang] Enhance logging capabilities of libclang.Argyrios Kyrtzidis2013-01-10
| | | | | | | | | -provide a "raw_ostream'ish" class to make it convenient to output logging info. -use macros to automate a bit the logging functionality inside libclang functions -when logging, print a stack trace if "LIBCLANG_LOGGING=2" environment is set. -add logging to more functions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172089 91177308-0d34-0410-b5e6-96231b3b80d8
* Re-sort #include lines using the llvm/utils/sort_includes.py script.Chandler Carruth2013-01-02
| | | | | | | Removes a duplicate #include as well as cleaning up some sort order regressions since I last ran the script over Clang. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171364 91177308-0d34-0410-b5e6-96231b3b80d8
* [libclang] Check for the 'LIBCLANG_NOTHREADS' environment variable before ↵Argyrios Kyrtzidis2012-12-22
| | | | | | | | creating a separate thread for code-completion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170978 91177308-0d34-0410-b5e6-96231b3b80d8
* Sort #include lines for tools/...Chandler Carruth2012-12-04
| | | | | | Completely automated with sort_includes.py git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169240 91177308-0d34-0410-b5e6-96231b3b80d8
* Make helpers static/anonymous.Benjamin Kramer2012-11-22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168500 91177308-0d34-0410-b5e6-96231b3b80d8
* Make DiagnosticOptions intrusively reference-counted, and make sureDouglas Gregor2012-10-23
| | | | | | | | the various stakeholders bump up the reference count. In particular, the diagnostics engine now keeps the DiagnosticOptions object alive. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166508 91177308-0d34-0410-b5e6-96231b3b80d8
* [libclang] Remove the ParentKind cursor kind from code-completion results.Argyrios Kyrtzidis2012-09-26
| | | | | | 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-02
| | | | | | | | | | | | | | | | | | 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
* [code-complete] Introduce CodeCompletionTUInfo which will be used for cachingArgyrios Kyrtzidis2012-04-10
| | | | | | | | | | | | | | | | | | | 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
* [libclang] Rename setBackGroundPriority -> setThreadBackgroundPriority.Argyrios Kyrtzidis2012-03-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153566 91177308-0d34-0410-b5e6-96231b3b80d8
* [libclang] Introduce options to control the priority for the threadsArgyrios Kyrtzidis2012-03-28
| | | | | | | | | | | | | | | | | | | | | | that libclang creates. -Introduce CXGlobalOptFlags enum for the new options that can be set on the CXIndex object. -CXGlobalOpt_ThreadBackgroundPriorityForIndexing affects: clang_indexSourceFile clang_indexTranslationUnit clang_parseTranslationUnit clang_saveTranslationUnit -CXGlobalOpt_ThreadBackgroundPriorityForEditing affects: clang_reparseTranslationUnit clang_codeCompleteAt clang_annotateTokens rdar://9075282 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153562 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce a new libclang API to determine the parent context of a codeDouglas Gregor2012-03-27
| | | | | | | | | | 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
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-11
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152536 91177308-0d34-0410-b5e6-96231b3b80d8
* Basic: import IntrusiveRefCntPtr<> into clang namespaceDylan Noblesmith2012-02-20
| | | | | | | The class name is long enough without the llvm:: added. Also bring in RefCountedBase and RefCountedBaseVPTR. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150958 91177308-0d34-0410-b5e6-96231b3b80d8
* drop more llvm:: prefixes on SmallString<>Dylan Noblesmith2012-02-13
| | | | | | More cleanup after r149799. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150380 91177308-0d34-0410-b5e6-96231b3b80d8
* More dead code removal (using -Wunreachable-code)David Blaikie2012-01-20
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148577 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove unreachable code in Clang. (replace with llvm_unreachable where ↵David Blaikie2012-01-17
| | | | | | appropriate or when GCC requires it) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148292 91177308-0d34-0410-b5e6-96231b3b80d8
* Added clang_getCompletionAnnotation and clang_getCompletionNumAnnotations toErik Verbruggen2011-10-14
| | | | | | | retrieve annotations from completion string. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141953 91177308-0d34-0410-b5e6-96231b3b80d8
* Make sure we initialize the "extra" data within the libclang codeDouglas Gregor2011-10-10
| | | | | | | | | | completion context, in case we end up having no code-completion callback. Individual instances of this problem are always bugs that need to be fixed, but it's better to make sure we have initialized data here. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141598 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename Diagnostic to DiagnosticsEngine as per issue 5397David Blaikie2011-09-25
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140478 91177308-0d34-0410-b5e6-96231b3b80d8
* [libclang] Workaround potential race condition with code completion ↵Ted Kremenek2011-08-17
| | | | | | | | | AllocatedResults being freed after a CXTranslationUnit. The Container USR's CXString had its underlying data owned by the CXTranslationUnit's string pool. This would result in trying to access freed memory. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137887 91177308-0d34-0410-b5e6-96231b3b80d8
* When performing code completion after at @interface, allow bothDouglas Gregor2011-07-30
| | | | | | | | | 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
* Eliminate a bunch of temporary strings.Benjamin Kramer2011-07-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136092 91177308-0d34-0410-b5e6-96231b3b80d8
* Add new libclang API, clang_codeCompleteGetObjCSelector(), whichDouglas Gregor2011-07-26
| | | | | | | | provides the partial Objective-C selector used in a code completion. From Connor Wakamo! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136084 91177308-0d34-0410-b5e6-96231b3b80d8
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-23
| | | | | | | | | 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
* New libclang API to expose container type for code completion, fromDouglas Gregor2011-07-21
| | | | | | | Connor Wakamo! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135651 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce a new libclang aPI function,Douglas Gregor2011-07-07
| | | | | | | | | | 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