mirror of
https://github.com/MaskRay/ccls.git
synced 2025-06-07 08:44:55 +00:00
Convert llvm::StringRef -> std::string from implicit to explicit
A change in llvm 11 changed the llvm::StringRef API to disable implicit casts from llvm::StringRef to std::string. Convert all calls here to the explicit API.
This commit is contained in:
parent
1834f8195b
commit
65464cb4a4
@ -21,7 +21,7 @@ std::string pathFromFileEntry(const FileEntry &file) {
|
|||||||
StringRef name = file.tryGetRealPathName();
|
StringRef name = file.tryGetRealPathName();
|
||||||
if (name.empty())
|
if (name.empty())
|
||||||
name = file.getName();
|
name = file.getName();
|
||||||
std::string ret = normalizePath(name);
|
std::string ret = normalizePath(name.str());
|
||||||
// Resolve symlinks outside of workspace folders, e.g. /usr/include/c++/7.3.0
|
// Resolve symlinks outside of workspace folders, e.g. /usr/include/c++/7.3.0
|
||||||
return normalizeFolder(ret) ? ret : realPath(ret);
|
return normalizeFolder(ret) ? ret : realPath(ret);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,8 @@ void getFilesInFolder(std::string folder, bool recursive, bool dir_prefix,
|
|||||||
curr.pop_back();
|
curr.pop_back();
|
||||||
for (sys::fs::directory_iterator i(folder1, ec, false), e; i != e && !ec;
|
for (sys::fs::directory_iterator i(folder1, ec, false), e; i != e && !ec;
|
||||||
i.increment(ec)) {
|
i.increment(ec)) {
|
||||||
std::string path = i->path(), filename = sys::path::filename(path);
|
std::string path = i->path(),
|
||||||
|
filename = sys::path::filename(path).str();
|
||||||
if ((filename[0] == '.' && filename != ".ccls") ||
|
if ((filename[0] == '.' && filename != ".ccls") ||
|
||||||
sys::fs::status(path, status, false))
|
sys::fs::status(path, status, false))
|
||||||
continue;
|
continue;
|
||||||
|
@ -508,7 +508,7 @@ public:
|
|||||||
llvm::raw_svector_ostream os(str);
|
llvm::raw_svector_ostream os(str);
|
||||||
d->print(os, getDefaultPolicy());
|
d->print(os, getDefaultPolicy());
|
||||||
|
|
||||||
std::string name = os.str();
|
std::string name = os.str().str();
|
||||||
simplifyAnonymous(name);
|
simplifyAnonymous(name);
|
||||||
// Remove \n in DeclPrinter.cpp "{\n" + if(!TerseOutput)something + "}"
|
// Remove \n in DeclPrinter.cpp "{\n" + if(!TerseOutput)something + "}"
|
||||||
for (std::string::size_type i = 0;;) {
|
for (std::string::size_type i = 0;;) {
|
||||||
|
@ -140,7 +140,7 @@ int main(int argc, char **argv) {
|
|||||||
if (opt_index.size()) {
|
if (opt_index.size()) {
|
||||||
SmallString<256> root(opt_index);
|
SmallString<256> root(opt_index);
|
||||||
sys::fs::make_absolute(root);
|
sys::fs::make_absolute(root);
|
||||||
pipeline::standalone(root.str());
|
pipeline::standalone(root.str().str());
|
||||||
} else {
|
} else {
|
||||||
// The thread that reads from stdin and dispatchs commands to the main
|
// The thread that reads from stdin and dispatchs commands to the main
|
||||||
// thread.
|
// thread.
|
||||||
|
@ -297,7 +297,7 @@ void do_initialize(MessageHandler *m, InitializeParam ¶m,
|
|||||||
SmallString<256> path(g_config->cache.directory);
|
SmallString<256> path(g_config->cache.directory);
|
||||||
sys::fs::make_absolute(project_path, path);
|
sys::fs::make_absolute(project_path, path);
|
||||||
// Use upper case for the Driver letter on Windows.
|
// Use upper case for the Driver letter on Windows.
|
||||||
g_config->cache.directory = normalizePath(path.str());
|
g_config->cache.directory = normalizePath(path.str().str());
|
||||||
ensureEndsInSlash(g_config->cache.directory);
|
ensureEndsInSlash(g_config->cache.directory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ bool cacheInvalid(VFS *vfs, IndexFile *prev, const std::string &path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For inferred files, allow -o a a.cc -> -o b b.cc
|
// For inferred files, allow -o a a.cc -> -o b b.cc
|
||||||
std::string stem = sys::path::stem(path);
|
std::string stem = sys::path::stem(path).str();
|
||||||
int changed = -1, size = std::min(prev->args.size(), args.size());
|
int changed = -1, size = std::min(prev->args.size(), args.size());
|
||||||
for (int i = 0; i < size; i++)
|
for (int i = 0; i < size; i++)
|
||||||
if (strcmp(prev->args[i], args[i]) && sys::path::stem(args[i]) != stem) {
|
if (strcmp(prev->args[i], args[i]) && sys::path::stem(args[i]) != stem) {
|
||||||
|
@ -226,7 +226,7 @@ readCompilerArgumentsFromFile(const std::string &path) {
|
|||||||
return {};
|
return {};
|
||||||
std::vector<const char *> args;
|
std::vector<const char *> args;
|
||||||
for (line_iterator i(*mbOrErr.get(), true, '#'), e; i != e; ++i) {
|
for (line_iterator i(*mbOrErr.get(), true, '#'), e; i != e; ++i) {
|
||||||
std::string line = *i;
|
std::string line = i->str();
|
||||||
doPathMapping(line);
|
doPathMapping(line);
|
||||||
args.push_back(intern(line));
|
args.push_back(intern(line));
|
||||||
}
|
}
|
||||||
@ -641,7 +641,7 @@ void Project::index(WorkingFiles *wfiles, const RequestId &id) {
|
|||||||
void Project::indexRelated(const std::string &path) {
|
void Project::indexRelated(const std::string &path) {
|
||||||
auto &gi = g_config->index;
|
auto &gi = g_config->index;
|
||||||
GroupMatch match(gi.whitelist, gi.blacklist);
|
GroupMatch match(gi.whitelist, gi.blacklist);
|
||||||
std::string stem = sys::path::stem(path);
|
std::string stem = sys::path::stem(path).str();
|
||||||
std::vector<const char *> args, extra_args;
|
std::vector<const char *> args, extra_args;
|
||||||
for (const std::string &arg : g_config->clang.extraArgs)
|
for (const std::string &arg : g_config->clang.extraArgs)
|
||||||
extra_args.push_back(intern(arg));
|
extra_args.push_back(intern(arg));
|
||||||
|
@ -622,7 +622,7 @@ void *diagnosticMain(void *manager_) {
|
|||||||
for (const Note &n : d.notes) {
|
for (const Note &n : d.notes) {
|
||||||
SmallString<256> str(n.file);
|
SmallString<256> str(n.file);
|
||||||
llvm::sys::path::remove_dots(str, true);
|
llvm::sys::path::remove_dots(str, true);
|
||||||
Location loc{DocumentUri::fromPath(str.str()),
|
Location loc{DocumentUri::fromPath(str.str().str()),
|
||||||
lsRange{{n.range.start.line, n.range.start.column},
|
lsRange{{n.range.start.line, n.range.start.column},
|
||||||
{n.range.end.line, n.range.end.column}}};
|
{n.range.end.line, n.range.end.column}}};
|
||||||
ls_diag.relatedInformation.push_back({loc, n.message});
|
ls_diag.relatedInformation.push_back({loc, n.message});
|
||||||
|
@ -218,7 +218,7 @@ void reflect(JsonWriter &vis, IndexInclude &v) {
|
|||||||
reflectMemberStart(vis);
|
reflectMemberStart(vis);
|
||||||
REFLECT_MEMBER(line);
|
REFLECT_MEMBER(line);
|
||||||
if (gTestOutputMode) {
|
if (gTestOutputMode) {
|
||||||
std::string basename = llvm::sys::path::filename(v.resolved_path);
|
std::string basename = llvm::sys::path::filename(v.resolved_path).str();
|
||||||
if (v.resolved_path[0] != '&')
|
if (v.resolved_path[0] != '&')
|
||||||
basename = "&" + basename;
|
basename = "&" + basename;
|
||||||
REFLECT_MEMBER2("resolved_path", basename);
|
REFLECT_MEMBER2("resolved_path", basename);
|
||||||
|
@ -128,7 +128,7 @@ std::string resolveIfRelative(const std::string &directory,
|
|||||||
return path;
|
return path;
|
||||||
SmallString<256> ret;
|
SmallString<256> ret;
|
||||||
sys::path::append(ret, directory, path);
|
sys::path::append(ret, directory, path);
|
||||||
return normalizePath(ret.str());
|
return normalizePath(ret.str().str());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string realPath(const std::string &path) {
|
std::string realPath(const std::string &path) {
|
||||||
|
Loading…
Reference in New Issue
Block a user