diff options
Diffstat (limited to 'unittests/Tooling/RewriterTestContext.h')
-rw-r--r-- | unittests/Tooling/RewriterTestContext.h | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/unittests/Tooling/RewriterTestContext.h b/unittests/Tooling/RewriterTestContext.h index fe108ad308e5..112efac52ebc 100644 --- a/unittests/Tooling/RewriterTestContext.h +++ b/unittests/Tooling/RewriterTestContext.h @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_REWRITER_TEST_CONTEXT_H -#define LLVM_CLANG_REWRITER_TEST_CONTEXT_H +#ifndef LLVM_CLANG_UNITTESTS_TOOLING_REWRITERTESTCONTEXT_H +#define LLVM_CLANG_UNITTESTS_TOOLING_REWRITERTESTCONTEXT_H #include "clang/Basic/Diagnostic.h" #include "clang/Basic/DiagnosticOptions.h" @@ -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, std::move(Source)); assert(Entry != nullptr); return Sources.createFileID(Entry, SourceLocation(), SrcMgr::C_User); } @@ -71,7 +72,8 @@ class RewriterTestContext { const FileEntry *File = Files.getFile(Path); assert(File != nullptr); - StringRef Found = TemporaryFiles.GetOrCreateValue(Name, Path.str()).second; + StringRef Found = + TemporaryFiles.insert(std::make_pair(Name, Path.str())).first->second; assert(Found == Path); (void)Found; return Sources.createFileID(File, SourceLocation(), SrcMgr::C_User); @@ -100,9 +102,8 @@ class RewriterTestContext { // descriptor, which might not see the changes made. // FIXME: Figure out whether there is a way to get the SourceManger to // reopen the file. - std::unique_ptr<const llvm::MemoryBuffer> FileBuffer( - Files.getBufferForFile(Path, nullptr)); - return FileBuffer->getBuffer(); + auto FileBuffer = Files.getBufferForFile(Path); + return (*FileBuffer)->getBuffer(); } IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts; |