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

@ -28,8 +28,8 @@ unsigned Flags() {
}
unsigned GetCompletionPriority(const CXCompletionString& str,
CXCursorKind result_kind,
const std::string& label) {
CXCursorKind result_kind,
const std::string& label) {
unsigned priority = clang_getCompletionPriority(str);
// XXX: What happens if priority overflows?
@ -46,14 +46,15 @@ unsigned GetCompletionPriority(const CXCompletionString& str,
return priority;
}
template<typename T>
char *tofixedbase64(T input, char *out) {
const char *digits = "./0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
int len = (sizeof(T)*8-1)/6+1;
for (int i = len-1; i >= 0; i--) {
out[i] = digits[input%64];
template <typename T>
char* tofixedbase64(T input, char* out) {
const char* digits =
"./0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
int len = (sizeof(T) * 8 - 1) / 6 + 1;
for (int i = len - 1; i >= 0; i--) {
out[i] = digits[input % 64];
input /= 64;
}
out[len] = '\0';
@ -450,9 +451,10 @@ void CompletionQueryMain(ClangCompleteManager* completion_manager) {
char buf[16];
ls_completion_item.sortText =
tofixedbase64(GetCompletionPriority(
result.CompletionString, result.CursorKind,
ls_completion_item.label), buf);
tofixedbase64(GetCompletionPriority(result.CompletionString,
result.CursorKind,
ls_completion_item.label),
buf);
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,
int display_diagnostics) {
// llvm::InitializeAllTargets (and possibly others) called by clang_createIndex
// transtively modifies/reads lib/Support/TargetRegistry.cpp FirstTarget.
// There will be a race condition if two threads call clang_createIndex
// concurrently.
// llvm::InitializeAllTargets (and possibly others) called by
// clang_createIndex transtively modifies/reads lib/Support/TargetRegistry.cpp
// FirstTarget. There will be a race condition if two threads call
// clang_createIndex concurrently.
static std::mutex 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) {
// 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_MERGE(name) AddMergeableRange(&name, update.name);