From c86b984ea8ecb3e944dc3de48539f4c1f65851ea Mon Sep 17 00:00:00 2001 From: dim Date: Sun, 18 Jan 2015 16:23:48 +0000 Subject: Vendor import of clang RELEASE_360/rc1 tag r226102 (effectively, 3.6.0 RC1): https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_360/rc1@226102 --- unittests/Tooling/RefactoringTest.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'unittests/Tooling/RefactoringTest.cpp') diff --git a/unittests/Tooling/RefactoringTest.cpp b/unittests/Tooling/RefactoringTest.cpp index ddb974a..a026a94 100644 --- a/unittests/Tooling/RefactoringTest.cpp +++ b/unittests/Tooling/RefactoringTest.cpp @@ -237,7 +237,8 @@ public: const FileEntry *File = Context.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 Context.Sources.createFileID(File, SourceLocation(), SrcMgr::C_User); @@ -251,9 +252,8 @@ public: // 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 FileBuffer( - Context.Files.getBufferForFile(Path, nullptr)); - return FileBuffer->getBuffer(); + auto FileBuffer = Context.Files.getBufferForFile(Path); + return (*FileBuffer)->getBuffer(); } llvm::StringMap TemporaryFiles; @@ -299,11 +299,12 @@ private: public: TestAction(TestVisitor *Visitor) : Visitor(Visitor) {} - virtual clang::ASTConsumer* CreateASTConsumer( - clang::CompilerInstance& compiler, llvm::StringRef dummy) { + virtual std::unique_ptr + CreateASTConsumer(clang::CompilerInstance &compiler, + llvm::StringRef dummy) { Visitor->SM = &compiler.getSourceManager(); /// TestConsumer will be deleted by the framework calling us. - return new FindConsumer(Visitor); + return llvm::make_unique(Visitor); } private: @@ -392,6 +393,8 @@ TEST(DeduplicateTest, removesDuplicates) { Input.push_back(Replacement("fileA", 50, 0, " foo ")); // Duplicate Input.push_back(Replacement("fileA", 51, 3, " bar ")); Input.push_back(Replacement("fileB", 51, 3, " bar ")); // Filename differs! + Input.push_back(Replacement("fileB", 60, 1, " bar ")); + Input.push_back(Replacement("fileA", 60, 2, " bar ")); Input.push_back(Replacement("fileA", 51, 3, " moo ")); // Replacement text // differs! @@ -402,12 +405,14 @@ TEST(DeduplicateTest, removesDuplicates) { Expected.push_back(Replacement("fileA", 50, 0, " foo ")); Expected.push_back(Replacement("fileA", 51, 3, " bar ")); Expected.push_back(Replacement("fileA", 51, 3, " moo ")); - Expected.push_back(Replacement("fileB", 51, 3, " bar ")); + Expected.push_back(Replacement("fileB", 60, 1, " bar ")); + Expected.push_back(Replacement("fileA", 60, 2, " bar ")); std::vector Conflicts; // Ignored for this test deduplicate(Input, Conflicts); - ASSERT_TRUE(Expected == Input); + EXPECT_EQ(3U, Conflicts.size()); + EXPECT_EQ(Expected, Input); } TEST(DeduplicateTest, detectsConflicts) { -- cgit v1.1