mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-07 22:27:13 +00:00
Update for LLVM api change.
llvm-svn: 216585
This commit is contained in:
parent
7fa030330c
commit
d87f8d76e0
@ -4919,10 +4919,11 @@ FileID ASTImporter::Import(FileID FromID) {
|
||||
// FIXME: We want to re-use the existing MemoryBuffer!
|
||||
const llvm::MemoryBuffer *
|
||||
FromBuf = Cache->getBuffer(FromContext.getDiagnostics(), FromSM);
|
||||
llvm::MemoryBuffer *ToBuf
|
||||
std::unique_ptr<llvm::MemoryBuffer> ToBuf
|
||||
= llvm::MemoryBuffer::getMemBufferCopy(FromBuf->getBuffer(),
|
||||
FromBuf->getBufferIdentifier());
|
||||
ToID = ToSM.createFileID(ToBuf, FromSLoc.getFile().getFileCharacteristic());
|
||||
ToID = ToSM.createFileID(ToBuf.release(),
|
||||
FromSLoc.getFile().getFileCharacteristic());
|
||||
}
|
||||
|
||||
|
||||
|
@ -112,8 +112,8 @@ llvm::MemoryBuffer *ContentCache::getBuffer(DiagnosticsEngine &Diag,
|
||||
// possible.
|
||||
if (!Buffer.getPointer()) {
|
||||
const StringRef FillStr("<<<MISSING SOURCE FILE>>>\n");
|
||||
Buffer.setPointer(MemoryBuffer::getNewMemBuffer(ContentsEntry->getSize(),
|
||||
"<invalid>"));
|
||||
Buffer.setPointer(MemoryBuffer::getNewMemBuffer(ContentsEntry->getSize(),
|
||||
"<invalid>").release());
|
||||
char *Ptr = const_cast<char*>(Buffer.getPointer()->getBufferStart());
|
||||
for (unsigned i = 0, e = ContentsEntry->getSize(); i != e; ++i)
|
||||
Ptr[i] = FillStr[i % FillStr.size()];
|
||||
@ -501,8 +501,8 @@ SourceManager::AllocateLoadedSLocEntries(unsigned NumSLocEntries,
|
||||
/// fake, non-empty buffer.
|
||||
llvm::MemoryBuffer *SourceManager::getFakeBufferForRecovery() const {
|
||||
if (!FakeBufferForRecovery)
|
||||
FakeBufferForRecovery.reset(
|
||||
llvm::MemoryBuffer::getMemBuffer("<<<INVALID BUFFER>>"));
|
||||
FakeBufferForRecovery =
|
||||
llvm::MemoryBuffer::getMemBuffer("<<<INVALID BUFFER>>");
|
||||
|
||||
return FakeBufferForRecovery.get();
|
||||
}
|
||||
|
@ -273,11 +273,11 @@ static FullSourceLoc ConvertBackendLocation(const llvm::SMDiagnostic &D,
|
||||
|
||||
// Create the copy and transfer ownership to clang::SourceManager.
|
||||
// TODO: Avoid copying files into memory.
|
||||
llvm::MemoryBuffer *CBuf =
|
||||
llvm::MemoryBuffer::getMemBufferCopy(LBuf->getBuffer(),
|
||||
LBuf->getBufferIdentifier());
|
||||
std::unique_ptr<llvm::MemoryBuffer> CBuf =
|
||||
llvm::MemoryBuffer::getMemBufferCopy(LBuf->getBuffer(),
|
||||
LBuf->getBufferIdentifier());
|
||||
// FIXME: Keep a file ID map instead of creating new IDs for each location.
|
||||
FileID FID = CSM.createFileID(CBuf);
|
||||
FileID FID = CSM.createFileID(CBuf.release());
|
||||
|
||||
// Translate the offset into the file.
|
||||
unsigned Offset = D.getLoc().getPointer() - LBuf->getBufferStart();
|
||||
|
@ -1992,10 +1992,11 @@ tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
|
||||
IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs),
|
||||
new DiagnosticOptions);
|
||||
SourceManager SourceMgr(Diagnostics, Files);
|
||||
llvm::MemoryBuffer *Buf = llvm::MemoryBuffer::getMemBuffer(Code, FileName);
|
||||
std::unique_ptr<llvm::MemoryBuffer> Buf =
|
||||
llvm::MemoryBuffer::getMemBuffer(Code, FileName);
|
||||
const clang::FileEntry *Entry =
|
||||
Files.getVirtualFile(FileName, Buf->getBufferSize(), 0);
|
||||
SourceMgr.overrideFileContents(Entry, Buf);
|
||||
SourceMgr.overrideFileContents(Entry, Buf.release());
|
||||
FileID ID =
|
||||
SourceMgr.createFileID(Entry, SourceLocation(), clang::SrcMgr::C_User);
|
||||
Lexer Lex(ID, SourceMgr.getBuffer(ID), SourceMgr,
|
||||
|
@ -1451,10 +1451,8 @@ ASTUnit::getMainBufferWithPrecompiledPreamble(
|
||||
PreambleInvocation->getDiagnosticOpts());
|
||||
getDiagnostics().setNumWarnings(NumWarningsInPreamble);
|
||||
|
||||
return std::unique_ptr<llvm::MemoryBuffer>(
|
||||
llvm::MemoryBuffer::getMemBufferCopy(
|
||||
NewPreamble.first->getBuffer(),
|
||||
FrontendOpts.Inputs[0].getFile()));
|
||||
return llvm::MemoryBuffer::getMemBufferCopy(
|
||||
NewPreamble.first->getBuffer(), FrontendOpts.Inputs[0].getFile());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1504,8 +1502,8 @@ ASTUnit::getMainBufferWithPrecompiledPreamble(
|
||||
+ NewPreamble.second.first);
|
||||
PreambleEndsAtStartOfLine = NewPreamble.second.second;
|
||||
|
||||
PreambleBuffer.reset(llvm::MemoryBuffer::getMemBufferCopy(
|
||||
NewPreamble.first->getBuffer().slice(0, Preamble.size()), MainFilename));
|
||||
PreambleBuffer = llvm::MemoryBuffer::getMemBufferCopy(
|
||||
NewPreamble.first->getBuffer().slice(0, Preamble.size()), MainFilename);
|
||||
|
||||
// Remap the main source file to the preamble buffer.
|
||||
StringRef MainFilePath = FrontendOpts.Inputs[0].getFile();
|
||||
@ -1649,9 +1647,8 @@ ASTUnit::getMainBufferWithPrecompiledPreamble(
|
||||
PreambleTopLevelHashValue = CurrentTopLevelHashValue;
|
||||
}
|
||||
|
||||
return std::unique_ptr<llvm::MemoryBuffer>(
|
||||
llvm::MemoryBuffer::getMemBufferCopy(NewPreamble.first->getBuffer(),
|
||||
MainFilename));
|
||||
return llvm::MemoryBuffer::getMemBufferCopy(NewPreamble.first->getBuffer(),
|
||||
MainFilename);
|
||||
}
|
||||
|
||||
void ASTUnit::RealizeTopLevelDeclsFromPreamble() {
|
||||
|
@ -176,8 +176,7 @@ IntrusiveRefCntPtr<ExternalSemaSource> clang::createChainedIncludesSource(
|
||||
// TODO: Pass through the existing MemoryBuffer instances instead of
|
||||
// allocating new ones.
|
||||
for (auto &SB : SerialBufs)
|
||||
Bufs.push_back(std::unique_ptr<llvm::MemoryBuffer>(
|
||||
llvm::MemoryBuffer::getMemBuffer(SB->getBuffer())));
|
||||
Bufs.push_back(llvm::MemoryBuffer::getMemBuffer(SB->getBuffer()));
|
||||
std::string pchName = includes[i-1];
|
||||
llvm::raw_string_ostream os(pchName);
|
||||
os << ".pch" << i-1;
|
||||
@ -198,8 +197,7 @@ IntrusiveRefCntPtr<ExternalSemaSource> clang::createChainedIncludesSource(
|
||||
|
||||
ParseAST(Clang->getSema());
|
||||
Clang->getDiagnosticClient().EndSourceFile();
|
||||
SerialBufs.push_back(std::unique_ptr<llvm::MemoryBuffer>(
|
||||
llvm::MemoryBuffer::getMemBufferCopy(OS.str())));
|
||||
SerialBufs.push_back(llvm::MemoryBuffer::getMemBufferCopy(OS.str()));
|
||||
source->CIs.push_back(Clang.release());
|
||||
}
|
||||
|
||||
|
@ -947,11 +947,11 @@ static bool compileModuleImpl(CompilerInstance &ImportingInstance,
|
||||
FrontendOpts.Inputs.push_back(
|
||||
FrontendInputFile("__inferred_module.map", IK));
|
||||
|
||||
llvm::MemoryBuffer *ModuleMapBuffer =
|
||||
std::unique_ptr<llvm::MemoryBuffer> ModuleMapBuffer =
|
||||
llvm::MemoryBuffer::getMemBuffer(InferredModuleMapContent);
|
||||
ModuleMapFile = Instance.getFileManager().getVirtualFile(
|
||||
"__inferred_module.map", InferredModuleMapContent.size(), 0);
|
||||
SourceMgr.overrideFileContents(ModuleMapFile, ModuleMapBuffer);
|
||||
SourceMgr.overrideFileContents(ModuleMapFile, ModuleMapBuffer.release());
|
||||
}
|
||||
|
||||
// Construct a module-generating action. Passing through the module map is
|
||||
|
@ -331,11 +331,11 @@ bool GenerateModuleAction::BeginSourceFileAction(CompilerInstance &CI,
|
||||
return false;
|
||||
}
|
||||
|
||||
llvm::MemoryBuffer *InputBuffer =
|
||||
std::unique_ptr<llvm::MemoryBuffer> InputBuffer =
|
||||
llvm::MemoryBuffer::getMemBufferCopy(HeaderContents,
|
||||
Module::getModuleInputBufferName());
|
||||
// Ownership of InputBuffer will be transferred to the SourceManager.
|
||||
setCurrentInput(FrontendInputFile(InputBuffer, getCurrentFileKind(),
|
||||
setCurrentInput(FrontendInputFile(InputBuffer.release(), getCurrentFileKind(),
|
||||
Module->IsSystem));
|
||||
return true;
|
||||
}
|
||||
|
@ -47,10 +47,11 @@ public:
|
||||
~SimpleFormatContext() { }
|
||||
|
||||
FileID createInMemoryFile(StringRef Name, StringRef Content) {
|
||||
llvm::MemoryBuffer *Source = llvm::MemoryBuffer::getMemBuffer(Content);
|
||||
std::unique_ptr<llvm::MemoryBuffer> Source =
|
||||
llvm::MemoryBuffer::getMemBuffer(Content);
|
||||
const FileEntry *Entry =
|
||||
Files.getVirtualFile(Name, Source->getBufferSize(), 0);
|
||||
Sources.overrideFileContents(Entry, Source);
|
||||
Sources.overrideFileContents(Entry, Source.release());
|
||||
assert(Entry != nullptr);
|
||||
return Sources.createFileID(Entry, SourceLocation(), SrcMgr::C_User);
|
||||
}
|
||||
|
@ -399,14 +399,14 @@ bool Preprocessor::SetCodeCompletionPoint(const FileEntry *File,
|
||||
CodeCompletionFile = File;
|
||||
CodeCompletionOffset = Position - Buffer->getBufferStart();
|
||||
|
||||
MemoryBuffer *NewBuffer =
|
||||
std::unique_ptr<MemoryBuffer> NewBuffer =
|
||||
MemoryBuffer::getNewUninitMemBuffer(Buffer->getBufferSize() + 1,
|
||||
Buffer->getBufferIdentifier());
|
||||
char *NewBuf = const_cast<char*>(NewBuffer->getBufferStart());
|
||||
char *NewPos = std::copy(Buffer->getBufferStart(), Position, NewBuf);
|
||||
*NewPos = '\0';
|
||||
std::copy(Position, Buffer->getBufferEnd(), NewPos+1);
|
||||
SourceMgr.overrideFileContents(File, NewBuffer);
|
||||
SourceMgr.overrideFileContents(File, NewBuffer.release());
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -503,10 +503,10 @@ void Preprocessor::EnterMainSourceFile() {
|
||||
}
|
||||
|
||||
// Preprocess Predefines to populate the initial preprocessor state.
|
||||
llvm::MemoryBuffer *SB =
|
||||
std::unique_ptr<llvm::MemoryBuffer> SB =
|
||||
llvm::MemoryBuffer::getMemBufferCopy(Predefines, "<built-in>");
|
||||
assert(SB && "Cannot create predefined source buffer");
|
||||
FileID FID = SourceMgr.createFileID(SB);
|
||||
FileID FID = SourceMgr.createFileID(SB.release());
|
||||
assert(!FID.isInvalid() && "Could not create FileID for predefines?");
|
||||
setPredefinesFileID(FID);
|
||||
|
||||
|
@ -64,11 +64,12 @@ void ScratchBuffer::AllocScratchBuffer(unsigned RequestLen) {
|
||||
if (RequestLen < ScratchBufSize)
|
||||
RequestLen = ScratchBufSize;
|
||||
|
||||
llvm::MemoryBuffer *Buf =
|
||||
llvm::MemoryBuffer::getNewMemBuffer(RequestLen, "<scratch space>");
|
||||
FileID FID = SourceMgr.createFileID(Buf);
|
||||
std::unique_ptr<llvm::MemoryBuffer> OwnBuf =
|
||||
llvm::MemoryBuffer::getNewMemBuffer(RequestLen, "<scratch space>");
|
||||
llvm::MemoryBuffer &Buf = *OwnBuf;
|
||||
FileID FID = SourceMgr.createFileID(OwnBuf.release());
|
||||
BufferStartLoc = SourceMgr.getLocForStartOfFile(FID);
|
||||
CurBuffer = const_cast<char*>(Buf->getBufferStart());
|
||||
CurBuffer = const_cast<char*>(Buf.getBufferStart());
|
||||
BytesUsed = 1;
|
||||
CurBuffer[0] = '0'; // Start out with a \0 for cleanliness.
|
||||
}
|
||||
|
@ -498,8 +498,8 @@ StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) {
|
||||
|
||||
llvm::SourceMgr TempSrcMgr;
|
||||
llvm::MCContext Ctx(MAI.get(), MRI.get(), MOFI.get(), &TempSrcMgr);
|
||||
std::unique_ptr<llvm::MemoryBuffer> Buffer(
|
||||
llvm::MemoryBuffer::getMemBuffer(AsmString, "<MS inline asm>"));
|
||||
std::unique_ptr<llvm::MemoryBuffer> Buffer =
|
||||
llvm::MemoryBuffer::getMemBuffer(AsmString, "<MS inline asm>");
|
||||
|
||||
// Tell SrcMgr about this buffer, which is what the parser will pick up.
|
||||
TempSrcMgr.AddNewSourceBuffer(std::move(Buffer), llvm::SMLoc());
|
||||
|
@ -1224,9 +1224,9 @@ bool ASTReader::ReadSLocEntry(int ID) {
|
||||
return true;
|
||||
}
|
||||
|
||||
llvm::MemoryBuffer *Buffer
|
||||
std::unique_ptr<llvm::MemoryBuffer> Buffer
|
||||
= llvm::MemoryBuffer::getMemBuffer(Blob.drop_back(1), File->getName());
|
||||
SourceMgr.overrideFileContents(File, Buffer);
|
||||
SourceMgr.overrideFileContents(File, Buffer.release());
|
||||
}
|
||||
|
||||
break;
|
||||
@ -1251,10 +1251,10 @@ bool ASTReader::ReadSLocEntry(int ID) {
|
||||
return true;
|
||||
}
|
||||
|
||||
llvm::MemoryBuffer *Buffer
|
||||
= llvm::MemoryBuffer::getMemBuffer(Blob.drop_back(1), Name);
|
||||
SourceMgr.createFileID(Buffer, FileCharacter, ID, BaseOffset + Offset,
|
||||
IncludeLoc);
|
||||
std::unique_ptr<llvm::MemoryBuffer> Buffer =
|
||||
llvm::MemoryBuffer::getMemBuffer(Blob.drop_back(1), Name);
|
||||
SourceMgr.createFileID(Buffer.release(), FileCharacter, ID,
|
||||
BaseOffset + Offset, IncludeLoc);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -182,10 +182,11 @@ std::string applyAllReplacements(StringRef Code, const Replacements &Replaces) {
|
||||
llvm::outs(), &Diagnostics.getDiagnosticOptions()));
|
||||
SourceManager SourceMgr(Diagnostics, Files);
|
||||
Rewriter Rewrite(SourceMgr, LangOptions());
|
||||
llvm::MemoryBuffer *Buf = llvm::MemoryBuffer::getMemBuffer(Code, "<stdin>");
|
||||
std::unique_ptr<llvm::MemoryBuffer> Buf =
|
||||
llvm::MemoryBuffer::getMemBuffer(Code, "<stdin>");
|
||||
const clang::FileEntry *Entry =
|
||||
Files.getVirtualFile("<stdin>", Buf->getBufferSize(), 0);
|
||||
SourceMgr.overrideFileContents(Entry, Buf);
|
||||
SourceMgr.overrideFileContents(Entry, Buf.release());
|
||||
FileID ID =
|
||||
SourceMgr.createFileID(Entry, SourceLocation(), clang::SrcMgr::C_User);
|
||||
for (Replacements::const_iterator I = Replaces.begin(), E = Replaces.end();
|
||||
|
@ -223,8 +223,10 @@ bool ToolInvocation::run() {
|
||||
newInvocation(&Diagnostics, *CC1Args));
|
||||
for (const auto &It : MappedFileContents) {
|
||||
// Inject the code as the given file name into the preprocessor options.
|
||||
auto *Input = llvm::MemoryBuffer::getMemBuffer(It.getValue());
|
||||
Invocation->getPreprocessorOpts().addRemappedFile(It.getKey(), Input);
|
||||
std::unique_ptr<llvm::MemoryBuffer> Input =
|
||||
llvm::MemoryBuffer::getMemBuffer(It.getValue());
|
||||
Invocation->getPreprocessorOpts().addRemappedFile(It.getKey(),
|
||||
Input.release());
|
||||
}
|
||||
return runInvocation(BinaryName, Compilation.get(), Invocation.release());
|
||||
}
|
||||
|
@ -2876,9 +2876,9 @@ static void clang_parseTranslationUnit_Impl(void *UserData) {
|
||||
std::vector<ASTUnit::RemappedFile> > RemappedCleanup(RemappedFiles.get());
|
||||
|
||||
for (auto &UF : PTUI->unsaved_files) {
|
||||
llvm::MemoryBuffer *MB =
|
||||
std::unique_ptr<llvm::MemoryBuffer> MB =
|
||||
llvm::MemoryBuffer::getMemBufferCopy(getContents(UF), UF.Filename);
|
||||
RemappedFiles->push_back(std::make_pair(UF.Filename, MB));
|
||||
RemappedFiles->push_back(std::make_pair(UF.Filename, MB.release()));
|
||||
}
|
||||
|
||||
std::unique_ptr<std::vector<const char *>> Args(
|
||||
@ -3160,9 +3160,9 @@ static void clang_reparseTranslationUnit_Impl(void *UserData) {
|
||||
std::vector<ASTUnit::RemappedFile> > RemappedCleanup(RemappedFiles.get());
|
||||
|
||||
for (auto &UF : RTUI->unsaved_files) {
|
||||
llvm::MemoryBuffer *MB =
|
||||
std::unique_ptr<llvm::MemoryBuffer> MB =
|
||||
llvm::MemoryBuffer::getMemBufferCopy(getContents(UF), UF.Filename);
|
||||
RemappedFiles->push_back(std::make_pair(UF.Filename, MB));
|
||||
RemappedFiles->push_back(std::make_pair(UF.Filename, MB.release()));
|
||||
}
|
||||
|
||||
if (!CXXUnit->Reparse(*RemappedFiles.get()))
|
||||
|
@ -692,9 +692,9 @@ void clang_codeCompleteAt_Impl(void *UserData) {
|
||||
SmallVector<ASTUnit::RemappedFile, 4> RemappedFiles;
|
||||
|
||||
for (auto &UF : CCAI->unsaved_files) {
|
||||
llvm::MemoryBuffer *MB =
|
||||
std::unique_ptr<llvm::MemoryBuffer> MB =
|
||||
llvm::MemoryBuffer::getMemBufferCopy(getContents(UF), UF.Filename);
|
||||
RemappedFiles.push_back(std::make_pair(UF.Filename, MB));
|
||||
RemappedFiles.push_back(std::make_pair(UF.Filename, MB.release()));
|
||||
}
|
||||
|
||||
if (EnableLogging) {
|
||||
|
@ -575,10 +575,10 @@ static void clang_indexSourceFile_Impl(void *UserData) {
|
||||
BufOwner.get());
|
||||
|
||||
for (auto &UF : ITUI->unsaved_files) {
|
||||
llvm::MemoryBuffer *MB =
|
||||
std::unique_ptr<llvm::MemoryBuffer> MB =
|
||||
llvm::MemoryBuffer::getMemBufferCopy(getContents(UF), UF.Filename);
|
||||
BufOwner->push_back(std::unique_ptr<llvm::MemoryBuffer>(MB));
|
||||
CInvok->getPreprocessorOpts().addRemappedFile(UF.Filename, MB);
|
||||
CInvok->getPreprocessorOpts().addRemappedFile(UF.Filename, MB.get());
|
||||
BufOwner->push_back(std::move(MB));
|
||||
}
|
||||
|
||||
// Since libclang is primarily used by batch tools dealing with
|
||||
|
@ -60,8 +60,8 @@ protected:
|
||||
|
||||
void CommentLexerTest::lexString(const char *Source,
|
||||
std::vector<Token> &Toks) {
|
||||
MemoryBuffer *Buf = MemoryBuffer::getMemBuffer(Source);
|
||||
FileID File = SourceMgr.createFileID(Buf);
|
||||
std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(Source);
|
||||
FileID File = SourceMgr.createFileID(Buf.release());
|
||||
SourceLocation Begin = SourceMgr.getLocForStartOfFile(File);
|
||||
|
||||
Lexer L(Allocator, Diags, Traits, Begin, Source, Source + strlen(Source));
|
||||
|
@ -54,8 +54,8 @@ protected:
|
||||
};
|
||||
|
||||
FullComment *CommentParserTest::parseString(const char *Source) {
|
||||
MemoryBuffer *Buf = MemoryBuffer::getMemBuffer(Source);
|
||||
FileID File = SourceMgr.createFileID(Buf);
|
||||
std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(Source);
|
||||
FileID File = SourceMgr.createFileID(Buf.release());
|
||||
SourceLocation Begin = SourceMgr.getLocForStartOfFile(File);
|
||||
|
||||
Lexer L(Allocator, Diags, Traits, Begin, Source, Source + strlen(Source));
|
||||
|
@ -50,7 +50,7 @@ bool testExternalASTSource(ExternalASTSource *Source,
|
||||
|
||||
CompilerInvocation *Invocation = new CompilerInvocation;
|
||||
Invocation->getPreprocessorOpts().addRemappedFile(
|
||||
"test.cc", MemoryBuffer::getMemBuffer(FileContents));
|
||||
"test.cc", MemoryBuffer::getMemBuffer(FileContents).release());
|
||||
const char *Args[] = { "test.cc" };
|
||||
CompilerInvocation::CreateFromArgs(*Invocation, Args,
|
||||
Args + array_lengthof(Args),
|
||||
|
@ -74,8 +74,8 @@ TEST_F(SourceManagerTest, isBeforeInTranslationUnit) {
|
||||
const char *source =
|
||||
"#define M(x) [x]\n"
|
||||
"M(foo)";
|
||||
MemoryBuffer *buf = MemoryBuffer::getMemBuffer(source);
|
||||
FileID mainFileID = SourceMgr.createFileID(buf);
|
||||
std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(source);
|
||||
FileID mainFileID = SourceMgr.createFileID(Buf.release());
|
||||
SourceMgr.setMainFileID(mainFileID);
|
||||
|
||||
VoidModuleLoader ModLoader;
|
||||
@ -127,8 +127,8 @@ TEST_F(SourceManagerTest, getColumnNumber) {
|
||||
"int x;\n"
|
||||
"int y;";
|
||||
|
||||
MemoryBuffer *Buf = MemoryBuffer::getMemBuffer(Source);
|
||||
FileID MainFileID = SourceMgr.createFileID(Buf);
|
||||
std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(Source);
|
||||
FileID MainFileID = SourceMgr.createFileID(Buf.release());
|
||||
SourceMgr.setMainFileID(MainFileID);
|
||||
|
||||
bool Invalid;
|
||||
@ -186,14 +186,14 @@ TEST_F(SourceManagerTest, getMacroArgExpandedLocation) {
|
||||
"#define CONCAT(X, Y) X##Y\n"
|
||||
"CONCAT(1,1)\n";
|
||||
|
||||
MemoryBuffer *headerBuf = MemoryBuffer::getMemBuffer(header);
|
||||
MemoryBuffer *mainBuf = MemoryBuffer::getMemBuffer(main);
|
||||
FileID mainFileID = SourceMgr.createFileID(mainBuf);
|
||||
std::unique_ptr<MemoryBuffer> HeaderBuf = MemoryBuffer::getMemBuffer(header);
|
||||
std::unique_ptr<MemoryBuffer> MainBuf = MemoryBuffer::getMemBuffer(main);
|
||||
FileID mainFileID = SourceMgr.createFileID(MainBuf.release());
|
||||
SourceMgr.setMainFileID(mainFileID);
|
||||
|
||||
const FileEntry *headerFile = FileMgr.getVirtualFile("/test-header.h",
|
||||
headerBuf->getBufferSize(), 0);
|
||||
SourceMgr.overrideFileContents(headerFile, headerBuf);
|
||||
HeaderBuf->getBufferSize(), 0);
|
||||
SourceMgr.overrideFileContents(headerFile, HeaderBuf.release());
|
||||
|
||||
VoidModuleLoader ModLoader;
|
||||
HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts,
|
||||
@ -285,13 +285,13 @@ TEST_F(SourceManagerTest, isBeforeInTranslationUnitWithMacroInInclude) {
|
||||
"#define INC2 </test-header.h>\n"
|
||||
"#include M(INC2)\n";
|
||||
|
||||
MemoryBuffer *headerBuf = MemoryBuffer::getMemBuffer(header);
|
||||
MemoryBuffer *mainBuf = MemoryBuffer::getMemBuffer(main);
|
||||
SourceMgr.setMainFileID(SourceMgr.createFileID(mainBuf));
|
||||
std::unique_ptr<MemoryBuffer> HeaderBuf = MemoryBuffer::getMemBuffer(header);
|
||||
std::unique_ptr<MemoryBuffer> MainBuf = MemoryBuffer::getMemBuffer(main);
|
||||
SourceMgr.setMainFileID(SourceMgr.createFileID(MainBuf.release()));
|
||||
|
||||
const FileEntry *headerFile = FileMgr.getVirtualFile("/test-header.h",
|
||||
headerBuf->getBufferSize(), 0);
|
||||
SourceMgr.overrideFileContents(headerFile, headerBuf);
|
||||
HeaderBuf->getBufferSize(), 0);
|
||||
SourceMgr.overrideFileContents(headerFile, HeaderBuf.release());
|
||||
|
||||
VoidModuleLoader ModLoader;
|
||||
HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts,
|
||||
|
@ -539,7 +539,7 @@ public:
|
||||
IntrusiveRefCntPtr<vfs::FileSystem>
|
||||
getFromYAMLRawString(StringRef Content,
|
||||
IntrusiveRefCntPtr<vfs::FileSystem> ExternalFS) {
|
||||
std::unique_ptr<MemoryBuffer> Buffer(MemoryBuffer::getMemBuffer(Content));
|
||||
std::unique_ptr<MemoryBuffer> Buffer = MemoryBuffer::getMemBuffer(Content);
|
||||
return getVFSFromYAML(std::move(Buffer), CountingDiagHandler, this,
|
||||
ExternalFS);
|
||||
}
|
||||
|
@ -69,8 +69,9 @@ TEST(BufferSourceTest, EmitCXXGlobalInitFunc) {
|
||||
compiler.createSema(clang::TU_Prefix,NULL);
|
||||
|
||||
clang::SourceManager &sm = compiler.getSourceManager();
|
||||
sm.setMainFileID(sm.createFileID(
|
||||
llvm::MemoryBuffer::getMemBuffer(TestProgram), clang::SrcMgr::C_User));
|
||||
sm.setMainFileID(
|
||||
sm.createFileID(llvm::MemoryBuffer::getMemBuffer(TestProgram).release(),
|
||||
clang::SrcMgr::C_User));
|
||||
|
||||
clang::ParseAST(compiler.getSema(), false, false);
|
||||
}
|
||||
|
@ -65,7 +65,8 @@ private:
|
||||
TEST(ASTFrontendAction, Sanity) {
|
||||
CompilerInvocation *invocation = new CompilerInvocation;
|
||||
invocation->getPreprocessorOpts().addRemappedFile(
|
||||
"test.cc", MemoryBuffer::getMemBuffer("int main() { float x; }"));
|
||||
"test.cc",
|
||||
MemoryBuffer::getMemBuffer("int main() { float x; }").release());
|
||||
invocation->getFrontendOpts().Inputs.push_back(FrontendInputFile("test.cc",
|
||||
IK_CXX));
|
||||
invocation->getFrontendOpts().ProgramAction = frontend::ParseSyntaxOnly;
|
||||
@ -84,7 +85,8 @@ TEST(ASTFrontendAction, Sanity) {
|
||||
TEST(ASTFrontendAction, IncrementalParsing) {
|
||||
CompilerInvocation *invocation = new CompilerInvocation;
|
||||
invocation->getPreprocessorOpts().addRemappedFile(
|
||||
"test.cc", MemoryBuffer::getMemBuffer("int main() { float x; }"));
|
||||
"test.cc",
|
||||
MemoryBuffer::getMemBuffer("int main() { float x; }").release());
|
||||
invocation->getFrontendOpts().Inputs.push_back(FrontendInputFile("test.cc",
|
||||
IK_CXX));
|
||||
invocation->getFrontendOpts().ProgramAction = frontend::ParseSyntaxOnly;
|
||||
@ -128,7 +130,8 @@ public:
|
||||
TEST(PreprocessorFrontendAction, EndSourceFile) {
|
||||
CompilerInvocation *Invocation = new CompilerInvocation;
|
||||
Invocation->getPreprocessorOpts().addRemappedFile(
|
||||
"test.cc", MemoryBuffer::getMemBuffer("int main() { float x; }"));
|
||||
"test.cc",
|
||||
MemoryBuffer::getMemBuffer("int main() { float x; }").release());
|
||||
Invocation->getFrontendOpts().Inputs.push_back(
|
||||
FrontendInputFile("test.cc", IK_CXX));
|
||||
Invocation->getFrontendOpts().ProgramAction = frontend::ParseSyntaxOnly;
|
||||
|
@ -62,8 +62,8 @@ protected:
|
||||
|
||||
std::vector<Token> CheckLex(StringRef Source,
|
||||
ArrayRef<tok::TokenKind> ExpectedTokens) {
|
||||
MemoryBuffer *buf = MemoryBuffer::getMemBuffer(Source);
|
||||
SourceMgr.setMainFileID(SourceMgr.createFileID(buf));
|
||||
std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(Source);
|
||||
SourceMgr.setMainFileID(SourceMgr.createFileID(Buf.release()));
|
||||
|
||||
VoidModuleLoader ModLoader;
|
||||
HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts,
|
||||
|
@ -160,8 +160,8 @@ protected:
|
||||
// the InclusionDirective callback.
|
||||
CharSourceRange InclusionDirectiveFilenameRange(const char* SourceText,
|
||||
const char* HeaderPath, bool SystemHeader) {
|
||||
MemoryBuffer *Buf = MemoryBuffer::getMemBuffer(SourceText);
|
||||
SourceMgr.setMainFileID(SourceMgr.createFileID(Buf));
|
||||
std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(SourceText);
|
||||
SourceMgr.setMainFileID(SourceMgr.createFileID(Buf.release()));
|
||||
|
||||
VoidModuleLoader ModLoader;
|
||||
|
||||
@ -197,8 +197,9 @@ protected:
|
||||
LangOptions OpenCLLangOpts;
|
||||
OpenCLLangOpts.OpenCL = 1;
|
||||
|
||||
MemoryBuffer* sourceBuf = MemoryBuffer::getMemBuffer(SourceText, "test.cl");
|
||||
SourceMgr.setMainFileID(SourceMgr.createFileID(sourceBuf));
|
||||
std::unique_ptr<MemoryBuffer> SourceBuf =
|
||||
MemoryBuffer::getMemBuffer(SourceText, "test.cl");
|
||||
SourceMgr.setMainFileID(SourceMgr.createFileID(SourceBuf.release()));
|
||||
|
||||
VoidModuleLoader ModLoader;
|
||||
HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags,
|
||||
|
@ -90,8 +90,8 @@ TEST_F(PPConditionalDirectiveRecordTest, PPRecAPI) {
|
||||
"#endif\n"
|
||||
"9\n";
|
||||
|
||||
MemoryBuffer *buf = MemoryBuffer::getMemBuffer(source);
|
||||
SourceMgr.setMainFileID(SourceMgr.createFileID(buf));
|
||||
std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(source);
|
||||
SourceMgr.setMainFileID(SourceMgr.createFileID(Buf.release()));
|
||||
|
||||
VoidModuleLoader ModLoader;
|
||||
HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts,
|
||||
|
@ -48,10 +48,11 @@ class RewriterTestContext {
|
||||
~RewriterTestContext() {}
|
||||
|
||||
FileID createInMemoryFile(StringRef Name, StringRef Content) {
|
||||
llvm::MemoryBuffer *Source = llvm::MemoryBuffer::getMemBuffer(Content);
|
||||
std::unique_ptr<llvm::MemoryBuffer> Source =
|
||||
llvm::MemoryBuffer::getMemBuffer(Content);
|
||||
const FileEntry *Entry =
|
||||
Files.getVirtualFile(Name, Source->getBufferSize(), 0);
|
||||
Sources.overrideFileContents(Entry, Source);
|
||||
Sources.overrideFileContents(Entry, Source.release());
|
||||
assert(Entry != nullptr);
|
||||
return Sources.createFileID(Entry, SourceLocation(), SrcMgr::C_User);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user