summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-06-10 15:27:39 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-06-10 15:27:39 +0000
commit1dc43065a7b02c6e52e2df8777bb231292c0ce04 (patch)
treeb8dc1d383aa44438927132b63bfe62871da9caf6 /llvm/lib
parentaecb66ec331bf1b1fc29dde9ca6ee09560039530 (diff)
downloadbcm5719-llvm-1dc43065a7b02c6e52e2df8777bb231292c0ce04.tar.gz
bcm5719-llvm-1dc43065a7b02c6e52e2df8777bb231292c0ce04.zip
Pass a StringRef to sys::identifyFileType.
llvm-svn: 183669
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Archive/Archive.cpp2
-rw-r--r--llvm/lib/Archive/ArchiveReader.cpp2
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp4
-rw-r--r--llvm/lib/Object/Binary.cpp3
-rw-r--r--llvm/lib/Object/ObjectFile.cpp3
-rw-r--r--llvm/lib/Support/Path.cpp12
6 files changed, 11 insertions, 15 deletions
diff --git a/llvm/lib/Archive/Archive.cpp b/llvm/lib/Archive/Archive.cpp
index 1f36a00ab08..2b92d0ff827 100644
--- a/llvm/lib/Archive/Archive.cpp
+++ b/llvm/lib/Archive/Archive.cpp
@@ -129,7 +129,7 @@ bool ArchiveMember::replaceWith(const sys::Path& newFile, std::string* ErrMsg) {
}
// Determine what kind of file it is.
- switch (sys::IdentifyFileType(signature,4)) {
+ switch (sys::identifyFileType(StringRef(signature, 4))) {
case sys::Bitcode_FileType:
flags |= BitcodeFlag;
break;
diff --git a/llvm/lib/Archive/ArchiveReader.cpp b/llvm/lib/Archive/ArchiveReader.cpp
index 14713e692c0..65505993c0c 100644
--- a/llvm/lib/Archive/ArchiveReader.cpp
+++ b/llvm/lib/Archive/ArchiveReader.cpp
@@ -205,7 +205,7 @@ Archive::parseMemberHeader(const char*& At, const char* End, std::string* error)
}
// Determine if this is a bitcode file
- switch (sys::IdentifyFileType(At, 4)) {
+ switch (sys::identifyFileType(StringRef(At, 4))) {
case sys::Bitcode_FileType:
flags |= ArchiveMember::BitcodeFlag;
break;
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
index cee18c69adf..3995ba5b0da 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
@@ -501,9 +501,7 @@ RuntimeDyld::~RuntimeDyld() {
ObjectImage *RuntimeDyld::loadObject(ObjectBuffer *InputBuffer) {
if (!Dyld) {
- sys::LLVMFileType type = sys::IdentifyFileType(
- InputBuffer->getBufferStart(),
- static_cast<unsigned>(InputBuffer->getBufferSize()));
+ sys::LLVMFileType type = sys::identifyFileType(InputBuffer->getBuffer());
switch (type) {
case sys::ELF_Relocatable_FileType:
case sys::ELF_Executable_FileType:
diff --git a/llvm/lib/Object/Binary.cpp b/llvm/lib/Object/Binary.cpp
index 012e3284127..5d816e15b53 100644
--- a/llvm/lib/Object/Binary.cpp
+++ b/llvm/lib/Object/Binary.cpp
@@ -45,8 +45,7 @@ error_code object::createBinary(MemoryBuffer *Source,
OwningPtr<MemoryBuffer> scopedSource(Source);
if (!Source)
return make_error_code(errc::invalid_argument);
- sys::LLVMFileType type = sys::IdentifyFileType(Source->getBufferStart(),
- static_cast<unsigned>(Source->getBufferSize()));
+ sys::LLVMFileType type = sys::identifyFileType(Source->getBuffer());
error_code ec;
switch (type) {
case sys::Archive_FileType: {
diff --git a/llvm/lib/Object/ObjectFile.cpp b/llvm/lib/Object/ObjectFile.cpp
index 5b3165db94f..c64af84346b 100644
--- a/llvm/lib/Object/ObjectFile.cpp
+++ b/llvm/lib/Object/ObjectFile.cpp
@@ -40,8 +40,7 @@ section_iterator ObjectFile::getRelocatedSection(DataRefImpl Sec) const {
ObjectFile *ObjectFile::createObjectFile(MemoryBuffer *Object) {
if (!Object || Object->getBufferSize() < 64)
return 0;
- sys::LLVMFileType type = sys::IdentifyFileType(Object->getBufferStart(),
- static_cast<unsigned>(Object->getBufferSize()));
+ sys::LLVMFileType type = sys::identifyFileType(Object->getBuffer());
switch (type) {
case sys::Unknown_FileType:
return 0;
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp
index b6eeb1484cf..bf1ae44e0d0 100644
--- a/llvm/lib/Support/Path.cpp
+++ b/llvm/lib/Support/Path.cpp
@@ -38,9 +38,9 @@ bool Path::operator<(const Path& that) const {
}
LLVMFileType
-sys::identifyFileType(const char *Magic, unsigned Length) {
- assert(Magic && "Invalid magic number string");
- assert(Length >=4 && "Invalid magic number length");
+sys::identifyFileType(StringRef Magic) {
+ unsigned Length = Magic.size();
+ assert(Length >= 4 && "Invalid magic number length");
switch ((unsigned char)Magic[0]) {
case 0xDE: // 0x0B17C0DE = BC wraper
if (Magic[1] == (char)0xC0 && Magic[2] == (char)0x17 &&
@@ -53,7 +53,7 @@ sys::identifyFileType(const char *Magic, unsigned Length) {
break;
case '!':
if (Length >= 8)
- if (memcmp(Magic,"!<arch>\n",8) == 0)
+ if (memcmp(Magic.data(),"!<arch>\n",8) == 0)
return Archive_FileType;
break;
@@ -136,9 +136,9 @@ sys::identifyFileType(const char *Magic, unsigned Length) {
case 0x4d: // Possible MS-DOS stub on Windows PE file
if (Magic[1] == 0x5a) {
uint32_t off =
- *reinterpret_cast<const ulittle32_t *>(Magic + 0x3c);
+ *reinterpret_cast<const ulittle32_t *>(Magic.data() + 0x3c);
// PE/COFF file, either EXE or DLL.
- if (off < Length && memcmp(Magic + off, "PE\0\0",4) == 0)
+ if (off < Length && memcmp(Magic.data() + off, "PE\0\0",4) == 0)
return COFF_FileType;
}
break;
OpenPOWER on IntegriCloud