diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2010-05-27 15:17:06 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2010-05-27 15:17:06 +0000 |
commit | 53992adde3eda3ccf9da63bc7e45673f043de18f (patch) | |
tree | 3558f327a6f9ab59c5d7a06528d84e1560445247 /lib/Sema/CodeCompleteConsumer.cpp | |
parent | 7e411337c0ed226dace6e07f1420486768161308 (diff) | |
download | FreeBSD-src-53992adde3eda3ccf9da63bc7e45673f043de18f.zip FreeBSD-src-53992adde3eda3ccf9da63bc7e45673f043de18f.tar.gz |
Update clang to r104832.
Diffstat (limited to 'lib/Sema/CodeCompleteConsumer.cpp')
-rw-r--r-- | lib/Sema/CodeCompleteConsumer.cpp | 67 |
1 files changed, 34 insertions, 33 deletions
diff --git a/lib/Sema/CodeCompleteConsumer.cpp b/lib/Sema/CodeCompleteConsumer.cpp index 0ef9a15..6cefc61 100644 --- a/lib/Sema/CodeCompleteConsumer.cpp +++ b/lib/Sema/CodeCompleteConsumer.cpp @@ -210,9 +210,10 @@ CodeCompletionString::Chunk::Destroy() { } } -CodeCompletionString::~CodeCompletionString() { +void CodeCompletionString::clear() { std::for_each(Chunks.begin(), Chunks.end(), std::mem_fun_ref(&Chunk::Destroy)); + Chunks.clear(); } std::string CodeCompletionString::getAsString() const { @@ -310,15 +311,13 @@ void CodeCompletionString::Serialize(llvm::raw_ostream &OS) const { } } -CodeCompletionString *CodeCompletionString::Deserialize(const char *&Str, - const char *StrEnd) { +bool CodeCompletionString::Deserialize(const char *&Str, const char *StrEnd) { if (Str == StrEnd || *Str == 0) - return 0; + return false; - CodeCompletionString *Result = new CodeCompletionString; unsigned NumBlocks; if (ReadUnsigned(Str, StrEnd, NumBlocks)) - return Result; + return false; for (unsigned I = 0; I != NumBlocks; ++I) { if (Str + 1 >= StrEnd) @@ -327,7 +326,7 @@ CodeCompletionString *CodeCompletionString::Deserialize(const char *&Str, // Parse the next kind. unsigned KindValue; if (ReadUnsigned(Str, StrEnd, KindValue)) - return Result; + return false; switch (ChunkKind Kind = (ChunkKind)KindValue) { case CK_TypedText: @@ -338,16 +337,17 @@ CodeCompletionString *CodeCompletionString::Deserialize(const char *&Str, case CK_CurrentParameter: { unsigned StrLen; if (ReadUnsigned(Str, StrEnd, StrLen) || (Str + StrLen > StrEnd)) - return Result; + return false; - Result->AddChunk(Chunk(Kind, StringRef(Str, StrLen))); + AddChunk(Chunk(Kind, StringRef(Str, StrLen))); Str += StrLen; break; } case CK_Optional: { - std::auto_ptr<CodeCompletionString> Optional(Deserialize(Str, StrEnd)); - Result->AddOptionalChunk(Optional); + std::auto_ptr<CodeCompletionString> Optional(new CodeCompletionString()); + if (Optional->Deserialize(Str, StrEnd)) + AddOptionalChunk(Optional); break; } @@ -365,12 +365,12 @@ CodeCompletionString *CodeCompletionString::Deserialize(const char *&Str, case CK_Equal: case CK_HorizontalSpace: case CK_VerticalSpace: - Result->AddChunk(Chunk(Kind)); + AddChunk(Chunk(Kind)); break; } }; - return Result; + return true; } void CodeCompleteConsumer::Result::Destroy() { @@ -380,6 +380,25 @@ void CodeCompleteConsumer::Result::Destroy() { } } +unsigned CodeCompleteConsumer::Result::getPriorityFromDecl(NamedDecl *ND) { + if (!ND) + return CCP_Unlikely; + + // Context-based decisions. + DeclContext *DC = ND->getDeclContext()->getLookupContext(); + if (DC->isFunctionOrMethod() || isa<BlockDecl>(DC)) + return CCP_LocalDeclaration; + if (DC->isRecord() || isa<ObjCContainerDecl>(DC)) + return CCP_MemberDeclaration; + + // Content-based decisions. + if (isa<EnumConstantDecl>(ND)) + return CCP_Constant; + if (isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND)) + return CCP_Type; + return CCP_Declaration; +} + //===----------------------------------------------------------------------===// // Code completion overload candidate implementation //===----------------------------------------------------------------------===// @@ -459,11 +478,6 @@ PrintingCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &SemaRef, } } } - - // Once we've printed the code-completion results, suppress remaining - // diagnostics. - // FIXME: Move this somewhere else! - SemaRef.PP.getDiagnostics().setSuppressAllDiagnostics(); } void @@ -478,11 +492,6 @@ PrintingCodeCompleteConsumer::ProcessOverloadCandidates(Sema &SemaRef, delete CCS; } } - - // Once we've printed the code-completion results, suppress remaining - // diagnostics. - // FIXME: Move this somewhere else! - SemaRef.PP.getDiagnostics().setSuppressAllDiagnostics(); } void @@ -594,16 +603,12 @@ CIndexCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &SemaRef, } WriteUnsigned(OS, Kind); + WriteUnsigned(OS, Results[I].Priority); CodeCompletionString *CCS = Results[I].CreateCodeCompletionString(SemaRef); assert(CCS && "No code-completion string?"); CCS->Serialize(OS); delete CCS; } - - // Once we've printed the code-completion results, suppress remaining - // diagnostics. - // FIXME: Move this somewhere else! - SemaRef.PP.getDiagnostics().setSuppressAllDiagnostics(); } void @@ -613,15 +618,11 @@ CIndexCodeCompleteConsumer::ProcessOverloadCandidates(Sema &SemaRef, unsigned NumCandidates) { for (unsigned I = 0; I != NumCandidates; ++I) { WriteUnsigned(OS, CXCursor_NotImplemented); + WriteUnsigned(OS, /*Priority=*/0); CodeCompletionString *CCS = Candidates[I].CreateSignatureString(CurrentArg, SemaRef); assert(CCS && "No code-completion string?"); CCS->Serialize(OS); delete CCS; } - - // Once we've printed the code-completion results, suppress remaining - // diagnostics. - // FIXME: Move this somewhere else! - SemaRef.PP.getDiagnostics().setSuppressAllDiagnostics(); } |