]> granicus.if.org Git - clang/commitdiff
Fix use-after-move in ClangBasicTests
authorHarlan Haskins <harlan@harlanhaskins.com>
Thu, 1 Aug 2019 21:50:16 +0000 (21:50 +0000)
committerHarlan Haskins <harlan@harlanhaskins.com>
Thu, 1 Aug 2019 21:50:16 +0000 (21:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@367620 91177308-0d34-0410-b5e6-96231b3b80d8

unittests/Basic/FileManagerTest.cpp

index cff12c53eace8106bd13b57d1d899436ef0a0467..77e13057a1d7209e5dfc0710b20b667f17010fbc 100644 (file)
@@ -212,6 +212,7 @@ TEST_F(FileManagerTest, getFileReturnsErrorForNonexistentFile) {
   auto statCache = llvm::make_unique<FakeStatCache>();
   statCache->InjectDirectory(".", 41);
   statCache->InjectFile("foo.cpp", 42);
+  statCache->InjectDirectory("MyDirectory", 49);
   manager.setStatCache(std::move(statCache));
 
   // Create a virtual bar.cpp file.
@@ -221,7 +222,6 @@ TEST_F(FileManagerTest, getFileReturnsErrorForNonexistentFile) {
   ASSERT_FALSE(file);
   ASSERT_EQ(file.getError(), std::errc::no_such_file_or_directory);
 
-  statCache->InjectDirectory("MyDirectory", 49);
   auto readingDirAsFile = manager.getFile("MyDirectory");
   ASSERT_FALSE(readingDirAsFile);
   ASSERT_EQ(readingDirAsFile.getError(), std::errc::is_a_directory);