diff mbox series

[03/11] Implement STRIP_ANY_LOCATION_WRAPPER_SAFE

Message ID 1510973563-10046-4-git-send-email-dmalcolm@redhat.com
State New
Headers show
Series C++: locations for (almost) everything (PR 43486) | expand

Commit Message

David Malcolm Nov. 18, 2017, 2:52 a.m. UTC
We occasionally need to handle the NULL case when stripping trees,
so this patch introduces a variant of STRIP_ANY_LOCATION_WRAPPER to
do so.

gcc/ChangeLog:
	* tree.h (STRIP_ANY_LOCATION_WRAPPER_SAFE): New macro.
---
 gcc/tree.h | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/gcc/tree.h b/gcc/tree.h
index 9a0bd60..98acc8b 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -492,6 +492,14 @@  extern void omp_clause_range_check_failed (const_tree, const char *, int,
       (EXP) = TREE_OPERAND ((EXP), 0);	\
   } while (0)
 
+/* As STRIP_ANY_LOCATION_WRAPPER, but handle NULL_TREE.  */
+
+#define STRIP_ANY_LOCATION_WRAPPER_SAFE(EXP) \
+  do {					\
+    if ((EXP) && location_wrapper_p (EXP))	\
+      (EXP) = TREE_OPERAND ((EXP), 0);		\
+  } while (0)
+
 /* Nonzero if TYPE represents a vector type.  */
 
 #define VECTOR_TYPE_P(TYPE) (TREE_CODE (TYPE) == VECTOR_TYPE)