[llvm] Suppress GCC dangling-pointer false positive for RAII listener pattern (PR #180875)
Eric Christopher via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 14 11:11:10 PST 2026
https://github.com/echristo updated https://github.com/llvm/llvm-project/pull/180875
>From c4c41394ae7fbb967b6fccebc8b86940822c2c43 Mon Sep 17 00:00:00 2001
From: Eric Christopher <echristo at gmail.com>
Date: Fri, 6 Feb 2026 01:17:46 -0800
Subject: [PATCH] Suppress GCC -Wdangling-pointer false positive in
DAGUpdateListener
GCC warns about storing 'this' here but the destructor cleans it up,
so it's a false positive. Suppress with a pragma.
---
llvm/include/llvm/CodeGen/SelectionDAG.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/llvm/include/llvm/CodeGen/SelectionDAG.h b/llvm/include/llvm/CodeGen/SelectionDAG.h
index b5458bf7180ca..f068db9239b02 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() {
More information about the llvm-commits
mailing list