This commit is contained in:
Jacob Dufault 2017-12-07 11:53:48 -08:00
parent d8d794fb4e
commit 4a7ca6168f
3 changed files with 20 additions and 18 deletions

View File

@ -46,14 +46,15 @@ unsigned GetCompletionPriority(const CXCompletionString& str,
return priority; return priority;
} }
template<typename T> template <typename T>
char *tofixedbase64(T input, char *out) { char* tofixedbase64(T input, char* out) {
const char *digits = "./0123456789" const char* digits =
"./0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"; "abcdefghijklmnopqrstuvwxyz";
int len = (sizeof(T)*8-1)/6+1; int len = (sizeof(T) * 8 - 1) / 6 + 1;
for (int i = len-1; i >= 0; i--) { for (int i = len - 1; i >= 0; i--) {
out[i] = digits[input%64]; out[i] = digits[input % 64];
input /= 64; input /= 64;
} }
out[len] = '\0'; out[len] = '\0';
@ -450,9 +451,10 @@ void CompletionQueryMain(ClangCompleteManager* completion_manager) {
char buf[16]; char buf[16];
ls_completion_item.sortText = ls_completion_item.sortText =
tofixedbase64(GetCompletionPriority( tofixedbase64(GetCompletionPriority(result.CompletionString,
result.CompletionString, result.CursorKind, result.CursorKind,
ls_completion_item.label), buf); ls_completion_item.label),
buf);
ls_result.push_back(ls_completion_item); ls_result.push_back(ls_completion_item);
} }

View File

@ -6,10 +6,10 @@ ClangIndex::ClangIndex() : ClangIndex(1, 0) {}
ClangIndex::ClangIndex(int exclude_declarations_from_pch, ClangIndex::ClangIndex(int exclude_declarations_from_pch,
int display_diagnostics) { int display_diagnostics) {
// llvm::InitializeAllTargets (and possibly others) called by clang_createIndex // llvm::InitializeAllTargets (and possibly others) called by
// transtively modifies/reads lib/Support/TargetRegistry.cpp FirstTarget. // clang_createIndex transtively modifies/reads lib/Support/TargetRegistry.cpp
// There will be a race condition if two threads call clang_createIndex // FirstTarget. There will be a race condition if two threads call
// concurrently. // clang_createIndex concurrently.
static std::mutex mutex_; static std::mutex mutex_;
std::lock_guard<std::mutex> lock(mutex_); std::lock_guard<std::mutex> lock(mutex_);

View File

@ -618,7 +618,7 @@ IndexUpdate::IndexUpdate(const IdMap& previous_id_map,
} }
void IndexUpdate::Merge(const IndexUpdate& update) { void IndexUpdate::Merge(const IndexUpdate& update) {
// This function runs on an indexer thread. // This function runs on an indexer thread.
#define INDEX_UPDATE_APPEND(name) AddRange(&name, update.name); #define INDEX_UPDATE_APPEND(name) AddRange(&name, update.name);
#define INDEX_UPDATE_MERGE(name) AddMergeableRange(&name, update.name); #define INDEX_UPDATE_MERGE(name) AddMergeableRange(&name, update.name);