mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-29 02:51:57 +00:00
Fix warnings (almost all numeric cast-related)
This commit is contained in:
parent
e182ac12ae
commit
8910d0a13e
@ -294,11 +294,12 @@ void CompletionQueryMain(CompletionManager* completion_manager) {
|
||||
timer.ResetAndPrint("[complete] Fetching unsaved files");
|
||||
|
||||
timer.Reset();
|
||||
unsigned const kCompleteOptions = CXCodeComplete_IncludeMacros | CXCodeComplete_IncludeBriefComments;
|
||||
CXCodeCompleteResults* cx_results = clang_codeCompleteAt(
|
||||
session->active->cx_tu,
|
||||
session->file.filename.c_str(), line, column,
|
||||
unsaved.data(), unsaved.size(),
|
||||
CXCodeComplete_IncludeMacros | CXCodeComplete_IncludeBriefComments);
|
||||
unsaved.data(), (unsigned)unsaved.size(),
|
||||
kCompleteOptions);
|
||||
if (!cx_results) {
|
||||
std::cerr << "[complete] Code completion failed" << std::endl;
|
||||
request->on_complete({}, {});
|
||||
@ -332,7 +333,7 @@ void CompletionQueryMain(CompletionManager* completion_manager) {
|
||||
ls_completion_item.kind = GetCompletionKind(result.CursorKind);
|
||||
BuildDetailString(result.CompletionString, ls_completion_item.label, ls_completion_item.detail, ls_completion_item.insertText, &ls_completion_item.parameters_);
|
||||
ls_completion_item.documentation = clang::ToString(clang_getCompletionBriefComment(result.CompletionString));
|
||||
ls_completion_item.sortText = uint64_t(GetCompletionPriority(result.CompletionString, result.CursorKind, ls_completion_item.label));
|
||||
ls_completion_item.sortText = (const char)uint64_t(GetCompletionPriority(result.CompletionString, result.CursorKind, ls_completion_item.label));
|
||||
|
||||
// If this function is slow we can skip building insertText at the cost of some code duplication.
|
||||
if (!IsCallKind(result.CursorKind))
|
||||
|
@ -233,7 +233,7 @@ QueryFile* FindFile(QueryDatabase* db, const std::string& filename, QueryFileId*
|
||||
}
|
||||
|
||||
std::cerr << "Unable to find file " << filename << std::endl;
|
||||
*file_id = QueryFileId(-1);
|
||||
*file_id = QueryFileId((size_t)-1);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -1048,15 +1048,15 @@ bool ImportCachedIndex(Config* config,
|
||||
PerformanceImportFile tu_perf;
|
||||
Timer time;
|
||||
|
||||
std::unique_ptr<IndexFile> cache = LoadCachedIndex(config, tu_path);
|
||||
std::unique_ptr<IndexFile> tu_cache = LoadCachedIndex(config, tu_path);
|
||||
tu_perf.index_load_cached = time.ElapsedMicrosecondsAndReset();
|
||||
if (!cache)
|
||||
if (!tu_cache)
|
||||
return true;
|
||||
|
||||
bool needs_reparse = false;
|
||||
|
||||
// Import all dependencies.
|
||||
for (auto& dependency_path : cache->dependencies) {
|
||||
for (auto& dependency_path : tu_cache->dependencies) {
|
||||
//std::cerr << "- Got dependency " << dependency_path << std::endl;
|
||||
PerformanceImportFile perf;
|
||||
time.Reset();
|
||||
@ -1071,11 +1071,11 @@ bool ImportCachedIndex(Config* config,
|
||||
}
|
||||
|
||||
// Import primary file.
|
||||
if (GetLastModificationTime(tu_path) == cache->last_modification_time)
|
||||
if (GetLastModificationTime(tu_path) == tu_cache->last_modification_time)
|
||||
file_consumer_shared->Mark(tu_path);
|
||||
else
|
||||
needs_reparse = true;
|
||||
queue_do_id_map->Enqueue(Index_DoIdMap(std::move(cache), indexed_content, tu_perf, false /*is_interactive*/));
|
||||
queue_do_id_map->Enqueue(Index_DoIdMap(std::move(tu_cache), indexed_content, tu_perf, false /*is_interactive*/));
|
||||
|
||||
return needs_reparse;
|
||||
}
|
||||
@ -1180,9 +1180,9 @@ bool ResetStaleFiles(Config* config,
|
||||
FileConsumer::SharedState* file_consumer_shared,
|
||||
const std::string& tu_path) {
|
||||
Timer time;
|
||||
std::unique_ptr<IndexFile> cache = LoadCachedIndex(config, tu_path);
|
||||
std::unique_ptr<IndexFile> tu_cache = LoadCachedIndex(config, tu_path);
|
||||
|
||||
if (!cache) {
|
||||
if (!tu_cache) {
|
||||
std::cerr << "[indexer] Unable to load existing index from file when freshening (dependences will not be freshened)" << std::endl;
|
||||
file_consumer_shared->Mark(tu_path);
|
||||
return true;
|
||||
@ -1191,7 +1191,7 @@ bool ResetStaleFiles(Config* config,
|
||||
bool needs_reparse = false;
|
||||
|
||||
// Check dependencies
|
||||
for (auto& dependency_path : cache->dependencies) {
|
||||
for (auto& dependency_path : tu_cache->dependencies) {
|
||||
std::unique_ptr<IndexFile> cache = LoadCachedIndex(config, dependency_path);
|
||||
if (GetLastModificationTime(cache->path) != cache->last_modification_time) {
|
||||
needs_reparse = true;
|
||||
@ -1200,7 +1200,7 @@ bool ResetStaleFiles(Config* config,
|
||||
}
|
||||
|
||||
// Check primary file
|
||||
if (GetLastModificationTime(tu_path) != cache->last_modification_time) {
|
||||
if (GetLastModificationTime(tu_path) != tu_cache->last_modification_time) {
|
||||
needs_reparse = true;
|
||||
file_consumer_shared->Mark(tu_path);
|
||||
}
|
||||
@ -2188,7 +2188,7 @@ bool QueryDbMainLoop(
|
||||
}
|
||||
if (start == buffer_line_content->size())
|
||||
continue;
|
||||
int end = buffer_line_content->size();
|
||||
int end = (int)buffer_line_content->size();
|
||||
while (end > 0) {
|
||||
char c = (*buffer_line_content)[end];
|
||||
if (c == '"' || c == '>')
|
||||
@ -2297,7 +2297,7 @@ bool QueryDbMainLoop(
|
||||
if (!func)
|
||||
continue;
|
||||
|
||||
int offset = 0;
|
||||
int16_t offset = 0;
|
||||
|
||||
std::vector<QueryFuncRef> base_callers = GetCallersForAllBaseFunctions(db, *func);
|
||||
std::vector<QueryFuncRef> derived_callers = GetCallersForAllDerivedFunctions(db, *func);
|
||||
|
@ -17,7 +17,7 @@ std::string ElideLongPath(Config* config, const std::string& path) {
|
||||
if (path.size() <= config->includeCompletionMaximumPathLength)
|
||||
return path;
|
||||
|
||||
int start = path.size() - config->includeCompletionMaximumPathLength;
|
||||
size_t start = path.size() - config->includeCompletionMaximumPathLength;
|
||||
return ".." + path.substr(start + 2);
|
||||
}
|
||||
|
||||
@ -27,8 +27,8 @@ size_t TrimCommonPathPrefix(const std::string& result, const std::string& trimme
|
||||
char a = result[i];
|
||||
char b = trimmer[i];
|
||||
#if defined(_WIN32)
|
||||
a = tolower(a);
|
||||
b = tolower(b);
|
||||
a = (char)tolower(a);
|
||||
b = (char)tolower(b);
|
||||
#endif
|
||||
if (a != b)
|
||||
break;
|
||||
|
@ -34,8 +34,8 @@ Range Resolve(const CXSourceRange& range, CXFile* cx_file = nullptr) {
|
||||
clang_getSpellingLocation(end, nullptr, &end_line, &end_column, nullptr);
|
||||
|
||||
return Range(
|
||||
Position(start_line, start_column) /*start*/,
|
||||
Position(end_line, end_column) /*end*/);
|
||||
Position((int16_t)start_line, (int16_t)start_column) /*start*/,
|
||||
Position((int16_t)end_line, (int16_t)end_column) /*end*/);
|
||||
}
|
||||
|
||||
Range ResolveSpelling(const CXCursor& cx_cursor, CXFile* cx_file = nullptr) {
|
||||
@ -685,7 +685,6 @@ clang::VisiterResult AddDeclInitializerUsagesVisitor(clang::Cursor cursor,
|
||||
|
||||
switch (cursor.get_kind()) {
|
||||
case CXCursor_DeclRefExpr:
|
||||
CXCursorKind referenced_kind = cursor.get_referenced().get_kind();
|
||||
if (cursor.get_referenced().get_kind() != CXCursor_VarDecl)
|
||||
break;
|
||||
|
||||
@ -1173,7 +1172,7 @@ void indexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
|
||||
optional<IndexTypeId> parent_type_id =
|
||||
ResolveToDeclarationType(db, base_class->cursor);
|
||||
// type_def ptr could be invalidated by ResolveToDeclarationType.
|
||||
IndexType* type_def = db->Resolve(type_id);
|
||||
type_def = db->Resolve(type_id);
|
||||
if (parent_type_id) {
|
||||
IndexType* parent_type_def =
|
||||
db->Resolve(parent_type_id.value());
|
||||
|
@ -91,7 +91,7 @@ struct Ref {
|
||||
Ref() {} // For serialization.
|
||||
|
||||
Ref(Id<T> id, Range loc) : id_(id), loc(loc) {}
|
||||
Ref(Range loc) : id_(Id<T>(-1)), loc(loc) {}
|
||||
Ref(Range loc) : id_(Id<T>((size_t)-1)), loc(loc) {}
|
||||
|
||||
bool operator==(const Ref<T>& other) {
|
||||
return id_ == other.id_ && loc == other.loc;
|
||||
|
@ -103,10 +103,10 @@ MessageRegistry* MessageRegistry::instance() {
|
||||
|
||||
void lsResponseError::Write(Writer& visitor) {
|
||||
auto& value = *this;
|
||||
int code = static_cast<int>(this->code);
|
||||
int code2 = static_cast<int>(this->code);
|
||||
|
||||
visitor.StartObject();
|
||||
REFLECT_MEMBER2("code", code);
|
||||
REFLECT_MEMBER2("code", code2);
|
||||
REFLECT_MEMBER(message);
|
||||
if (data) {
|
||||
visitor.Key("data");
|
||||
|
@ -203,6 +203,7 @@ std::string Cursor::get_type_description() const {
|
||||
auto type = clang_getCursorType(cx_cursor);
|
||||
return clang::ToString(clang_getTypeSpelling(type));
|
||||
|
||||
#if false
|
||||
std::string spelling;
|
||||
|
||||
auto referenced = clang_getCursorReferenced(cx_cursor);
|
||||
@ -244,6 +245,7 @@ std::string Cursor::get_type_description() const {
|
||||
return get_spelling();
|
||||
|
||||
return spelling;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if false
|
||||
|
@ -27,8 +27,8 @@ TranslationUnit::TranslationUnit(Index& index,
|
||||
|
||||
//CXErrorCode error_code = clang_parseTranslationUnit2FullArgv(
|
||||
CXErrorCode error_code = clang_parseTranslationUnit2(
|
||||
index.cx_index, filepath.c_str(), args.data(), args.size(),
|
||||
unsaved_files.data(), unsaved_files.size(), flags, &cx_tu);
|
||||
index.cx_index, filepath.c_str(), args.data(), (int)args.size(),
|
||||
unsaved_files.data(), (unsigned)unsaved_files.size(), flags, &cx_tu);
|
||||
|
||||
switch (error_code) {
|
||||
case CXError_Success:
|
||||
@ -61,7 +61,7 @@ TranslationUnit::~TranslationUnit() {
|
||||
void TranslationUnit::ReparseTranslationUnit(
|
||||
std::vector<CXUnsavedFile>& unsaved) {
|
||||
int error_code =
|
||||
clang_reparseTranslationUnit(cx_tu, unsaved.size(), unsaved.data(),
|
||||
clang_reparseTranslationUnit(cx_tu, (unsigned)unsaved.size(), unsaved.data(),
|
||||
clang_defaultReparseOptions(cx_tu));
|
||||
switch (error_code) {
|
||||
case CXError_Success:
|
||||
|
@ -62,7 +62,7 @@ void MakeDirectoryRecursive(std::string path) {
|
||||
|
||||
// Find first parent directory which doesn't exist.
|
||||
int first_success = -1;
|
||||
for (int i = components.size(); i > 0; --i) {
|
||||
for (int i = (int)components.size(); i > 0; --i) {
|
||||
if (TryMakeDirectory(prefix + Join(components, '/', i))) {
|
||||
first_success = i;
|
||||
break;
|
||||
|
@ -81,7 +81,7 @@ struct PlatformSharedMemoryWin : public PlatformSharedMemory {
|
||||
this->name = name;
|
||||
|
||||
shmem_ = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0,
|
||||
capacity, name.c_str());
|
||||
(DWORD)capacity, name.c_str());
|
||||
CheckForError({ ERROR_ALREADY_EXISTS } /*allow*/);
|
||||
|
||||
data = MapViewOfFile(shmem_, FILE_MAP_ALL_ACCESS, 0, 0, capacity);
|
||||
@ -133,7 +133,6 @@ std::string GetWorkingDirectory() {
|
||||
|
||||
std::string NormalizePath(const std::string& path) {
|
||||
DWORD retval = 0;
|
||||
BOOL success = false;
|
||||
TCHAR buffer[MAX_PATH] = TEXT("");
|
||||
TCHAR buf[MAX_PATH] = TEXT("");
|
||||
TCHAR** lpp_part = { NULL };
|
||||
@ -172,7 +171,7 @@ void SetCurrentThreadName(const std::string& thread_name) {
|
||||
THREADNAME_INFO info;
|
||||
info.dwType = 0x1000;
|
||||
info.szName = thread_name.c_str();
|
||||
info.dwThreadID = -1;
|
||||
info.dwThreadID = (DWORD)-1;
|
||||
info.dwFlags = 0;
|
||||
|
||||
__try {
|
||||
|
@ -12,16 +12,16 @@ const char* SkipAfter(const char* input, char skip_after) {
|
||||
|
||||
Position::Position() {}
|
||||
|
||||
Position::Position(int32_t line, int32_t column)
|
||||
Position::Position(int16_t line, int16_t column)
|
||||
: line(line), column(column) {}
|
||||
|
||||
Position::Position(const char* encoded) {
|
||||
assert(encoded);
|
||||
line = atoi(encoded);
|
||||
line = (int16_t)atoi(encoded);
|
||||
|
||||
encoded = SkipAfter(encoded, ':');
|
||||
assert(encoded);
|
||||
column = atoi(encoded);
|
||||
column = (int16_t)atoi(encoded);
|
||||
}
|
||||
|
||||
std::string Position::ToString() {
|
||||
@ -78,19 +78,19 @@ Range::Range(Position start, Position end) : start(start), end(end) {}
|
||||
Range::Range(const char* encoded) {
|
||||
end = start;
|
||||
|
||||
start.line = atoi(encoded);
|
||||
start.line = (int16_t)atoi(encoded);
|
||||
|
||||
encoded = SkipAfter(encoded, ':');
|
||||
assert(encoded);
|
||||
start.column = atoi(encoded);
|
||||
start.column = (int16_t)atoi(encoded);
|
||||
|
||||
encoded = SkipAfter(encoded, '-');
|
||||
assert(encoded);
|
||||
end.line = atoi(encoded);
|
||||
end.line = (int16_t)atoi(encoded);
|
||||
|
||||
encoded = SkipAfter(encoded, ':');
|
||||
assert(encoded);
|
||||
end.column = atoi(encoded);
|
||||
end.column = (int16_t)atoi(encoded);
|
||||
}
|
||||
|
||||
bool Range::Contains(int line, int column) const {
|
||||
|
@ -11,7 +11,7 @@ struct Position {
|
||||
int16_t column = -1;
|
||||
|
||||
Position();
|
||||
Position(int32_t line, int32_t column);
|
||||
Position(int16_t line, int16_t column);
|
||||
explicit Position(const char* encoded);
|
||||
|
||||
std::string ToString();
|
||||
|
@ -287,8 +287,8 @@ std::vector<Project::Entry> LoadCompilationEntriesFromDirectory(
|
||||
|
||||
unsigned num_args = clang_CompileCommand_getNumArgs(cx_command);
|
||||
entry.args.reserve(num_args);
|
||||
for (unsigned i = 0; i < num_args; ++i)
|
||||
entry.args.push_back(clang::ToString(clang_CompileCommand_getArg(cx_command, i)));
|
||||
for (unsigned j = 0; j < num_args; ++j)
|
||||
entry.args.push_back(clang::ToString(clang_CompileCommand_getArg(cx_command, j)));
|
||||
|
||||
result.push_back(GetCompilationEntryFromCompileCommandEntry(quote_includes, angle_includes, extra_flags, entry));
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ QueryTypeId IdMap::ToQuery(IndexTypeId id) const {
|
||||
return QueryTypeId(cached_type_ids_.find(id)->second);
|
||||
}
|
||||
QueryFuncId IdMap::ToQuery(IndexFuncId id) const {
|
||||
if (id.id == -1) return QueryFuncId(-1);
|
||||
if (id.id == -1) return QueryFuncId((size_t)-1);
|
||||
assert(cached_func_ids_.find(id) != cached_func_ids_.end());
|
||||
return QueryFuncId(cached_func_ids_.find(id)->second);
|
||||
}
|
||||
|
12
src/query.h
12
src/query.h
@ -37,7 +37,7 @@ struct QueryLocation {
|
||||
QueryLocation(QueryFileId path, Range range)
|
||||
: path(path), range(range) {}
|
||||
|
||||
QueryLocation OffsetStartColumn(int offset) const {
|
||||
QueryLocation OffsetStartColumn(int16_t offset) const {
|
||||
QueryLocation result = *this;
|
||||
result.range.start.column += offset;
|
||||
return result;
|
||||
@ -65,7 +65,7 @@ struct SymbolIdx {
|
||||
SymbolKind kind;
|
||||
size_t idx;
|
||||
|
||||
SymbolIdx() : kind(SymbolKind::Invalid), idx(-1) {} // Default ctor needed by stdlib. Do not use.
|
||||
SymbolIdx() : kind(SymbolKind::Invalid), idx((size_t)-1) {} // Default ctor needed by stdlib. Do not use.
|
||||
SymbolIdx(SymbolKind kind, uint64_t idx) : kind(kind), idx(idx) {}
|
||||
|
||||
bool operator==(const SymbolIdx& that) const {
|
||||
@ -172,7 +172,7 @@ struct QueryFile {
|
||||
using DefUpdate = Def;
|
||||
|
||||
DefUpdate def;
|
||||
size_t detailed_name_idx = -1;
|
||||
size_t detailed_name_idx = (size_t)-1;
|
||||
|
||||
QueryFile(const std::string& path) { def.path = path; }
|
||||
};
|
||||
@ -188,7 +188,7 @@ struct QueryType {
|
||||
std::vector<QueryTypeId> derived;
|
||||
std::vector<QueryVarId> instances;
|
||||
std::vector<QueryLocation> uses;
|
||||
size_t detailed_name_idx = -1;
|
||||
size_t detailed_name_idx = (size_t)-1;
|
||||
|
||||
QueryType(const Usr& usr) : def(usr) {}
|
||||
};
|
||||
@ -203,7 +203,7 @@ struct QueryFunc {
|
||||
std::vector<QueryLocation> declarations;
|
||||
std::vector<QueryFuncId> derived;
|
||||
std::vector<QueryFuncRef> callers;
|
||||
size_t detailed_name_idx = -1;
|
||||
size_t detailed_name_idx = (size_t)-1;
|
||||
|
||||
QueryFunc(const Usr& usr) : def(usr) {}
|
||||
};
|
||||
@ -214,7 +214,7 @@ struct QueryVar {
|
||||
|
||||
DefUpdate def;
|
||||
std::vector<QueryLocation> uses;
|
||||
size_t detailed_name_idx = -1;
|
||||
size_t detailed_name_idx = (size_t)-1;
|
||||
|
||||
QueryVar(const Usr& usr) : def(usr) {}
|
||||
};
|
||||
|
@ -8,7 +8,7 @@ bool gTestOutputMode = false;
|
||||
|
||||
// int16_t
|
||||
void Reflect(Reader& visitor, int16_t& value) {
|
||||
value = visitor.GetInt();
|
||||
value = (int16_t)visitor.GetInt();
|
||||
}
|
||||
void Reflect(Writer& visitor, int16_t& value) {
|
||||
visitor.Int(value);
|
||||
|
@ -193,7 +193,7 @@ void RunTests() {
|
||||
std::cout << "[Enter to continue - type u to update test, a to update all]";
|
||||
char c = 'u';
|
||||
if (!update_all) {
|
||||
c = std::cin.get();
|
||||
c = (char)std::cin.get();
|
||||
std::cin.get();
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ namespace {
|
||||
|
||||
lsPosition GetPositionForOffset(const std::string& content, int offset) {
|
||||
if (offset >= content.size())
|
||||
offset = content.size() - 1;
|
||||
offset = (int)content.size() - 1;
|
||||
|
||||
lsPosition result;
|
||||
int i = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user