diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/libclang/CIndexCodeCompletion.cpp | 20 | ||||
-rw-r--r-- | tools/libclang/CXCursor.cpp | 10 |
2 files changed, 17 insertions, 13 deletions
diff --git a/tools/libclang/CIndexCodeCompletion.cpp b/tools/libclang/CIndexCodeCompletion.cpp index 95ed3c4843..303fb1f9d5 100644 --- a/tools/libclang/CIndexCodeCompletion.cpp +++ b/tools/libclang/CIndexCodeCompletion.cpp @@ -264,7 +264,8 @@ struct AllocatedCXCodeCompleteResults : public CXCodeCompleteResults { CachedCompletionAllocator; /// \brief Allocator used to store code completion results. - clang::CodeCompletionAllocator CodeCompletionAllocator; + IntrusiveRefCntPtr<clang::GlobalCodeCompletionAllocator> + CodeCompletionAllocator; /// \brief Context under which completion occurred. enum clang::CodeCompletionContext::Kind ContextKind; @@ -300,6 +301,7 @@ AllocatedCXCodeCompleteResults::AllocatedCXCodeCompleteResults( FileSystemOpts(FileSystemOpts), FileMgr(new FileManager(FileSystemOpts)), SourceMgr(new SourceManager(*Diag, *FileMgr)), + CodeCompletionAllocator(new clang::GlobalCodeCompletionAllocator), Contexts(CXCompletionContext_Unknown), ContainerKind(CXCursor_InvalidCode), ContainerUSR(createCXString("")), @@ -503,13 +505,15 @@ static unsigned long long getContextsForContextKind( namespace { class CaptureCompletionResults : public CodeCompleteConsumer { AllocatedCXCodeCompleteResults &AllocatedResults; + CodeCompletionTUInfo CCTUInfo; SmallVector<CXCompletionResult, 16> StoredResults; CXTranslationUnit *TU; public: CaptureCompletionResults(AllocatedCXCodeCompleteResults &Results, CXTranslationUnit *TranslationUnit) : CodeCompleteConsumer(true, false, true, false), - AllocatedResults(Results), TU(TranslationUnit) { } + AllocatedResults(Results), CCTUInfo(Results.CodeCompletionAllocator), + TU(TranslationUnit) { } ~CaptureCompletionResults() { Finish(); } virtual void ProcessCodeCompleteResults(Sema &S, @@ -519,8 +523,8 @@ namespace { StoredResults.reserve(StoredResults.size() + NumResults); for (unsigned I = 0; I != NumResults; ++I) { CodeCompletionString *StoredCompletion - = Results[I].CreateCodeCompletionString(S, - AllocatedResults.CodeCompletionAllocator); + = Results[I].CreateCodeCompletionString(S, getAllocator(), + getCodeCompletionTUInfo()); CXCompletionResult R; R.CursorKind = Results[I].CursorKind; @@ -607,8 +611,8 @@ namespace { StoredResults.reserve(StoredResults.size() + NumCandidates); for (unsigned I = 0; I != NumCandidates; ++I) { CodeCompletionString *StoredCompletion - = Candidates[I].CreateSignatureString(CurrentArg, S, - AllocatedResults.CodeCompletionAllocator); + = Candidates[I].CreateSignatureString(CurrentArg, S, getAllocator(), + getCodeCompletionTUInfo()); CXCompletionResult R; R.CursorKind = CXCursor_NotImplemented; @@ -618,8 +622,10 @@ namespace { } virtual CodeCompletionAllocator &getAllocator() { - return AllocatedResults.CodeCompletionAllocator; + return *AllocatedResults.CodeCompletionAllocator; } + + virtual CodeCompletionTUInfo &getCodeCompletionTUInfo() { return CCTUInfo; } private: void Finish() { diff --git a/tools/libclang/CXCursor.cpp b/tools/libclang/CXCursor.cpp index 84a6ccb07e..0533c84a57 100644 --- a/tools/libclang/CXCursor.cpp +++ b/tools/libclang/CXCursor.cpp @@ -1076,13 +1076,12 @@ CXCompletionString clang_getCursorCompletionString(CXCursor cursor) { Decl *decl = getCursorDecl(cursor); if (NamedDecl *namedDecl = dyn_cast_or_null<NamedDecl>(decl)) { ASTUnit *unit = getCursorASTUnit(cursor); - CodeCompletionAllocator *Allocator - = unit->getCursorCompletionAllocator().getPtr(); CodeCompletionResult Result(namedDecl); CodeCompletionString *String = Result.CreateCodeCompletionString(unit->getASTContext(), unit->getPreprocessor(), - *Allocator); + unit->getCodeCompletionTUInfo().getAllocator(), + unit->getCodeCompletionTUInfo()); return String; } } @@ -1090,13 +1089,12 @@ CXCompletionString clang_getCursorCompletionString(CXCursor cursor) { MacroDefinition *definition = getCursorMacroDefinition(cursor); const IdentifierInfo *MacroInfo = definition->getName(); ASTUnit *unit = getCursorASTUnit(cursor); - CodeCompletionAllocator *Allocator - = unit->getCursorCompletionAllocator().getPtr(); CodeCompletionResult Result(const_cast<IdentifierInfo *>(MacroInfo)); CodeCompletionString *String = Result.CreateCodeCompletionString(unit->getASTContext(), unit->getPreprocessor(), - *Allocator); + unit->getCodeCompletionTUInfo().getAllocator(), + unit->getCodeCompletionTUInfo()); return String; } return NULL; |