mirror of
https://github.com/MaskRay/ccls.git
synced 2025-06-10 18:22:14 +00:00
Fix some MSVC 2017 errors
Thanks Dso Tsin!
This commit is contained in:
parent
0f2bef0f3f
commit
f132745f6d
@ -45,7 +45,8 @@ static Pos Decomposed2LineAndCol(const SourceManager &SM,
|
|||||||
std::pair<FileID, unsigned> I) {
|
std::pair<FileID, unsigned> I) {
|
||||||
int l = SM.getLineNumber(I.first, I.second) - 1,
|
int l = SM.getLineNumber(I.first, I.second) - 1,
|
||||||
c = SM.getColumnNumber(I.first, I.second) - 1;
|
c = SM.getColumnNumber(I.first, I.second) - 1;
|
||||||
return {(int16_t)std::min(l, INT16_MAX), (int16_t)std::min(c, INT16_MAX)};
|
return {(int16_t)std::min<int>(l, INT16_MAX),
|
||||||
|
(int16_t)std::min<int>(c, INT16_MAX)};
|
||||||
}
|
}
|
||||||
|
|
||||||
Range FromCharSourceRange(const SourceManager &SM, const LangOptions &LangOpts,
|
Range FromCharSourceRange(const SourceManager &SM, const LangOptions &LangOpts,
|
||||||
|
@ -18,6 +18,7 @@ limitations under the License.
|
|||||||
#include "log.hh"
|
#include "log.hh"
|
||||||
#include "serializers/json.hh"
|
#include "serializers/json.hh"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
namespace ccls {
|
namespace ccls {
|
||||||
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
|
|
||||||
#include "serializer.hh"
|
#include "serializer.hh"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -57,14 +58,10 @@ Range Range::FromString(const std::string &encoded) {
|
|||||||
bool Range::Contains(int line, int column) const {
|
bool Range::Contains(int line, int column) const {
|
||||||
if (line > INT16_MAX)
|
if (line > INT16_MAX)
|
||||||
return false;
|
return false;
|
||||||
Pos p{int16_t(line), int16_t(std::min(column, INT16_MAX))};
|
Pos p{(int16_t)line, (int16_t)std::min<int>(column, INT16_MAX)};
|
||||||
return !(p < start) && p < end;
|
return !(p < start) && p < end;
|
||||||
}
|
}
|
||||||
|
|
||||||
Range Range::RemovePrefix(Pos position) const {
|
|
||||||
return {std::min(std::max(position, start), end), end};
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Range::ToString() {
|
std::string Range::ToString() {
|
||||||
char buf[99];
|
char buf[99];
|
||||||
snprintf(buf, sizeof buf, "%d:%d-%d:%d", start.line + 1, start.column + 1,
|
snprintf(buf, sizeof buf, "%d:%d-%d:%d", start.line + 1, start.column + 1,
|
||||||
|
@ -52,7 +52,6 @@ struct Range {
|
|||||||
|
|
||||||
bool Valid() const { return start.Valid(); }
|
bool Valid() const { return start.Valid(); }
|
||||||
bool Contains(int line, int column) const;
|
bool Contains(int line, int column) const;
|
||||||
Range RemovePrefix(Pos position) const;
|
|
||||||
|
|
||||||
std::string ToString();
|
std::string ToString();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user