Converted uses of scoped_ptr to OwningPtr.

llvm-svn: 45265
This commit is contained in:
Ted Kremenek 2007-12-20 19:47:16 +00:00
parent 63b19f1b6e
commit 71d643f8b1
5 changed files with 21 additions and 19 deletions

View File

@ -20,7 +20,7 @@
#include "llvm/Bitcode/Deserialize.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/System/Path.h"
#include "llvm/ADT/scoped_ptr.h"
#include "llvm/ADT/OwningPtr.h"
#include <stdio.h>
@ -125,7 +125,7 @@ TranslationUnit*
clang::ReadASTBitcodeFile(const llvm::sys::Path& Filename, FileManager& FMgr) {
// Create the memory buffer that contains the contents of the file.
llvm::scoped_ptr<llvm::MemoryBuffer>
llvm::OwningPtr<llvm::MemoryBuffer>
MBuffer(llvm::MemoryBuffer::getFile(Filename.c_str(),
strlen(Filename.c_str())));

View File

@ -663,23 +663,25 @@ public:
// FIXME: This is not portable to Windows.
// FIXME: This logic should probably be moved elsewhere later.
llvm::sys::Path ASTFile(EmitDir);
llvm::sys::Path FName(EmitDir);
std::vector<char> buf;
buf.reserve(strlen(FE->getName())+100);
sprintf(&buf[0], "dev_%llx", (uint64_t) FE->getDevice());
ASTFile.appendComponent(&buf[0]);
ASTFile.createDirectoryOnDisk(true);
if (!ASTFile.canWrite() || !ASTFile.isDirectory()) {
FName.appendComponent(&buf[0]);
FName.createDirectoryOnDisk(true);
if (!FName.canWrite() || !FName.isDirectory()) {
assert (false && "Could not create 'device' serialization directory.");
return;
}
sprintf(&buf[0], "%s-%llX.ast", FE->getName(), (uint64_t) FE->getInode());
ASTFile.appendComponent(&buf[0]);
FName.appendComponent(&buf[0]);
EmitASTBitcodeFile(TU,FName);
// Now emit the sources.
EmitASTBitcodeFile(TU,ASTFile);
}
};

View File

@ -20,7 +20,7 @@
#include "ASTConsumers.h"
#include "clang/AST/TranslationUnit.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/ADT/scoped_ptr.h"
#include "llvm/ADT/OwningPtr.h"
#include "llvm/Support/Streams.h"
#include <fstream>
@ -71,7 +71,7 @@ bool SerializationTest::Serialize(llvm::sys::Path& Filename,
// Pretty-print the decls to a temp file.
std::ofstream DeclPP(FNameDeclPrint.c_str());
assert (DeclPP && "Could not open file for printing out decls.");
llvm::scoped_ptr<ASTConsumer> FilePrinter(CreateASTPrinter(&DeclPP));
llvm::OwningPtr<ASTConsumer> FilePrinter(CreateASTPrinter(&DeclPP));
for (TranslationUnit::iterator I=TU.begin(), E=TU.end(); I!=E; ++I)
FilePrinter->HandleTopLevelDecl(*I);
@ -94,7 +94,7 @@ bool SerializationTest::Deserialize(llvm::sys::Path& Filename,
// Pretty-print the deserialized decls to a temp file.
std::ofstream DeclPP(FNameDeclPrint.c_str());
assert (DeclPP && "Could not open file for printing out decls.");
llvm::scoped_ptr<ASTConsumer> FilePrinter(CreateASTPrinter(&DeclPP));
llvm::OwningPtr<ASTConsumer> FilePrinter(CreateASTPrinter(&DeclPP));
for (TranslationUnit::iterator I=NewTU->begin(), E=NewTU->end(); I!=E; ++I)
FilePrinter->HandleTopLevelDecl(*I);
@ -162,7 +162,7 @@ SerializationTest::~SerializationTest() {
using llvm::MemoryBuffer;
llvm::scoped_ptr<MemoryBuffer>
llvm::OwningPtr<MemoryBuffer>
MBufferSer(MemoryBuffer::getFile(FNameDeclBefore.c_str(),
strlen(FNameDeclBefore.c_str())));
@ -171,7 +171,7 @@ SerializationTest::~SerializationTest() {
return;
}
llvm::scoped_ptr<MemoryBuffer>
llvm::OwningPtr<MemoryBuffer>
MBufferDSer(MemoryBuffer::getFile(FNameDeclAfter.c_str(),
strlen(FNameDeclAfter.c_str())));

View File

@ -39,7 +39,7 @@
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/System/Signals.h"
#include "llvm/Config/config.h"
#include "llvm/ADT/scoped_ptr.h"
#include "llvm/ADT/OwningPtr.h"
#include <memory>
using namespace clang;
@ -1040,7 +1040,7 @@ static void ProcessSerializedFile(const std::string& InFile, Diagnostic& Diag,
exit (1);
}
llvm::scoped_ptr<TranslationUnit> TU(ReadASTBitcodeFile(Filename,FileMgr));
llvm::OwningPtr<TranslationUnit> TU(ReadASTBitcodeFile(Filename,FileMgr));
if (!TU) {
fprintf(stderr, "error: file '%s' could not be deserialized\n",
@ -1050,7 +1050,7 @@ static void ProcessSerializedFile(const std::string& InFile, Diagnostic& Diag,
// Observe that we use the source file name stored in the deserialized
// translation unit, rather than InFile.
llvm::scoped_ptr<ASTConsumer>
llvm::OwningPtr<ASTConsumer>
Consumer(CreateASTConsumer(InFile, Diag, FileMgr, TU->getLangOpts()));
if (!Consumer) {

View File

@ -13,7 +13,7 @@
#include "clang/Lex/HeaderMap.h"
#include "clang/Basic/FileManager.h"
#include "llvm/ADT/scoped_ptr.h"
#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/MathExtras.h"
@ -78,7 +78,7 @@ const HeaderMap *HeaderMap::Create(const FileEntry *FE) {
unsigned FileSize = FE->getSize();
if (FileSize <= sizeof(HMapHeader)) return 0;
llvm::scoped_ptr<const llvm::MemoryBuffer> FileBuffer(
llvm::OwningPtr<const llvm::MemoryBuffer> FileBuffer(
llvm::MemoryBuffer::getFile(FE->getName(), strlen(FE->getName()), 0,
FE->getSize()));
if (FileBuffer == 0) return 0; // Unreadable file?