llvm::StringRef does not support automatic conversion to string anymore.

See llvm/llvm-project@777180a32b
This commit is contained in:
Vassil Vassilev 2021-09-11 18:12:30 +00:00 committed by jenkins
parent 83ff0acdd2
commit c8c61d7aa9
19 changed files with 82 additions and 78 deletions

View File

@ -126,7 +126,7 @@ namespace cling {
for (auto & item : m_SearchPaths)
if (dir.equals(item.Path)) return;
auto pos = prepend ? m_SearchPaths.begin() : m_SearchPaths.end();
m_SearchPaths.insert(pos, SearchPathInfo{dir, isUser});
m_SearchPaths.insert(pos, SearchPathInfo{dir.str(), isUser});
}
}

View File

@ -163,11 +163,11 @@ namespace cling {
if ( (cacheUpdate = addFile(FileNames.first,true)) ) {
m_PrevFE.first = cacheUpdate;
m_PrevFileName.first = FileNames.first;
m_PrevFileName.first = FileNames.first.str();
}
if ( (cacheUpdate = addFile(FileNames.second,false)) ) {
m_PrevFE.second = cacheUpdate;
m_PrevFileName.second = FileNames.second;
m_PrevFileName.second = FileNames.second.str();
}

View File

@ -283,7 +283,7 @@ namespace {
#ifdef _LIBCPP_VERSION
// Try to use a version of clang that is located next to cling
// in case cling was built with a new/custom libc++
std::string clang = llvm::sys::path::parent_path(clingBin);
std::string clang = llvm::sys::path::parent_path(clingBin).str();
buffer.assign(clang);
llvm::sys::path::append(buffer, "clang");
clang.assign(&buffer[0], buffer.size());
@ -666,50 +666,52 @@ namespace {
std::string MOverlay;
#ifdef _WIN32
maybeAppendOverlayEntry(vcIncLoc.str(), "vcruntime.modulemap",
clingIncLoc.str(), MOverlay,
clingIncLoc.str().str(), MOverlay,
/*RegisterModuleMap=*/ true,
/*AllowModulemapOverride=*/ false);
maybeAppendOverlayEntry(servIncLoc.str(), "services_msvc.modulemap",
clingIncLoc.str(), MOverlay,
clingIncLoc.str().str(), MOverlay,
/*RegisterModuleMap=*/ true,
/*AllowModulemapOverride=*/ false);
maybeAppendOverlayEntry(cIncLoc.str(), "libc_msvc.modulemap",
clingIncLoc.str(), MOverlay,
clingIncLoc.str().str(), MOverlay,
/*RegisterModuleMap=*/ true,
/*AllowModulemapOverride=*/ false);
maybeAppendOverlayEntry(stdIncLoc.str(), "std_msvc.modulemap",
clingIncLoc.str(), MOverlay,
clingIncLoc.str().str(), MOverlay,
/*RegisterModuleMap=*/ true,
/*AllowModulemapOverride=*/ false);
#else
maybeAppendOverlayEntry(cIncLoc.str(), "libc.modulemap", clingIncLoc.str(),
MOverlay, /*RegisterModuleMap=*/ true,
maybeAppendOverlayEntry(cIncLoc.str(), "libc.modulemap",
clingIncLoc.str().str(), MOverlay,
/*RegisterModuleMap=*/ true,
/*AllowModulemapOverride=*/true);
maybeAppendOverlayEntry(stdIncLoc.str(), "std.modulemap", clingIncLoc.str(),
MOverlay, /*RegisterModuleMap=*/ true,
maybeAppendOverlayEntry(stdIncLoc.str(), "std.modulemap",
clingIncLoc.str().str(), MOverlay,
/*RegisterModuleMap=*/ true,
/*AllowModulemapOverride=*/true);
#endif // _WIN32
if (!tinyxml2IncLoc.empty())
maybeAppendOverlayEntry(tinyxml2IncLoc.str(), "tinyxml2.modulemap",
clingIncLoc.str(), MOverlay,
clingIncLoc.str().str(), MOverlay,
/*RegisterModuleMap=*/ false,
/*AllowModulemapOverride=*/ false);
if (!cudaIncLoc.empty())
maybeAppendOverlayEntry(cudaIncLoc.str(), "cuda.modulemap",
clingIncLoc.str(), MOverlay,
clingIncLoc.str().str(), MOverlay,
/*RegisterModuleMap=*/ true,
/*AllowModulemapOverride=*/ false);
if (!vcVcIncLoc.empty())
maybeAppendOverlayEntry(vcVcIncLoc.str(), "vc.modulemap",
clingIncLoc.str(), MOverlay,
clingIncLoc.str().str(), MOverlay,
/*RegisterModuleMap=*/ true,
/*AllowModulemapOverride=*/ false);
if (!boostIncLoc.empty()) {
// Add the modulemap in the include/boost folder not in include.
llvm::sys::path::append(boostIncLoc, "boost");
maybeAppendOverlayEntry(boostIncLoc.str(), "boost.modulemap",
clingIncLoc.str(), MOverlay,
clingIncLoc.str().str(), MOverlay,
/*RegisterModuleMap=*/ false,
/*AllowModulemapOverride=*/ false);
}
@ -1616,7 +1618,7 @@ namespace {
+CI->getFrontendOpts().BuildingImplicitModule));
Consumers.push_back(
CI->getPCHContainerWriter().CreatePCHContainerGenerator(
*CI, "", ModuleOutputFile, std::move(OS), PCHBuff));
*CI, "", ModuleOutputFile.str(), std::move(OS), PCHBuff));
// Set the current module name for clang. With that clang doesn't start
// to build the current module on demand when we include a header

View File

@ -120,7 +120,7 @@ namespace cling {
if (llvm::sys::fs::createUniqueFile(TempPath.str(), fd, TempPath)
!= std::errc::no_such_file_or_directory) {
OS.reset(new llvm::raw_fd_ostream(fd, /*shouldClose=*/true));
OSFile = TempPath.str();
OSFile = TempPath.str().str();
}
// Make sure the out stream file gets removed if we crash.

View File

@ -73,7 +73,7 @@ namespace {
SmallVector<Token, 1> StrToks(1, Tok);
StringLiteralParser LitParse(StrToks, PP);
if (!LitParse.hadError)
Literal = LitParse.GetString();
Literal = LitParse.GetString().str();
} else {
llvm::SmallString<64> Buffer;
Literal = PP.getSpelling(Tok, Buffer).str();

View File

@ -24,7 +24,7 @@ namespace runtime {
Buf.resize(0);
llvm::raw_svector_ostream Strm(Buf);
Strm << m_Addresses[i];
m_Result = m_Result.insert(found + 1, Strm.str());
m_Result = m_Result.insert(found + 1, Strm.str().str());
m_Result = m_Result.erase(found, 1);
++i;
}

View File

@ -72,7 +72,7 @@ namespace cling {
return original.str();
llvm::SmallString<512> result(replacement);
result.append(original.drop_front(pattern.size()));
return result.str();
return result.str().str();
}
///\returns substitution of all known linker variables in \c original
@ -167,7 +167,7 @@ namespace cling {
if (DEBUG > 7) {
cling::errs() << " ... Found (in RPATH)!\n";
}
return ThisPath.str();
return ThisPath.str().str();
}
}
// m_SearchPaths
@ -182,7 +182,7 @@ namespace cling {
if (DEBUG > 7) {
cling::errs() << " ... Found (in SearchPaths)!\n";
}
return ThisPath.str();
return ThisPath.str().str();
}
}
// RUNPATH
@ -197,7 +197,7 @@ namespace cling {
if (DEBUG > 7) {
cling::errs() << " ... Found (in RUNPATH)!\n";
}
return ThisPath.str();
return ThisPath.str().str();
}
}

View File

@ -509,7 +509,7 @@ namespace cling {
}
bool Contains(StringRef Path) {
return m_Paths.count(Path);
return m_Paths.count(Path.str());
}
};
@ -697,8 +697,9 @@ namespace cling {
llvm::StringRef FileRealPath = llvm::sys::path::parent_path(FileName);
llvm::StringRef FileRealName = llvm::sys::path::filename(FileName);
const BasePath& BaseP = m_BasePaths.RegisterBasePath(FileRealPath.str());
LibraryPath LibPath(BaseP, FileRealName); //bp, str
const BasePath& BaseP =
m_BasePaths.RegisterBasePath(FileRealPath.str());
LibraryPath LibPath(BaseP, FileRealName.str()); //bp, str
if (m_SysLibraries.GetRegisteredLib(LibPath) ||
m_Libraries.GetRegisteredLib(LibPath)) {
@ -967,7 +968,7 @@ namespace cling {
// Generate BloomFilter
for (const auto &S : symbols) {
if (m_UseHashTable)
Lib->AddBloom(Lib->AddSymbol(S));
Lib->AddBloom(Lib->AddSymbol(S.str()));
else
Lib->AddBloom(S);
}
@ -1186,7 +1187,7 @@ namespace cling {
std::string Dyld::searchLibrariesForSymbol(StringRef mangledName,
bool searchSystem/* = true*/) {
assert(!llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(mangledName) &&
assert(!llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(mangledName.data()) &&
"Library already loaded, please use dlsym!");
assert(!mangledName.empty());

View File

@ -966,7 +966,7 @@ namespace cling {
ostrstream stream;
stream << "delete (" << m_Type << "*) " << m_Memory << ";";
LockCompilationDuringUserCodeExecutionRAII LCDUCER(*m_Interpreter);
m_Interpreter->execute(stream.str());
m_Interpreter->execute(stream.str().str());
}
} // end namespace internal
} // end namespace runtime

View File

@ -69,7 +69,7 @@ namespace cling {
for (unsigned i = 0, e = MI->getNumTokens(); i != e; ++i) {
const Token &Tok = MI->getReplacementToken(i);
Out() << Tok.getName() << ' ';
macrodefs.push_back(macro.m_II->getName());
macrodefs.push_back(macro.m_II->getName().str());
}
Out() << '\n';
}
@ -1053,7 +1053,7 @@ namespace cling {
skipDecl(D, "specialization failed");
return;
}
std::string output = stream.take(true);
std::string output = stream.take(true).str();
Out() << output;
}
@ -1077,7 +1077,7 @@ namespace cling {
skipDecl(D, "template instance failed");
return;
}
std::string output = stream.take(true);
std::string output = stream.take(true).str();
Out() << output;
Out() << '\n';
}

View File

@ -274,7 +274,7 @@ static void HandlePlugins(CompilerInstance& CI,
PluginASTAction::ActionType PluginActionType = P->getActionType();
assert(PluginActionType != clang::PluginASTAction::ReplaceAction);
if (P->ParseArgs(CI, CI.getFrontendOpts().PluginArgs[it->getName()])) {
if (P->ParseArgs(CI, CI.getFrontendOpts().PluginArgs[it->getName().str()])) {
std::unique_ptr<ASTConsumer> PluginConsumer
= P->CreateASTConsumer(CI, /*InputFile*/ "");
if (PluginActionType == clang::PluginASTAction::AddBeforeMainAction)

View File

@ -562,10 +562,10 @@ namespace cling {
}
if (m_Opts.Verbose())
cling::errs() << Strm.str();
cling::errs() << Strm.str().str();
Transaction *T;
declare(Strm.str(), &T);
declare(Strm.str().str(), &T);
return T;
}
@ -1098,7 +1098,7 @@ namespace cling {
Strm << "void ";
makeUniqueName(Strm, ID);
Strm << "(void* vpClingValue) {\n ";
return Strm.str();
return Strm.str().str();
}
void Interpreter::createUniqueName(std::string &Out) {
@ -1256,7 +1256,7 @@ namespace cling {
bool savedAccessControl = LO.AccessControl;
LO.AccessControl = withAccessControl;
T = nullptr;
cling::Interpreter::CompilationResult CR = declare(code, &T);
cling::Interpreter::CompilationResult CR = declare(code.str(), &T);
LO.AccessControl = savedAccessControl;
Diag.setSeverity(clang::diag::ext_nested_name_member_ref_lookup_ambiguous,
@ -1429,7 +1429,7 @@ namespace cling {
std::string Interpreter::lookupFileOrLibrary(llvm::StringRef file) {
std::string canonicalFile = DynamicLibraryManager::normalizePath(file);
if (canonicalFile.empty())
canonicalFile = file;
canonicalFile = file.str();
const FileEntry* FE = 0;
//Copied from clang's PPDirectives.cpp
@ -1449,7 +1449,7 @@ namespace cling {
/*IsFrameworkFound*/ nullptr, /*SkipCache*/false,
/*OpenFile*/ false, /*CacheFail*/ false);
if (FE)
return FE->getName();
return FE->getName().str();
return getDynamicLibraryManager()->lookupLibrary(canonicalFile);
}

View File

@ -173,7 +173,7 @@ static std::string printAddress(const void* Ptr, const char Prfx = 0) {
Strm << Ptr;
if (!utils::isAddressValid(Ptr))
Strm << kInvalidAddr;
return Strm.str();
return Strm.str().str();
}
} // anonymous namespace
@ -217,7 +217,7 @@ namespace cling {
else
Strm << Val;
Strm << "'";
return Strm.str();
return Strm.str().str();
}
CLING_LIB_EXPORT
@ -240,56 +240,56 @@ namespace cling {
std::string printValue(const short *val) {
cling::smallstream strm;
strm << *val;
return strm.str();
return strm.str().str();
}
CLING_LIB_EXPORT
std::string printValue(const unsigned short *val) {
cling::smallstream strm;
strm << *val;
return strm.str();
return strm.str().str();
}
CLING_LIB_EXPORT
std::string printValue(const int *val) {
cling::smallstream strm;
strm << *val;
return strm.str();
return strm.str().str();
}
CLING_LIB_EXPORT
std::string printValue(const unsigned int *val) {
cling::smallstream strm;
strm << *val;
return strm.str();
return strm.str().str();
}
CLING_LIB_EXPORT
std::string printValue(const long *val) {
cling::smallstream strm;
strm << *val;
return strm.str();
return strm.str().str();
}
CLING_LIB_EXPORT
std::string printValue(const unsigned long *val) {
cling::smallstream strm;
strm << *val;
return strm.str();
return strm.str().str();
}
CLING_LIB_EXPORT
std::string printValue(const long long *val) {
cling::smallstream strm;
strm << *val;
return strm.str();
return strm.str().str();
}
CLING_LIB_EXPORT
std::string printValue(const unsigned long long *val) {
cling::smallstream strm;
strm << *val;
return strm.str();
return strm.str().str();
}
// Reals
@ -297,14 +297,14 @@ namespace cling {
std::string printValue(const float *val) {
cling::smallstream strm;
strm << llvm::format("%#.6g", *val) << 'f';
return strm.str();
return strm.str().str();
}
CLING_LIB_EXPORT
std::string printValue(const double *val) {
cling::smallstream strm;
strm << llvm::format("%#.8g", *val);
return strm.str();
return strm.str().str();
}
CLING_LIB_EXPORT
@ -312,7 +312,7 @@ namespace cling {
cling::smallstream strm;
strm << llvm::format("%#.8Lg", *val) << 'L';
//strm << llvm::format("%Le", *val) << 'L';
return strm.str();
return strm.str().str();
}
// Char pointers
@ -340,7 +340,7 @@ namespace cling {
if (!IsValid) {
cling::smallstream Strm;
Strm << static_cast<const void*>(Start) << kInvalidAddr;
return Strm.str();
return Strm.str().str();
}
if (*Start == 0)
@ -354,7 +354,7 @@ namespace cling {
Strm << *Start++;
Strm << "\"";
return Strm.str();
return Strm.str().str();
}
CLING_LIB_EXPORT
@ -554,7 +554,7 @@ namespace cling {
llvm::raw_svector_ostream Strm(Buf);
Strm << Prefix << "'\\" << Esc
<< llvm::format_hex_no_prefix(unsigned(*Src), sizeof(T)*2) << "'";
return Strm.str();
return Strm.str().str();
}
CLING_LIB_EXPORT
@ -773,7 +773,7 @@ static std::string printEnumValue(const Value &V) {
}
enumString << " : " << printQualType(C, ED->getIntegerType()) << " "
<< ValAsAPSInt.toString(/*Radix = */10);
return enumString.str();
return enumString.str().str();
}
static std::string printFunctionValue(const Value &V, const void *ptr,
@ -784,7 +784,7 @@ static std::string printFunctionValue(const Value &V, const void *ptr,
Interpreter &Interp = *const_cast<Interpreter *>(V.getInterpreter());
const Transaction *T = Interp.getLastWrapperTransaction();
if (!T)
return o.str();
return o.str().str();
if (clang::FunctionDecl *WrapperFD = T->getWrapperFD()) {
clang::ASTContext &C = V.getASTContext();
@ -853,7 +853,7 @@ static std::string printFunctionValue(const Value &V, const void *ptr,
o << '\n';
}
}
return o.str();
return o.str().str();
}
static std::string printStringType(const Value &V, const clang::Type* Type) {
@ -972,7 +972,7 @@ namespace cling {
} else
strm << "<<<invalid>>> " << printAddress(value, '@');
return strm.str();
return strm.str().str();
}
namespace valuePrinterInternal {

View File

@ -110,7 +110,7 @@ static void AppendAnyDeclLocation(const CompilerInstance* compiler,
const SourceManager &sourceManager = compiler->getSourceManager();
if (loc.isValid() && sourceManager.isLoadedSourceLocation(loc)) {
// No line numbers as they would touich disk.
baseName = llvm::sys::path::filename(sourceManager.getFilename(loc));
baseName = llvm::sys::path::filename(sourceManager.getFilename(loc)).str();
lineNo = -1;
} else {
PresumedLoc ploc(sourceManager.getPresumedLoc(loc));

View File

@ -104,8 +104,9 @@ namespace cling {
if (!m_Input.empty()) {
m_Input.append("\n");
}
m_Input.append(line);
m_Input.append(line.str());
m_LastResult = Res;
return Res;
}

View File

@ -159,11 +159,11 @@ namespace cling {
if (getCurTok().is(tok::ident) && getCurTok().getIdent().equals("T")) {
consumeAnyStringToken();
if (getCurTok().is(tok::raw_ident)) {
std::string inputFile = getCurTok().getIdent();
std::string inputFile = getCurTok().getIdent().str();
consumeAnyStringToken(tok::eof);
if (getCurTok().is(tok::raw_ident)) {
result = true;
std::string outputFile = getCurTok().getIdent();
std::string outputFile = getCurTok().getIdent().str();
actionResult = m_Actions.actOnTCommand(inputFile, outputFile);
}
}
@ -235,7 +235,7 @@ namespace cling {
if (!lookAhead(1).is(tok::eof) && !(stream & MetaProcessor::kSTDSTRM)) {
consumeAnyStringToken(tok::eof);
if (getCurTok().is(tok::raw_ident)) {
EnvExpand = getCurTok().getIdent();
EnvExpand = getCurTok().getIdent().str();
// Quoted path, no expansion and strip quotes
if (EnvExpand.size() > 3 && EnvExpand.front() == '"' &&
EnvExpand.back() == '"') {
@ -461,7 +461,7 @@ namespace cling {
skipWhitespace();
if (!getCurTok().is(tok::stringlit))
return false; // FIXME: Issue proper diagnostics
std::string ident = getCurTok().getIdentNoQuotes();
std::string ident = getCurTok().getIdentNoQuotes().str();
consumeToken();
m_Actions.actOnstoreStateCommand(ident);
return true;
@ -477,7 +477,7 @@ namespace cling {
skipWhitespace();
if (!getCurTok().is(tok::stringlit))
return false; // FIXME: Issue proper diagnostics
std::string ident = getCurTok().getIdentNoQuotes();
std::string ident = getCurTok().getIdentNoQuotes().str();
consumeToken();
m_Actions.actOncompareStateCommand(ident);
return true;

View File

@ -31,9 +31,9 @@
#include "clang/Lex/Preprocessor.h"
#include "clang/Basic/SourceManager.h"
#include <cstdlib>
#include <cctype>
#include <algorithm>
#include <cctype>
#include <cstdlib>
namespace {
///\brief Make a valid C++ identifier, replacing illegal characters in `S'
@ -75,7 +75,7 @@ namespace cling {
std::string pathname(m_Interpreter.lookupFileOrLibrary(file));
if (pathname.empty())
pathname = file;
pathname = file.str();
if (m_Interpreter.loadFile(pathname, /*allowSharedLib=*/true, transaction)
== Interpreter::kSuccess) {
registerUnloadPoint(unloadPoint, pathname);
@ -113,7 +113,7 @@ namespace cling {
void MetaSema::actOnComment(llvm::StringRef comment) const {
// Some of the comments are meaningful for the cling::Interpreter
m_Interpreter.declare(comment);
m_Interpreter.declare(comment.str());
}
MetaSema::ActionResult MetaSema::actOnxCommand(llvm::StringRef file,
@ -148,7 +148,7 @@ namespace cling {
// First, try function named after `file`; add any alternatives below.
const std::string tryCallThese[] = {
makeValidCXXIdentifier(llvm::sys::path::stem(file)),
makeValidCXXIdentifier(llvm::sys::path::stem(file).str()),
// FIXME: this provides an entry point that is independent from the macro
// filename (and still works if file is renamed); should we enable this?
//"__main__",
@ -288,11 +288,11 @@ namespace cling {
}
void MetaSema::actOnstoreStateCommand(llvm::StringRef name) const {
m_Interpreter.storeInterpreterState(name);
m_Interpreter.storeInterpreterState(name.str());
}
void MetaSema::actOncompareStateCommand(llvm::StringRef name) const {
m_Interpreter.compareInterpreterState(name);
m_Interpreter.compareInterpreterState(name.str());
}
void MetaSema::actOnstatsCommand(llvm::StringRef name,
@ -479,7 +479,7 @@ namespace cling {
llvm::StringRef filename) {
std::string pathname(m_Interpreter.lookupFileOrLibrary(filename));
if (pathname.empty())
pathname = filename;
pathname = filename.str();
clang::FileManager& FM = m_Interpreter.getSema().getSourceManager().getFileManager();
const clang::FileEntry* FE = FM.getFile(pathname, /*OpenFile=*/false,

View File

@ -174,7 +174,7 @@ bool LookForFile(const std::vector<const char*>& Args, std::string& Path,
llvm::sys::fs::is_regular_file(FilePath)) {
if (FileType)
LogFileStatus("Using", FileType, FilePath.str());
Path = FilePath.str();
Path = FilePath.str().str();
return true;
}
// Don't write same same log entry twice when FilePath == Path
@ -201,7 +201,7 @@ bool LookForFile(const std::vector<const char*>& Args, std::string& Path,
if (llvm::sys::fs::is_regular_file(FilePath)) {
if (FileType)
LogFileStatus("Using", FileType, FilePath.str());
Path = FilePath.str();
Path = FilePath.str().str();
return true;
}
if (FileType)

View File

@ -195,7 +195,7 @@ bool GetSystemLibraryPaths(llvm::SmallVectorImpl<std::string>& Paths) {
From += 12;
while (To > From && isspace(Result[To - 1]))
--To;
std::string SysPath = Result.substr(From, To - From);
std::string SysPath = Result.substr(From, To-From).str();
SysPath.erase(std::remove_if(SysPath.begin(), SysPath.end(), isspace),
SysPath.end());