r212408 - Update for llvm api change.
Rafael Espindola
rafael.espindola at gmail.com
Sun Jul 6 10:43:25 PDT 2014
Author: rafael
Date: Sun Jul 6 12:43:24 2014
New Revision: 212408
URL: http://llvm.org/viewvc/llvm-project?rev=212408&view=rev
Log:
Update for llvm api change.
Modified:
cfe/trunk/lib/ARCMigrate/FileRemapper.cpp
cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Lex/PTHLexer.cpp
cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp
cfe/trunk/lib/Serialization/ModuleManager.cpp
cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
cfe/trunk/tools/arcmt-test/arcmt-test.cpp
cfe/trunk/tools/clang-format/ClangFormat.cpp
cfe/trunk/tools/driver/cc1as_main.cpp
Modified: cfe/trunk/lib/ARCMigrate/FileRemapper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/FileRemapper.cpp?rev=212408&r1=212407&r2=212408&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/FileRemapper.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/FileRemapper.cpp Sun Jul 6 12:43:24 2014
@@ -65,12 +65,13 @@ bool FileRemapper::initFromFile(StringRe
std::vector<std::pair<const FileEntry *, const FileEntry *> > pairs;
- std::unique_ptr<llvm::MemoryBuffer> fileBuf;
- if (llvm::MemoryBuffer::getFile(infoFile.c_str(), fileBuf))
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> fileBuf =
+ llvm::MemoryBuffer::getFile(infoFile.c_str());
+ if (!fileBuf)
return report("Error opening file: " + infoFile, Diag);
SmallVector<StringRef, 64> lines;
- fileBuf->getBuffer().split(lines, "\n");
+ fileBuf.get()->getBuffer().split(lines, "\n");
for (unsigned idx = 0; idx+3 <= lines.size(); idx += 3) {
StringRef fromFilename = lines[idx];
Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=212408&r1=212407&r2=212408&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Sun Jul 6 12:43:24 2014
@@ -1943,12 +1943,13 @@ public:
bool parse(StringRef File, SmallVectorImpl<EditEntry> &Entries) {
using namespace llvm::yaml;
- std::unique_ptr<llvm::MemoryBuffer> FileBuf;
- if (llvm::MemoryBuffer::getFile(File, FileBuf))
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileBufOrErr =
+ llvm::MemoryBuffer::getFile(File);
+ if (!FileBufOrErr)
return true;
llvm::SourceMgr SM;
- Stream YAMLStream(FileBuf.release(), SM);
+ Stream YAMLStream(FileBufOrErr.get().release(), SM);
document_iterator I = YAMLStream.begin();
if (I == YAMLStream.end())
return true;
Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=212408&r1=212407&r2=212408&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Sun Jul 6 12:43:24 2014
@@ -126,8 +126,13 @@ std::error_code RealFile::getBuffer(cons
bool RequiresNullTerminator,
bool IsVolatile) {
assert(FD != -1 && "cannot get buffer for closed file");
- return MemoryBuffer::getOpenFile(FD, Name.str().c_str(), Result, FileSize,
- RequiresNullTerminator, IsVolatile);
+ ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
+ MemoryBuffer::getOpenFile(FD, Name.str().c_str(), FileSize,
+ RequiresNullTerminator, IsVolatile);
+ if (std::error_code EC = BufferOrErr.getError())
+ return EC;
+ Result = std::move(BufferOrErr.get());
+ return std::error_code();
}
// FIXME: This is terrible, we need this for ::close.
@@ -1202,4 +1207,4 @@ recursive_directory_iterator::increment(
State.reset(); // end iterator
return *this;
-}
\ No newline at end of file
+}
Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=212408&r1=212407&r2=212408&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Sun Jul 6 12:43:24 2014
@@ -2794,8 +2794,9 @@ static bool IsUbuntu(enum Distro Distro)
}
static Distro DetectDistro(llvm::Triple::ArchType Arch) {
- std::unique_ptr<llvm::MemoryBuffer> File;
- if (!llvm::MemoryBuffer::getFile("/etc/lsb-release", File)) {
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> File =
+ llvm::MemoryBuffer::getFile("/etc/lsb-release");
+ if (File) {
StringRef Data = File.get()->getBuffer();
SmallVector<StringRef, 8> Lines;
Data.split(Lines, "\n");
@@ -2820,7 +2821,8 @@ static Distro DetectDistro(llvm::Triple:
return Version;
}
- if (!llvm::MemoryBuffer::getFile("/etc/redhat-release", File)) {
+ File = llvm::MemoryBuffer::getFile("/etc/redhat-release");
+ if (File) {
StringRef Data = File.get()->getBuffer();
if (Data.startswith("Fedora release"))
return Fedora;
@@ -2836,7 +2838,8 @@ static Distro DetectDistro(llvm::Triple:
return UnknownDistro;
}
- if (!llvm::MemoryBuffer::getFile("/etc/debian_version", File)) {
+ File = llvm::MemoryBuffer::getFile("/etc/debian_version");
+ if (File) {
StringRef Data = File.get()->getBuffer();
if (Data[0] == '5')
return DebianLenny;
Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=212408&r1=212407&r2=212408&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Sun Jul 6 12:43:24 2014
@@ -2082,13 +2082,14 @@ FormatStyle getStyle(StringRef StyleName
}
if (IsFile) {
- std::unique_ptr<llvm::MemoryBuffer> Text;
- if (std::error_code ec =
- llvm::MemoryBuffer::getFile(ConfigFile.c_str(), Text)) {
- llvm::errs() << ec.message() << "\n";
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Text =
+ llvm::MemoryBuffer::getFile(ConfigFile.c_str());
+ if (std::error_code EC = Text.getError()) {
+ llvm::errs() << EC.message() << "\n";
break;
}
- if (std::error_code ec = parseConfiguration(Text->getBuffer(), &Style)) {
+ if (std::error_code ec =
+ parseConfiguration(Text.get()->getBuffer(), &Style)) {
if (ec == ParseError::Unsuitable) {
if (!UnsuitableConfigFiles.empty())
UnsuitableConfigFiles.append(", ");
Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=212408&r1=212407&r2=212408&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Sun Jul 6 12:43:24 2014
@@ -683,11 +683,14 @@ bool CompilerInstance::InitializeSourceM
SourceMgr.setMainFileID(
SourceMgr.createFileID(File, SourceLocation(), Kind));
} else {
- std::unique_ptr<llvm::MemoryBuffer> SB;
- if (std::error_code ec = llvm::MemoryBuffer::getSTDIN(SB)) {
- Diags.Report(diag::err_fe_error_reading_stdin) << ec.message();
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> SBOrErr =
+ llvm::MemoryBuffer::getSTDIN();
+ if (std::error_code EC = SBOrErr.getError()) {
+ Diags.Report(diag::err_fe_error_reading_stdin) << EC.message();
return false;
}
+ std::unique_ptr<llvm::MemoryBuffer> SB = std::move(SBOrErr.get());
+
const FileEntry *File = FileMgr.getVirtualFile(SB->getBufferIdentifier(),
SB->getBufferSize(), 0);
SourceMgr.setMainFileID(
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=212408&r1=212407&r2=212408&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Sun Jul 6 12:43:24 2014
@@ -1957,14 +1957,16 @@ std::string CompilerInvocation::getModul
// $sysroot/System/Library/CoreServices/SystemVersion.plist
// as part of the module hash.
if (!hsOpts.Sysroot.empty()) {
- std::unique_ptr<llvm::MemoryBuffer> buffer;
SmallString<128> systemVersionFile;
systemVersionFile += hsOpts.Sysroot;
llvm::sys::path::append(systemVersionFile, "System");
llvm::sys::path::append(systemVersionFile, "Library");
llvm::sys::path::append(systemVersionFile, "CoreServices");
llvm::sys::path::append(systemVersionFile, "SystemVersion.plist");
- if (!llvm::MemoryBuffer::getFile(systemVersionFile.str(), buffer)) {
+
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> buffer =
+ llvm::MemoryBuffer::getFile(systemVersionFile.str());
+ if (buffer) {
code = hash_combine(code, buffer.get()->getBuffer());
struct stat statBuf;
@@ -2031,14 +2033,15 @@ createVFSFromCompilerInvocation(const Co
Overlay(new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
// earlier vfs files are on the bottom
for (const std::string &File : CI.getHeaderSearchOpts().VFSOverlayFiles) {
- std::unique_ptr<llvm::MemoryBuffer> Buffer;
- if (llvm::MemoryBuffer::getFile(File, Buffer)) {
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Buffer =
+ llvm::MemoryBuffer::getFile(File);
+ if (!Buffer) {
Diags.Report(diag::err_missing_vfs_overlay_file) << File;
return IntrusiveRefCntPtr<vfs::FileSystem>();
}
IntrusiveRefCntPtr<vfs::FileSystem> FS =
- vfs::getVFSFromYAML(Buffer.release(), /*DiagHandler*/nullptr);
+ vfs::getVFSFromYAML(Buffer->release(), /*DiagHandler*/ nullptr);
if (!FS.get()) {
Diags.Report(diag::err_invalid_vfs_overlay) << File;
return IntrusiveRefCntPtr<vfs::FileSystem>();
Modified: cfe/trunk/lib/Lex/PTHLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PTHLexer.cpp?rev=212408&r1=212407&r2=212408&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PTHLexer.cpp (original)
+++ cfe/trunk/lib/Lex/PTHLexer.cpp Sun Jul 6 12:43:24 2014
@@ -440,13 +440,15 @@ static void InvalidPTH(DiagnosticsEngine
PTHManager *PTHManager::Create(const std::string &file,
DiagnosticsEngine &Diags) {
// Memory map the PTH file.
- std::unique_ptr<llvm::MemoryBuffer> File;
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileOrErr =
+ llvm::MemoryBuffer::getFile(file);
- if (llvm::MemoryBuffer::getFile(file, File)) {
+ if (!FileOrErr) {
// FIXME: Add ec.message() to this diag.
Diags.Report(diag::err_invalid_pth_file) << file;
return nullptr;
}
+ std::unique_ptr<llvm::MemoryBuffer> File = std::move(FileOrErr.get());
using namespace llvm::support;
Modified: cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp?rev=212408&r1=212407&r2=212408&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp (original)
+++ cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp Sun Jul 6 12:43:24 2014
@@ -239,9 +239,11 @@ GlobalModuleIndex::readIndex(StringRef P
IndexPath += Path;
llvm::sys::path::append(IndexPath, IndexFileName);
- std::unique_ptr<llvm::MemoryBuffer> Buffer;
- if (llvm::MemoryBuffer::getFile(IndexPath.c_str(), Buffer))
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> BufferOrErr =
+ llvm::MemoryBuffer::getFile(IndexPath.c_str());
+ if (!BufferOrErr)
return std::make_pair(nullptr, EC_NotFound);
+ std::unique_ptr<llvm::MemoryBuffer> Buffer = std::move(BufferOrErr.get());
/// \brief The bitstream reader from which we'll read the AST file.
llvm::BitstreamReader Reader((const unsigned char *)Buffer->getBufferStart(),
Modified: cfe/trunk/lib/Serialization/ModuleManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ModuleManager.cpp?rev=212408&r1=212407&r2=212408&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ModuleManager.cpp (original)
+++ cfe/trunk/lib/Serialization/ModuleManager.cpp Sun Jul 6 12:43:24 2014
@@ -106,9 +106,13 @@ ModuleManager::addModule(StringRef FileN
// Open the AST file.
std::error_code ec;
if (FileName == "-") {
- ec = llvm::MemoryBuffer::getSTDIN(New->Buffer);
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Buf =
+ llvm::MemoryBuffer::getSTDIN();
+ ec = Buf.getError();
if (ec)
ErrorStr = ec.message();
+ else
+ New->Buffer = std::move(Buf.get());
} else {
// Leave the FileEntry open so if it gets read again by another
// ModuleManager it must be the same underlying file.
Modified: cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp?rev=212408&r1=212407&r2=212408&view=diff
==============================================================================
--- cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp (original)
+++ cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp Sun Jul 6 12:43:24 2014
@@ -144,15 +144,14 @@ volatile int JSONAnchorSource = 0;
JSONCompilationDatabase *
JSONCompilationDatabase::loadFromFile(StringRef FilePath,
std::string &ErrorMessage) {
- std::unique_ptr<llvm::MemoryBuffer> DatabaseBuffer;
- std::error_code Result =
- llvm::MemoryBuffer::getFile(FilePath, DatabaseBuffer);
- if (Result) {
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> DatabaseBuffer =
+ llvm::MemoryBuffer::getFile(FilePath);
+ if (std::error_code Result = DatabaseBuffer.getError()) {
ErrorMessage = "Error while opening JSON database: " + Result.message();
return nullptr;
}
std::unique_ptr<JSONCompilationDatabase> Database(
- new JSONCompilationDatabase(DatabaseBuffer.release()));
+ new JSONCompilationDatabase(DatabaseBuffer->release()));
if (!Database->parse(ErrorMessage))
return nullptr;
return Database.release();
Modified: cfe/trunk/tools/arcmt-test/arcmt-test.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/arcmt-test/arcmt-test.cpp?rev=212408&r1=212407&r2=212408&view=diff
==============================================================================
--- cfe/trunk/tools/arcmt-test/arcmt-test.cpp (original)
+++ cfe/trunk/tools/arcmt-test/arcmt-test.cpp Sun Jul 6 12:43:24 2014
@@ -207,17 +207,15 @@ static bool performTransformations(Strin
static bool filesCompareEqual(StringRef fname1, StringRef fname2) {
using namespace llvm;
- std::unique_ptr<MemoryBuffer> file1;
- MemoryBuffer::getFile(fname1, file1);
+ ErrorOr<std::unique_ptr<MemoryBuffer>> file1 = MemoryBuffer::getFile(fname1);
if (!file1)
return false;
- std::unique_ptr<MemoryBuffer> file2;
- MemoryBuffer::getFile(fname2, file2);
+ ErrorOr<std::unique_ptr<MemoryBuffer>> file2 = MemoryBuffer::getFile(fname2);
if (!file2)
return false;
- return file1->getBuffer() == file2->getBuffer();
+ return file1.get()->getBuffer() == file2.get()->getBuffer();
}
static bool verifyTransformedFiles(ArrayRef<std::string> resultFiles) {
@@ -238,18 +236,19 @@ static bool verifyTransformedFiles(Array
resultMap[sys::path::stem(fname)] = fname;
}
- std::unique_ptr<MemoryBuffer> inputBuf;
+ ErrorOr<std::unique_ptr<MemoryBuffer>> inputBuf = std::error_code();
if (RemappingsFile.empty())
- MemoryBuffer::getSTDIN(inputBuf);
+ inputBuf = MemoryBuffer::getSTDIN();
else
- MemoryBuffer::getFile(RemappingsFile, inputBuf);
+ inputBuf = MemoryBuffer::getFile(RemappingsFile);
if (!inputBuf) {
errs() << "error: could not read remappings input\n";
return true;
}
SmallVector<StringRef, 8> strs;
- inputBuf->getBuffer().split(strs, "\n", /*MaxSplit=*/-1, /*KeepEmpty=*/false);
+ inputBuf.get()->getBuffer().split(strs, "\n", /*MaxSplit=*/-1,
+ /*KeepEmpty=*/false);
if (strs.empty()) {
errs() << "error: no files to verify from stdin\n";
Modified: cfe/trunk/tools/clang-format/ClangFormat.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/ClangFormat.cpp?rev=212408&r1=212407&r2=212408&view=diff
==============================================================================
--- cfe/trunk/tools/clang-format/ClangFormat.cpp (original)
+++ cfe/trunk/tools/clang-format/ClangFormat.cpp Sun Jul 6 12:43:24 2014
@@ -209,11 +209,13 @@ static bool format(StringRef FileName) {
IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs),
new DiagnosticOptions);
SourceManager Sources(Diagnostics, Files);
- std::unique_ptr<MemoryBuffer> Code;
- if (std::error_code ec = MemoryBuffer::getFileOrSTDIN(FileName, Code)) {
- llvm::errs() << ec.message() << "\n";
+ ErrorOr<std::unique_ptr<MemoryBuffer>> CodeOrErr =
+ MemoryBuffer::getFileOrSTDIN(FileName);
+ if (std::error_code EC = CodeOrErr.getError()) {
+ llvm::errs() << EC.message() << "\n";
return true;
}
+ std::unique_ptr<llvm::MemoryBuffer> Code = std::move(CodeOrErr.get());
if (Code->getBufferSize() == 0)
return false; // Empty files are formatted correctly.
FileID ID = createInMemoryFile(FileName, Code.get(), Sources, Files);
Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=212408&r1=212407&r2=212408&view=diff
==============================================================================
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Sun Jul 6 12:43:24 2014
@@ -281,17 +281,18 @@ static bool ExecuteAssembler(AssemblerIn
if (!TheTarget)
return Diags.Report(diag::err_target_unknown_triple) << Opts.Triple;
- std::unique_ptr<MemoryBuffer> Buffer;
- if (std::error_code ec =
- MemoryBuffer::getFileOrSTDIN(Opts.InputFile, Buffer)) {
- Error = ec.message();
+ ErrorOr<std::unique_ptr<MemoryBuffer>> Buffer =
+ MemoryBuffer::getFileOrSTDIN(Opts.InputFile);
+
+ if (std::error_code EC = Buffer.getError()) {
+ Error = EC.message();
return Diags.Report(diag::err_fe_error_reading) << Opts.InputFile;
}
SourceMgr SrcMgr;
// Tell SrcMgr about this buffer, which is what the parser will pick up.
- SrcMgr.AddNewSourceBuffer(Buffer.release(), SMLoc());
+ SrcMgr.AddNewSourceBuffer(Buffer->release(), SMLoc());
// Record the location of the include directories so that the lexer can find
// it later.
More information about the cfe-commits
mailing list