diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-08-16 16:18:59 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-08-16 16:18:59 +0000 |
commit | 1827e10051638770ad9ccf3e285caf95f995afd1 (patch) | |
tree | d9c1f2b06e818607623c4216d4ddd6f5a2df7190 /lib/Frontend/ASTUnit.cpp | |
parent | 6f1bd6674823697516fc169a44adf974123377e2 (diff) |
When caching global completion results, keep track of the simplified
type class, so that we can adjust priorities appropriately when the
preferred type for the context and the actual type of the completion
are similar.
This gets us one step closer to parity of the cached completion
results with the non-cached completion results.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111139 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/ASTUnit.cpp')
-rw-r--r-- | lib/Frontend/ASTUnit.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index 8ac5b681a6..a573fb41ab 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -191,6 +191,10 @@ void ASTUnit::CacheCodeCompletionResults() { Ctx->getLangOptions()); CachedResult.Priority = Results[I].Priority; CachedResult.Kind = Results[I].CursorKind; + CachedResult.TypeClass + = getSimplifiedTypeClass( + Ctx->getCanonicalType(getDeclUsageType(*Ctx, + Results[I].Declaration))); CachedCompletionResults.push_back(CachedResult); break; } @@ -215,6 +219,7 @@ void ASTUnit::CacheCodeCompletionResults() { | (1 << (CodeCompletionContext::CCC_ObjCMessageReceiver - 1)); CachedResult.Priority = Results[I].Priority; CachedResult.Kind = Results[I].CursorKind; + CachedResult.TypeClass = STC_Void; CachedCompletionResults.push_back(CachedResult); break; } @@ -1417,7 +1422,24 @@ namespace { AddedResult = true; } - AllResults.push_back(Result(C->Completion, C->Priority, C->Kind)); + // Adjust priority based on similar type classes. + unsigned Priority = C->Priority; + if (!Context.getPreferredType().isNull()) { + if (C->Kind == CXCursor_MacroDefinition) { + Priority = getMacroUsagePriority(C->Completion->getTypedText(), + Context.getPreferredType()->isAnyPointerType()); + } else { + CanQualType Expected + = S.Context.getCanonicalType(Context.getPreferredType()); + SimplifiedTypeClass ExpectedSTC = getSimplifiedTypeClass(Expected); + if (ExpectedSTC == C->TypeClass) { + // FIXME: How can we check for an exact match? + Priority /= CCF_SimilarTypeMatch; + } + } + } + + AllResults.push_back(Result(C->Completion, Priority, C->Kind)); } // If we did not add any cached completion results, just forward the |