github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code.
:warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp --
clang/lib/Interpreter/Value.cpp clang/unittests/Interpreter/InterpreterTest.cpp
--diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/unittests/Interpreter/InterpreterTest.cpp
b/clang/unittests/Interpreter/InterpreterTest.cpp
index ab2b58859..1db6282f2 100644
--- a/clang/unittests/Interpreter/InterpreterTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterTest.cpp
@@ -451,56 +451,56 @@ TEST_F(InterpreterTest, ValueSetRawBitsCopiesByteCount) {
V2.setRawBits(Buf);
EXPECT_EQ(V2.getLongLong(), Src);
-// Regression: Value's move ctor and move-assign must transfer ownership of
-// the manually-allocated storage without changing the storage refcount.
-// Earlier the move ctor called Release() on the just-moved-into storage,
-// double-releasing on the next read.
-TEST_F(InterpreterTest, ValueMoveSemantics) {
- std::vector<const char *> Args = {"-fno-sized-deallocation"};
- std::unique_ptr<Interpreter> Interp = createInterpreter(Args);
-
- llvm::cantFail(
- Interp->ParseAndExecute("struct MoveT { int v = 7; ~MoveT() {} };"));
-
- // Move-construct: source becomes empty, destination owns the storage.
- Value Src;
- llvm::cantFail(Interp->ParseAndExecute("MoveT{}", &Src));
- ASSERT_EQ(Src.getKind(), Value::K_PtrOrObj);
- ASSERT_TRUE(Src.isManuallyAlloc());
- void *Payload = Src.getPtr();
-
- Value Moved(std::move(Src));
- EXPECT_EQ(Moved.getKind(), Value::K_PtrOrObj);
- EXPECT_TRUE(Moved.isManuallyAlloc());
- EXPECT_EQ(Moved.getPtr(), Payload);
- EXPECT_EQ(Src.getKind(), Value::K_Unspecified);
- EXPECT_FALSE(Src.isManuallyAlloc());
-
- // Move-assign over a populated Value: previous storage released, new
- // storage adopted with refcount unchanged.
- Value Other;
- llvm::cantFail(Interp->ParseAndExecute("MoveT{}", &Other));
- Other = std::move(Moved);
- EXPECT_EQ(Other.getKind(), Value::K_PtrOrObj);
- EXPECT_EQ(Other.getPtr(), Payload);
- EXPECT_EQ(Moved.getKind(), Value::K_Unspecified);
-
- // Copy-construct still works (Retain bumps refcount; both share storage).
- Value Copy(Other);
- EXPECT_EQ(Copy.getKind(), Value::K_PtrOrObj);
- EXPECT_EQ(Copy.getPtr(), Payload);
- EXPECT_EQ(Other.getPtr(), Payload);
-
- // Force destruction order Copy -> Other -> Interp inside the test body so
- // any latent corruption from a buggy move surfaces here. Pre-fix the move
- // ctor leaves Other holding a dangling pointer; the subsequent Release in
- // ~Copy / ~Other reads or asserts on freed memory. Without explicit
- // teardown the abort happened during global cleanup, after gtest already
- // recorded the test as OK.
- Copy.clear();
- Other.clear();
- Interp.reset();
-}
+ // Regression: Value's move ctor and move-assign must transfer ownership of
+ // the manually-allocated storage without changing the storage refcount.
+ // Earlier the move ctor called Release() on the just-moved-into storage,
+ // double-releasing on the next read.
+ TEST_F(InterpreterTest, ValueMoveSemantics) {
+ std::vector<const char *> Args = {"-fno-sized-deallocation"};
+ std::unique_ptr<Interpreter> Interp = createInterpreter(Args);
+
+ llvm::cantFail(
+ Interp->ParseAndExecute("struct MoveT { int v = 7; ~MoveT() {} };"));
+
+ // Move-construct: source becomes empty, destination owns the storage.
+ Value Src;
+ llvm::cantFail(Interp->ParseAndExecute("MoveT{}", &Src));
+ ASSERT_EQ(Src.getKind(), Value::K_PtrOrObj);
+ ASSERT_TRUE(Src.isManuallyAlloc());
+ void *Payload = Src.getPtr();
+
+ Value Moved(std::move(Src));
+ EXPECT_EQ(Moved.getKind(), Value::K_PtrOrObj);
+ EXPECT_TRUE(Moved.isManuallyAlloc());
+ EXPECT_EQ(Moved.getPtr(), Payload);
+ EXPECT_EQ(Src.getKind(), Value::K_Unspecified);
+ EXPECT_FALSE(Src.isManuallyAlloc());
+
+ // Move-assign over a populated Value: previous storage released, new
+ // storage adopted with refcount unchanged.
+ Value Other;
+ llvm::cantFail(Interp->ParseAndExecute("MoveT{}", &Other));
+ Other = std::move(Moved);
+ EXPECT_EQ(Other.getKind(), Value::K_PtrOrObj);
+ EXPECT_EQ(Other.getPtr(), Payload);
+ EXPECT_EQ(Moved.getKind(), Value::K_Unspecified);
+
+ // Copy-construct still works (Retain bumps refcount; both share storage).
+ Value Copy(Other);
+ EXPECT_EQ(Copy.getKind(), Value::K_PtrOrObj);
+ EXPECT_EQ(Copy.getPtr(), Payload);
+ EXPECT_EQ(Other.getPtr(), Payload);
+
+ // Force destruction order Copy -> Other -> Interp inside the test body so
+ // any latent corruption from a buggy move surfaces here. Pre-fix the move
+ // ctor leaves Other holding a dangling pointer; the subsequent Release in
+ // ~Copy / ~Other reads or asserts on freed memory. Without explicit
+ // teardown the abort happened during global cleanup, after gtest already
+ // recorded the test as OK.
+ Copy.clear();
+ Other.clear();
+ Interp.reset();
+ }
TEST_F(InterpreterTest, TranslationUnit_CanonicalDecl) {
std::vector<const char *> Args;
``````````
</details>
https://github.com/llvm/llvm-project/pull/200888
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits