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:
Nathan Lanza 2020-01-29 00:29:06 -08:00
parent 1834f8195b
commit 65464cb4a4
10 changed files with 12 additions and 11 deletions

View File

@ -21,7 +21,7 @@ std::string pathFromFileEntry(const FileEntry &file) {
StringRef name = file.tryGetRealPathName();
if (name.empty())
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
return normalizeFolder(ret) ? ret : realPath(ret);
}

View File

@ -31,7 +31,8 @@ void getFilesInFolder(std::string folder, bool recursive, bool dir_prefix,
curr.pop_back();
for (sys::fs::directory_iterator i(folder1, ec, false), e; i != e && !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") ||
sys::fs::status(path, status, false))
continue;

View File

@ -508,7 +508,7 @@ public:
llvm::raw_svector_ostream os(str);
d->print(os, getDefaultPolicy());
std::string name = os.str();
std::string name = os.str().str();
simplifyAnonymous(name);
// Remove \n in DeclPrinter.cpp "{\n" + if(!TerseOutput)something + "}"
for (std::string::size_type i = 0;;) {

View File

@ -140,7 +140,7 @@ int main(int argc, char **argv) {
if (opt_index.size()) {
SmallString<256> root(opt_index);
sys::fs::make_absolute(root);
pipeline::standalone(root.str());
pipeline::standalone(root.str().str());
} else {
// The thread that reads from stdin and dispatchs commands to the main
// thread.

View File

@ -297,7 +297,7 @@ void do_initialize(MessageHandler *m, InitializeParam &param,
SmallString<256> path(g_config->cache.directory);
sys::fs::make_absolute(project_path, path);
// 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);
}
}

View File

@ -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
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());
for (int i = 0; i < size; i++)
if (strcmp(prev->args[i], args[i]) && sys::path::stem(args[i]) != stem) {

View File

@ -226,7 +226,7 @@ readCompilerArgumentsFromFile(const std::string &path) {
return {};
std::vector<const char *> args;
for (line_iterator i(*mbOrErr.get(), true, '#'), e; i != e; ++i) {
std::string line = *i;
std::string line = i->str();
doPathMapping(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) {
auto &gi = g_config->index;
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;
for (const std::string &arg : g_config->clang.extraArgs)
extra_args.push_back(intern(arg));

View File

@ -622,7 +622,7 @@ void *diagnosticMain(void *manager_) {
for (const Note &n : d.notes) {
SmallString<256> str(n.file);
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},
{n.range.end.line, n.range.end.column}}};
ls_diag.relatedInformation.push_back({loc, n.message});

View File

@ -218,7 +218,7 @@ void reflect(JsonWriter &vis, IndexInclude &v) {
reflectMemberStart(vis);
REFLECT_MEMBER(line);
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] != '&')
basename = "&" + basename;
REFLECT_MEMBER2("resolved_path", basename);

View File

@ -128,7 +128,7 @@ std::string resolveIfRelative(const std::string &directory,
return path;
SmallString<256> ret;
sys::path::append(ret, directory, path);
return normalizePath(ret.str());
return normalizePath(ret.str().str());
}
std::string realPath(const std::string &path) {