aboutsummaryrefslogtreecommitdiff
path: root/clang/tools/libclang/CIndexCodeCompletion.cpp
AgeCommit message (Collapse)AuthorFilesLines
2014-08-27Update for LLVM api change.Rafael Espindola1-2/+2
llvm-svn: 216585
2014-07-07libclang: refactor handling of unsaved_filesAlp Toker1-14/+13
Consolidate CXUnsavedFile argument handling in API functions to support a wider cleanup of various file remapping schemes in the frontend. llvm-svn: 212427
2014-06-27Remove 'const' from MemoryBuffers used through the SourceManagerDavid Blaikie1-2/+2
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. llvm-svn: 211915
2014-06-08[C++11] Use 'nullptr'. Tools edition.Craig Topper1-15/+15
llvm-svn: 210422
2014-05-09Don't leak the CXStoredDiagnostics returned by clang_codeCompleteGetDiagnostic()Nico Weber1-2/+12
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. llvm-svn: 208454
2014-04-15Honour -ivfsoverlay in ASTUnit to match clangBen Langmuir1-19/+12
This allows code indexing, etc. to use the VFS in the same way as the compiler. llvm-svn: 206309
2014-03-15[C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper1-13/+13
class. llvm-svn: 204002
2014-03-02[C++11] Use std::atomic instead of LLVM's.Benjamin Kramer1-10/+8
No intended functionality change. llvm-svn: 202652
2014-02-11Fix a typo in the function name that I just introduced (r201155)Dmitri Gribenko1-1/+1
llvm-svn: 201156
2014-02-11libclang: audit all APIs that accept a CXTranslationUnit to make sure thatDmitri Gribenko1-1/+6
checks for invalid translation unit are in place. Also, while there, add log output for this case. llvm-svn: 201155
2014-02-07ASTUnit: ArrayRef'ize RemappedFilesDmitri Gribenko1-1/+1
llvm-svn: 200975
2013-09-13Remove unnecessary inclusion of Sema.hDavid Blaikie1-0/+1
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. llvm-svn: 190715
2013-06-26Don't use PathV1.h in CIndexCodeCompletion.cpp.Rafael Espindola1-3/+3
llvm-svn: 184940
2013-06-18Simplify a loop in ProcessCodeCompleteResults(). Pointed out by David BlaikieDmitri Gribenko1-6/+6
llvm-svn: 184169
2013-06-18ArrayRef'ize CodeCompletionContext::getNumSelIdents()Dmitri Gribenko1-8/+6
llvm-svn: 184168
2013-06-13Use the sys::ExecuteAndWait that takes StringRefs.Rafael Espindola1-0/+1
Also don't depend on Program.h including PathV1.h. llvm-svn: 183935
2013-02-07libclang: reduce CXString abuseDmitri Gribenko1-25/+20
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. llvm-svn: 174647
2013-02-03libclang: remove 'using namespace cxstring'Dmitri Gribenko1-1/+0
llvm-svn: 174285
2013-02-02libclang: introduce cxstring::{createRef,createDup} for StringRefsDmitri Gribenko1-2/+2
Also migrate all clients from the old API. llvm-svn: 174263
2013-02-02libclang: introduce cxstring::{createRef,createDup} for C stringsDmitri Gribenko1-6/+5
Also migrate all clients from the old API. llvm-svn: 174238
2013-02-01libclang: itroduce cxstring::createEmpty()Dmitri Gribenko1-5/+5
llvm-svn: 174174
2013-02-01libclang: introduce cxstring::createNull()Dmitri Gribenko1-4/+4
llvm-svn: 174173
2013-01-26libclang: type safety for CXTranslationUnitImpl::CIdxDmitri Gribenko1-1/+1
llvm-svn: 173590
2013-01-26libclang: factor out the frequent pattern static_cast<ASTUnit *>(TU->TUData)Dmitri Gribenko1-2/+2
into a getter cxtu::getASTUnit(TU) llvm-svn: 173585
2013-01-19Re-sort all the headers. Lots of regressions have crept in here.Chandler Carruth1-1/+1
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. llvm-svn: 172892
2013-01-10[libclang] Enhance logging capabilities of libclang.Argyrios Kyrtzidis1-0/+7
-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. llvm-svn: 172089
2013-01-02Re-sort #include lines using the llvm/utils/sort_includes.py script.Chandler Carruth1-1/+0
Removes a duplicate #include as well as cleaning up some sort order regressions since I last ran the script over Clang. llvm-svn: 171364
2012-12-22[libclang] Check for the 'LIBCLANG_NOTHREADS' environment variable before ↵Argyrios Kyrtzidis1-0/+6
creating a separate thread for code-completion. llvm-svn: 170978
2012-12-04Sort #include lines for tools/...Chandler Carruth1-7/+7
Completely automated with sort_includes.py llvm-svn: 169240
2012-11-22Make helpers static/anonymous.Benjamin Kramer1-1/+4
llvm-svn: 168500
2012-10-23Make DiagnosticOptions intrusively reference-counted, and make sureDouglas Gregor1-1/+5
the various stakeholders bump up the reference count. In particular, the diagnostics engine now keeps the DiagnosticOptions object alive. llvm-svn: 166508
2012-09-26[libclang] Remove the ParentKind cursor kind from code-completion results.Argyrios Kyrtzidis1-2/+0
This is to reduce dependency to cursors for the code-completion results. llvm-svn: 164705
2012-07-02Add a new libclang completion API to get brief documentation comment that isDmitri Gribenko1-4/+21
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). llvm-svn: 159539
2012-04-10[code-complete] Introduce CodeCompletionTUInfo which will be used for cachingArgyrios Kyrtzidis1-7/+13
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. llvm-svn: 154408
2012-03-28[libclang] Rename setBackGroundPriority -> setThreadBackgroundPriority.Argyrios Kyrtzidis1-1/+1
llvm-svn: 153566
2012-03-28[libclang] Introduce options to control the priority for the threadsArgyrios Kyrtzidis1-0/+4
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 llvm-svn: 153562
2012-03-27Introduce a new libclang API to determine the parent context of a codeDouglas Gregor1-1/+15
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>. llvm-svn: 153545
2012-03-11Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie1-5/+5
(Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
2012-02-20Basic: import IntrusiveRefCntPtr<> into clang namespaceDylan Noblesmith1-5/+5
The class name is long enough without the llvm:: added. Also bring in RefCountedBase and RefCountedBaseVPTR. llvm-svn: 150958
2012-02-13drop more llvm:: prefixes on SmallString<>Dylan Noblesmith1-6/+6
More cleanup after r149799. llvm-svn: 150380
2012-01-20More dead code removal (using -Wunreachable-code)David Blaikie1-2/+1
llvm-svn: 148577
2012-01-17Remove unreachable code in Clang. (replace with llvm_unreachable where ↵David Blaikie1-4/+2
appropriate or when GCC requires it) llvm-svn: 148292
2011-10-14Added clang_getCompletionAnnotation and clang_getCompletionNumAnnotations toErik Verbruggen1-0/+14
retrieve annotations from completion string. llvm-svn: 141953
2011-10-10Make sure we initialize the "extra" data within the libclang codeDouglas Gregor1-1/+6
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. llvm-svn: 141598
2011-09-25Rename Diagnostic to DiagnosticsEngine as per issue 5397David Blaikie1-2/+2
llvm-svn: 140478
2011-08-17[libclang] Workaround potential race condition with code completion ↵Ted Kremenek1-0/+13
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. llvm-svn: 137887
2011-07-30When performing code completion after at @interface, allow bothDouglas Gregor1-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>. llvm-svn: 136559
2011-07-26Eliminate a bunch of temporary strings.Benjamin Kramer1-1/+1
llvm-svn: 136092
2011-07-26Add new libclang API, clang_codeCompleteGetObjCSelector(), whichDouglas Gregor1-2/+31
provides the partial Objective-C selector used in a code completion. From Connor Wakamo! llvm-svn: 136084
2011-07-23remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner1-11/+11
LLVM.h imports them into the clang namespace. llvm-svn: 135852