r217481 - Revert over-eager unique_ptr conversion.

Benjamin Kramer benny.kra at googlemail.com
Wed Sep 10 02:35:50 PDT 2014


Author: d0k
Date: Wed Sep 10 04:35:49 2014
New Revision: 217481

URL: http://llvm.org/viewvc/llvm-project?rev=217481&view=rev
Log:
Revert over-eager unique_ptr conversion.

This test wants to observe PPCallbacks after they have been moved into the
preprocessor. That doesn't work if the pointer has been moved away.

Modified:
    cfe/trunk/unittests/Frontend/FrontendActionTest.cpp

Modified: cfe/trunk/unittests/Frontend/FrontendActionTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Frontend/FrontendActionTest.cpp?rev=217481&r1=217480&r2=217481&view=diff
==============================================================================
--- cfe/trunk/unittests/Frontend/FrontendActionTest.cpp (original)
+++ cfe/trunk/unittests/Frontend/FrontendActionTest.cpp Wed Sep 10 04:35:49 2014
@@ -111,15 +111,15 @@ struct TestPPCallbacks : public PPCallba
 };
 
 class TestPPCallbacksFrontendAction : public PreprocessorFrontendAction {
-  std::unique_ptr<TestPPCallbacks> Callbacks;
+  TestPPCallbacks *Callbacks;
 
 public:
-  TestPPCallbacksFrontendAction(std::unique_ptr<TestPPCallbacks> C)
-      : Callbacks(std::move(C)), SeenEnd(false) {}
+  TestPPCallbacksFrontendAction(TestPPCallbacks *C)
+      : Callbacks(C), SeenEnd(false) {}
 
   void ExecuteAction() override {
     Preprocessor &PP = getCompilerInstance().getPreprocessor();
-    PP.addPPCallbacks(std::move(Callbacks));
+    PP.addPPCallbacks(std::unique_ptr<TestPPCallbacks>(Callbacks));
     PP.EnterMainSourceFile();
   }
   void EndSourceFileAction() override { SeenEnd = Callbacks->SeenEnd; }
@@ -140,8 +140,8 @@ TEST(PreprocessorFrontendAction, EndSour
   Compiler.setInvocation(Invocation);
   Compiler.createDiagnostics();
 
-  std::unique_ptr<TestPPCallbacks> Callbacks(new TestPPCallbacks);
-  TestPPCallbacksFrontendAction TestAction(std::move(Callbacks));
+  TestPPCallbacks *Callbacks = new TestPPCallbacks;
+  TestPPCallbacksFrontendAction TestAction(Callbacks);
   ASSERT_FALSE(Callbacks->SeenEnd);
   ASSERT_FALSE(TestAction.SeenEnd);
   ASSERT_TRUE(Compiler.ExecuteAction(TestAction));





More information about the cfe-commits mailing list