mirror of
				https://github.com/MaskRay/ccls.git
				synced 2025-10-31 04:32:33 +00:00 
			
		
		
		
	This commit fixes severak compiler errors when trying to build cquery. I gave up after a bit and didn't fix them all though, there are a ton of signed to unsigned comparisons.
This commit is contained in:
		
							parent
							
								
									0376da015f
								
							
						
					
					
						commit
						3f45c05476
					
				| @ -483,7 +483,7 @@ LruSessionCache::LruSessionCache(int max_entries) : max_entries_(max_entries) {} | |||||||
| 
 | 
 | ||||||
| std::shared_ptr<CompletionSession> LruSessionCache::TryGetEntry( | std::shared_ptr<CompletionSession> LruSessionCache::TryGetEntry( | ||||||
|     const std::string& filename) { |     const std::string& filename) { | ||||||
|   for (int i = 0; i < entries_.size(); ++i) { |   for (size_t i = 0; i < entries_.size(); ++i) { | ||||||
|     if (entries_[i]->file.filename == filename) |     if (entries_[i]->file.filename == filename) | ||||||
|       return entries_[i]; |       return entries_[i]; | ||||||
|   } |   } | ||||||
| @ -492,7 +492,7 @@ std::shared_ptr<CompletionSession> LruSessionCache::TryGetEntry( | |||||||
| 
 | 
 | ||||||
| std::shared_ptr<CompletionSession> LruSessionCache::TryTakeEntry( | std::shared_ptr<CompletionSession> LruSessionCache::TryTakeEntry( | ||||||
|     const std::string& filename) { |     const std::string& filename) { | ||||||
|   for (int i = 0; i < entries_.size(); ++i) { |   for (size_t i = 0; i < entries_.size(); ++i) { | ||||||
|     if (entries_[i]->file.filename == filename) { |     if (entries_[i]->file.filename == filename) { | ||||||
|       std::shared_ptr<CompletionSession> result = entries_[i]; |       std::shared_ptr<CompletionSession> result = entries_[i]; | ||||||
|       entries_.erase(entries_.begin() + i); |       entries_.erase(entries_.begin() + i); | ||||||
|  | |||||||
| @ -132,7 +132,9 @@ inline void Reflect(Writer& visitor, IndexFuncRef& value) { | |||||||
| 
 | 
 | ||||||
|   if (value.is_implicit) |   if (value.is_implicit) | ||||||
|     s += "~"; |     s += "~"; | ||||||
|   if (value.id.id == -1) {  // id.id is unsigned, special case 0 value
 | 
 | ||||||
|  |   // id.id is unsigned, special case 0 value
 | ||||||
|  |   if (static_cast<ssize_t>(value.id.id) == -1) { | ||||||
|     s += "-1"; |     s += "-1"; | ||||||
|   } else { |   } else { | ||||||
|     s += std::to_string(value.id.id); |     s += std::to_string(value.id.id); | ||||||
|  | |||||||
| @ -240,12 +240,12 @@ std::string lsDocumentUri::GetPath() const { | |||||||
|   result = ReplaceAll(result, "%29", ")"); |   result = ReplaceAll(result, "%29", ")"); | ||||||
| 
 | 
 | ||||||
|   size_t index = result.find("%3A"); |   size_t index = result.find("%3A"); | ||||||
|   if (index != -1) { |   if (index != std::string::npos) { | ||||||
|     result.replace(result.begin() + index, result.begin() + index + 3, ":"); |     result.replace(result.begin() + index, result.begin() + index + 3, ":"); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   index = result.find("file://"); |   index = result.find("file://"); | ||||||
|   if (index != -1) { |   if (index != std::string::npos) { | ||||||
| // TODO: proper fix
 | // TODO: proper fix
 | ||||||
| #if defined(_WIN32) | #if defined(_WIN32) | ||||||
|     result.replace(result.begin() + index, result.begin() + index + 8, ""); |     result.replace(result.begin() + index, result.begin() + index + 8, ""); | ||||||
|  | |||||||
| @ -11,7 +11,7 @@ int GetOffsetForPosition(lsPosition position, const std::string& content) { | |||||||
|   int offset = 0; |   int offset = 0; | ||||||
| 
 | 
 | ||||||
|   int remaining_lines = position.line; |   int remaining_lines = position.line; | ||||||
|   while (remaining_lines > 0 && offset < content.size()) { |   while (remaining_lines > 0 && offset < static_cast<int>(content.size())) { | ||||||
|     if (content[offset] == '\n') |     if (content[offset] == '\n') | ||||||
|       --remaining_lines; |       --remaining_lines; | ||||||
|     ++offset; |     ++offset; | ||||||
|  | |||||||
| @ -28,10 +28,11 @@ std::vector<std::string> Split(const std::string& s, char delim) { | |||||||
|   return elems; |   return elems; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::string Join(const std::vector<std::string>& entries, char delim, int end) { | std::string Join(const std::vector<std::string>& entries, char delim, | ||||||
|  |                  size_t end) { | ||||||
|   std::string result; |   std::string result; | ||||||
|   bool first = true; |   bool first = true; | ||||||
|   for (int i = 0; i < end; ++i) { |   for (size_t i = 0; i < end; ++i) { | ||||||
|     if (!first) |     if (!first) | ||||||
|       result += delim; |       result += delim; | ||||||
|     first = false; |     first = false; | ||||||
| @ -62,7 +63,8 @@ void MakeDirectoryRecursive(std::string path) { | |||||||
| 
 | 
 | ||||||
|   // Find first parent directory which doesn't exist.
 |   // Find first parent directory which doesn't exist.
 | ||||||
|   int first_success = -1; |   int first_success = -1; | ||||||
|   for (int i = (int)components.size(); i > 0; --i) { |   for (size_t j = 0; j < components.size(); ++j) { | ||||||
|  |     size_t i = components.size() - j; | ||||||
|     if (TryMakeDirectory(prefix + Join(components, '/', i))) { |     if (TryMakeDirectory(prefix + Join(components, '/', i))) { | ||||||
|       first_success = i; |       first_success = i; | ||||||
|       break; |       break; | ||||||
| @ -76,7 +78,7 @@ void MakeDirectoryRecursive(std::string path) { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   // Make all child directories.
 |   // Make all child directories.
 | ||||||
|   for (int i = first_success + 1; i <= components.size(); ++i) { |   for (size_t i = first_success + 1; i <= components.size(); ++i) { | ||||||
|     if (TryMakeDirectory(prefix + Join(components, '/', i)) == false) { |     if (TryMakeDirectory(prefix + Join(components, '/', i)) == false) { | ||||||
|       std::cerr << "Failed making directory for " << path |       std::cerr << "Failed making directory for " << path | ||||||
|                 << " even after creating parent directories" << std::endl; |                 << " even after creating parent directories" << std::endl; | ||||||
|  | |||||||
| @ -157,7 +157,7 @@ std::string GetWorkingDirectory() { | |||||||
| std::string NormalizePath(const std::string& path) { | std::string NormalizePath(const std::string& path) { | ||||||
|   errno = 0; |   errno = 0; | ||||||
|   char name[PATH_MAX + 1]; |   char name[PATH_MAX + 1]; | ||||||
|   realpath(path.c_str(), name); |   (void) realpath(path.c_str(), name); | ||||||
|   if (errno) |   if (errno) | ||||||
|     return path; |     return path; | ||||||
|   return name; |   return name; | ||||||
|  | |||||||
| @ -110,7 +110,7 @@ struct QueryFuncRef { | |||||||
|   QueryLocation loc; |   QueryLocation loc; | ||||||
|   bool is_implicit = false; |   bool is_implicit = false; | ||||||
| 
 | 
 | ||||||
|   bool has_id() const { return id_.id != -1; } |   bool has_id() const { return static_cast<ssize_t>(id_.id) != -1; } | ||||||
| 
 | 
 | ||||||
|   QueryFuncRef() {}  // Do not use, needed for reflect.
 |   QueryFuncRef() {}  // Do not use, needed for reflect.
 | ||||||
|   QueryFuncRef(QueryFuncId id, QueryLocation loc, bool is_implicit) |   QueryFuncRef(QueryFuncId id, QueryLocation loc, bool is_implicit) | ||||||
|  | |||||||
| @ -180,7 +180,7 @@ template <typename T> | |||||||
| void Reflect(Reader& visitor, optional<T>& value) { | void Reflect(Reader& visitor, optional<T>& value) { | ||||||
|   if (visitor.IsNull()) |   if (visitor.IsNull()) | ||||||
|     return; |     return; | ||||||
|   T real_value; |   T real_value{}; | ||||||
|   Reflect(visitor, real_value); |   Reflect(visitor, real_value); | ||||||
|   value = real_value; |   value = real_value; | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user