summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-10-01 01:18:16 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-10-01 01:18:16 +0000
commit05cfdd08003d533609786500346d4a0d49aa5830 (patch)
tree3c19b88cde17922db699d65dfb8e3bc0c1461649 /llvm/lib
parentb7fb1245129a8336ede6179119294879b50935c9 (diff)
downloadbcm5719-llvm-05cfdd08003d533609786500346d4a0d49aa5830.tar.gz
bcm5719-llvm-05cfdd08003d533609786500346d4a0d49aa5830.zip
Use StringRef in LTOModule implementation (NFC)
llvm-svn: 282997
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/LTO/LTOCodeGenerator.cpp2
-rw-r--r--llvm/lib/LTO/LTOModule.cpp54
2 files changed, 30 insertions, 26 deletions
diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index d0527b27b5c..6dabdf110ac 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -131,7 +131,7 @@ void LTOCodeGenerator::initializeLTOPasses() {
}
void LTOCodeGenerator::setAsmUndefinedRefs(LTOModule *Mod) {
- const std::vector<const char *> &undefs = Mod->getAsmUndefinedRefs();
+ const std::vector<StringRef> &undefs = Mod->getAsmUndefinedRefs();
for (int i = 0, e = undefs.size(); i != e; ++i)
AsmUndefinedRefs[undefs[i]] = 1;
}
diff --git a/llvm/lib/LTO/LTOModule.cpp b/llvm/lib/LTO/LTOModule.cpp
index cca33546a43..5b46feb15b9 100644
--- a/llvm/lib/LTO/LTOModule.cpp
+++ b/llvm/lib/LTO/LTOModule.cpp
@@ -62,7 +62,7 @@ bool LTOModule::isBitcodeFile(const void *Mem, size_t Length) {
return bool(BCData);
}
-bool LTOModule::isBitcodeFile(const char *Path) {
+bool LTOModule::isBitcodeFile(StringRef Path) {
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
MemoryBuffer::getFile(Path);
if (!BufferOrErr)
@@ -106,7 +106,7 @@ std::string LTOModule::getProducerString(MemoryBuffer *Buffer) {
}
ErrorOr<std::unique_ptr<LTOModule>>
-LTOModule::createFromFile(LLVMContext &Context, const char *path,
+LTOModule::createFromFile(LLVMContext &Context, StringRef path,
const TargetOptions &options) {
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
MemoryBuffer::getFile(path);
@@ -120,15 +120,15 @@ LTOModule::createFromFile(LLVMContext &Context, const char *path,
}
ErrorOr<std::unique_ptr<LTOModule>>
-LTOModule::createFromOpenFile(LLVMContext &Context, int fd, const char *path,
+LTOModule::createFromOpenFile(LLVMContext &Context, int fd, StringRef path,
size_t size, const TargetOptions &options) {
return createFromOpenFileSlice(Context, fd, path, size, 0, options);
}
ErrorOr<std::unique_ptr<LTOModule>>
-LTOModule::createFromOpenFileSlice(LLVMContext &Context, int fd,
- const char *path, size_t map_size,
- off_t offset, const TargetOptions &options) {
+LTOModule::createFromOpenFileSlice(LLVMContext &Context, int fd, StringRef path,
+ size_t map_size, off_t offset,
+ const TargetOptions &options) {
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
MemoryBuffer::getOpenFileSlice(fd, path, map_size, offset);
if (std::error_code EC = BufferOrErr.getError()) {
@@ -280,7 +280,7 @@ void LTOModule::addObjCClass(const GlobalVariable *clgv) {
_undefines.insert(std::make_pair(superclassName, NameAndAttributes()));
if (IterBool.second) {
NameAndAttributes &info = IterBool.first->second;
- info.name = IterBool.first->first().data();
+ info.name = IterBool.first->first();
info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED;
info.isFunction = false;
info.symbol = clgv;
@@ -293,7 +293,7 @@ void LTOModule::addObjCClass(const GlobalVariable *clgv) {
auto Iter = _defines.insert(className).first;
NameAndAttributes info;
- info.name = Iter->first().data();
+ info.name = Iter->first();
info.attributes = LTO_SYMBOL_PERMISSIONS_DATA |
LTO_SYMBOL_DEFINITION_REGULAR | LTO_SYMBOL_SCOPE_DEFAULT;
info.isFunction = false;
@@ -319,7 +319,7 @@ void LTOModule::addObjCCategory(const GlobalVariable *clgv) {
return;
NameAndAttributes &info = IterBool.first->second;
- info.name = IterBool.first->first().data();
+ info.name = IterBool.first->first();
info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED;
info.isFunction = false;
info.symbol = clgv;
@@ -338,7 +338,7 @@ void LTOModule::addObjCClassRef(const GlobalVariable *clgv) {
return;
NameAndAttributes &info = IterBool.first->second;
- info.name = IterBool.first->first().data();
+ info.name = IterBool.first->first();
info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED;
info.isFunction = false;
info.symbol = clgv;
@@ -349,13 +349,14 @@ void LTOModule::addDefinedDataSymbol(const object::BasicSymbolRef &Sym) {
{
raw_svector_ostream OS(Buffer);
Sym.printName(OS);
+ Buffer.c_str();
}
const GlobalValue *V = IRFile->getSymbolGV(Sym.getRawDataRefImpl());
- addDefinedDataSymbol(Buffer.c_str(), V);
+ addDefinedDataSymbol(Buffer, V);
}
-void LTOModule::addDefinedDataSymbol(const char *Name, const GlobalValue *v) {
+void LTOModule::addDefinedDataSymbol(StringRef Name, const GlobalValue *v) {
// Add to list of defined symbols.
addDefinedSymbol(Name, v, false);
@@ -410,19 +411,20 @@ void LTOModule::addDefinedFunctionSymbol(const object::BasicSymbolRef &Sym) {
{
raw_svector_ostream OS(Buffer);
Sym.printName(OS);
+ Buffer.c_str();
}
const Function *F =
cast<Function>(IRFile->getSymbolGV(Sym.getRawDataRefImpl()));
- addDefinedFunctionSymbol(Buffer.c_str(), F);
+ addDefinedFunctionSymbol(Buffer, F);
}
-void LTOModule::addDefinedFunctionSymbol(const char *Name, const Function *F) {
+void LTOModule::addDefinedFunctionSymbol(StringRef Name, const Function *F) {
// add to list of defined symbols
addDefinedSymbol(Name, F, true);
}
-void LTOModule::addDefinedSymbol(const char *Name, const GlobalValue *def,
+void LTOModule::addDefinedSymbol(StringRef Name, const GlobalValue *def,
bool isFunction) {
// set alignment part log2() can have rounding errors
uint32_t align = def->getAlignment();
@@ -471,8 +473,8 @@ void LTOModule::addDefinedSymbol(const char *Name, const GlobalValue *def,
// fill information structure
NameAndAttributes info;
StringRef NameRef = Iter->first();
- info.name = NameRef.data();
- assert(info.name[NameRef.size()] == '\0');
+ info.name = NameRef;
+ assert(NameRef.data()[NameRef.size()] == '\0');
info.attributes = attr;
info.isFunction = isFunction;
info.symbol = def;
@@ -483,7 +485,7 @@ void LTOModule::addDefinedSymbol(const char *Name, const GlobalValue *def,
/// addAsmGlobalSymbol - Add a global symbol from module-level ASM to the
/// defined list.
-void LTOModule::addAsmGlobalSymbol(const char *name,
+void LTOModule::addAsmGlobalSymbol(StringRef name,
lto_symbol_attributes scope) {
auto IterBool = _defines.insert(name);
@@ -491,7 +493,7 @@ void LTOModule::addAsmGlobalSymbol(const char *name,
if (!IterBool.second)
return;
- NameAndAttributes &info = _undefines[IterBool.first->first().data()];
+ NameAndAttributes &info = _undefines[IterBool.first->first()];
if (info.symbol == nullptr) {
// FIXME: This is trying to take care of module ASM like this:
@@ -503,7 +505,7 @@ void LTOModule::addAsmGlobalSymbol(const char *name,
// much.
// fill information structure
- info.name = IterBool.first->first().data();
+ info.name = IterBool.first->first();
info.attributes =
LTO_SYMBOL_PERMISSIONS_DATA | LTO_SYMBOL_DEFINITION_REGULAR | scope;
info.isFunction = false;
@@ -525,10 +527,10 @@ void LTOModule::addAsmGlobalSymbol(const char *name,
/// addAsmGlobalSymbolUndef - Add a global symbol from module-level ASM to the
/// undefined list.
-void LTOModule::addAsmGlobalSymbolUndef(const char *name) {
+void LTOModule::addAsmGlobalSymbolUndef(StringRef name) {
auto IterBool = _undefines.insert(std::make_pair(name, NameAndAttributes()));
- _asm_undefines.push_back(IterBool.first->first().data());
+ _asm_undefines.push_back(IterBool.first->first());
// we already have the symbol
if (!IterBool.second)
@@ -537,7 +539,7 @@ void LTOModule::addAsmGlobalSymbolUndef(const char *name) {
uint32_t attr = LTO_SYMBOL_DEFINITION_UNDEFINED;
attr |= LTO_SYMBOL_SCOPE_DEFAULT;
NameAndAttributes &info = IterBool.first->second;
- info.name = IterBool.first->first().data();
+ info.name = IterBool.first->first();
info.attributes = attr;
info.isFunction = false;
info.symbol = nullptr;
@@ -550,6 +552,7 @@ void LTOModule::addPotentialUndefinedSymbol(const object::BasicSymbolRef &Sym,
{
raw_svector_ostream OS(name);
Sym.printName(OS);
+ name.c_str();
}
auto IterBool = _undefines.insert(std::make_pair(name, NameAndAttributes()));
@@ -560,7 +563,7 @@ void LTOModule::addPotentialUndefinedSymbol(const object::BasicSymbolRef &Sym,
NameAndAttributes &info = IterBool.first->second;
- info.name = IterBool.first->first().data();
+ info.name = IterBool.first->first();
const GlobalValue *decl = IRFile->getSymbolGV(Sym.getRawDataRefImpl());
@@ -587,8 +590,9 @@ void LTOModule::parseSymbols() {
{
raw_svector_ostream OS(Buffer);
Sym.printName(OS);
+ Buffer.c_str();
}
- const char *Name = Buffer.c_str();
+ StringRef Name(Buffer);
if (IsUndefined)
addAsmGlobalSymbolUndef(Name);
OpenPOWER on IntegriCloud