[clang] [Clang] Fix a variable shadowing in MapLattice (NFC) (PR #95697)

via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 16 03:13:17 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-analysis

Author: Shivam Gupta (xgupta)

<details>
<summary>Changes</summary>

Reported in https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment N10.

The PVS-Studio warning:
V570 The 'C' variable is assigned to itself. MapLattice.h:52

---
Full diff: https://github.com/llvm/llvm-project/pull/95697.diff


1 Files Affected:

- (modified) clang/include/clang/Analysis/FlowSensitive/MapLattice.h (+1-1) 


``````````diff
diff --git a/clang/include/clang/Analysis/FlowSensitive/MapLattice.h b/clang/include/clang/Analysis/FlowSensitive/MapLattice.h
index 16b0c978779a7..9d7afbe6ae7bf 100644
--- a/clang/include/clang/Analysis/FlowSensitive/MapLattice.h
+++ b/clang/include/clang/Analysis/FlowSensitive/MapLattice.h
@@ -49,7 +49,7 @@ template <typename Key, typename ElementLattice> class MapLattice {
 
   MapLattice() = default;
 
-  explicit MapLattice(Container C) { C = std::move(C); }
+  explicit MapLattice(Container C) : C { std::move(C) } {};
 
   // The `bottom` element is the empty map.
   static MapLattice bottom() { return MapLattice(); }

``````````

</details>


https://github.com/llvm/llvm-project/pull/95697


More information about the cfe-commits mailing list