[llvm] Suppress GCC dangling-pointer false positive for RAII listener pattern (PR #180875)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 14 11:31:02 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-selectiondag
Author: Eric Christopher (echristo)
<details>
<summary>Changes</summary>
GCC warns about storing `this` here but the destructor cleans it up, so it's a false positive. Suppress with a pragma.
Built with ToT clang and GCC 13.3.0 on Linux x86_64. All existing tests pass.
---
Full diff: https://github.com/llvm/llvm-project/pull/180875.diff
1 Files Affected:
- (modified) llvm/include/llvm/CodeGen/SelectionDAG.h (+8)
``````````diff
diff --git a/llvm/include/llvm/CodeGen/SelectionDAG.h b/llvm/include/llvm/CodeGen/SelectionDAG.h
index 9b4b57099889a..7e24046a76c6f 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAG.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAG.h
@@ -324,7 +324,15 @@ class SelectionDAG {
explicit DAGUpdateListener(SelectionDAG &D)
: Next(D.UpdateListeners), DAG(D) {
+ // False positive - RAII pattern, destructor cleans up.
+#if defined(__GNUC__) && !defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdangling-pointer"
+#endif
DAG.UpdateListeners = this;
+#if defined(__GNUC__) && !defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
}
virtual ~DAGUpdateListener() {
``````````
</details>
https://github.com/llvm/llvm-project/pull/180875
More information about the llvm-commits
mailing list