mirror of
https://github.com/MaskRay/ccls.git
synced 2025-01-31 09:50:26 +00:00
Clean up some -Wcovered-switch-default default labels
This commit is contained in:
parent
a1e1d115bf
commit
0c4d82667f
@ -163,9 +163,6 @@ StorageClass GetStorageClass(CX_StorageClass storage) {
|
|||||||
return StorageClass::Auto;
|
return StorageClass::Auto;
|
||||||
case CX_SC_Register:
|
case CX_SC_Register:
|
||||||
return StorageClass::Register;
|
return StorageClass::Register;
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
return StorageClass::Invalid;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,11 +96,9 @@ const char* IpcIdToString(IpcId id) {
|
|||||||
return "$cquery/indexFile";
|
return "$cquery/indexFile";
|
||||||
case IpcId::CqueryWait:
|
case IpcId::CqueryWait:
|
||||||
return "$cquery/wait";
|
return "$cquery/wait";
|
||||||
|
|
||||||
default:
|
|
||||||
assert(false && "missing IpcId string name");
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CQUERY_UNREACHABLE("missing IpcId string name");
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseIpcMessage::BaseIpcMessage(IpcId method_id) : method_id(method_id) {}
|
BaseIpcMessage::BaseIpcMessage(IpcId method_id) : method_id(method_id) {}
|
||||||
|
@ -126,6 +126,7 @@ struct TextDocumentDefinitionHandler
|
|||||||
lsLocation result;
|
lsLocation result;
|
||||||
result.uri = lsDocumentUri::FromPath(include.resolved_path);
|
result.uri = lsDocumentUri::FromPath(include.resolved_path);
|
||||||
out.result.push_back(result);
|
out.result.push_back(result);
|
||||||
|
has_symbol = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,6 +136,9 @@ struct TextDocumentDefinitionHandler
|
|||||||
const std::string& buffer = working_file->buffer_content;
|
const std::string& buffer = working_file->buffer_content;
|
||||||
std::string query = LexWordAroundPos(position, buffer);
|
std::string query = LexWordAroundPos(position, buffer);
|
||||||
|
|
||||||
|
// For symbols whose detailed names contain |query| as a substring,
|
||||||
|
// we use the tuple <length difference, not in the same file, line
|
||||||
|
// distance> to find the best match.
|
||||||
std::tuple<int, bool, int> best_score = {INT_MAX, true, 0};
|
std::tuple<int, bool, int> best_score = {INT_MAX, true, 0};
|
||||||
int best_i = -1;
|
int best_i = -1;
|
||||||
for (int i = 0; i < (int)db->symbols.size(); ++i) {
|
for (int i = 0; i < (int)db->symbols.size(); ++i) {
|
||||||
|
10
src/port.cc
Normal file
10
src/port.cc
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include "port.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
void cquery_unreachable_internal(const char* msg, const char* file, int line) {
|
||||||
|
fprintf(stderr, "unreachable %s:%d %s\n", file, line, msg);
|
||||||
|
CQUERY_BUILTIN_UNREACHABLE;
|
||||||
|
abort();
|
||||||
|
}
|
20
src/port.h
20
src/port.h
@ -1,7 +1,27 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef __has_builtin
|
||||||
|
# define __has_builtin(x) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
#define ATTRIBUTE_UNUSED __attribute__((unused))
|
#define ATTRIBUTE_UNUSED __attribute__((unused))
|
||||||
#else
|
#else
|
||||||
#define ATTRIBUTE_UNUSED
|
#define ATTRIBUTE_UNUSED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// TODO GCC
|
||||||
|
#if __has_builtin(__builtin_unreachable)
|
||||||
|
#define CQUERY_BUILTIN_UNREACHABLE __builtin_unreachable()
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
#define CQUERY_BUILTIN_UNREACHABLE __assume(false)
|
||||||
|
#else
|
||||||
|
#define CQUERY_BUILTIN_UNREACHABLE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void cquery_unreachable_internal(const char* msg, const char* file, int line);
|
||||||
|
#ifndef NDEBUG
|
||||||
|
#define CQUERY_UNREACHABLE(msg) cquery_unreachable_internal(msg, __FILE__, __LINE__)
|
||||||
|
#else
|
||||||
|
#define CQUERY_UNREACHABLE(msg)
|
||||||
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user