Added capture function for assignment left-hand side.
authorJustin Seyster <jseyster@cs.sunysb.edu>
Thu, 11 Feb 2010 21:18:12 +0000 (16:18 -0500)
committerJustin Seyster <jseyster@cs.sunysb.edu>
Thu, 11 Feb 2010 21:18:12 +0000 (16:18 -0500)
src/aop-pc-assign.c
src/aop.h

index 79127326488f12e1291259ea4b3c5996efe78b1c..6e9a25beb3e5bff7a85e9551b2df13cbcd71fa18 100644 (file)
 #include "aop-pointcut.h"
 #include "aop-type.h"
 
+const char *
+aop_capture_lhs_name (struct aop_joinpoint *jp)
+{
+  gimple stmt;
+  tree lhs;
+
+  aop_assert (jp->pc->kind == ATP_ASSIGN);
+
+  stmt = gsi_stmt (*jp->gsi);
+  aop_assert (gimple_has_lhs (stmt));
+  lhs = gimple_get_lhs (stmt);
+
+  if (TREE_CODE (lhs) == SSA_NAME)
+    lhs = SSA_NAME_VAR (lhs);
+
+  if (lhs != NULL && DECL_P (lhs))
+    {
+      tree name = DECL_NAME (lhs);
+      if (name != NULL)
+       return IDENTIFIER_POINTER (name);
+      else
+       return NULL;
+    }
+  else
+    {
+      return NULL;
+    }
+}
+
 static bool
 stmt_matches_pointcut (struct aop_pointcut *pc, gimple stmt)
 {
index ccd67bfc7229c52d314248af667af64f51c9c771..b46ffdd7962a2322d44b240102eae1953d209e95 100644 (file)
--- a/src/aop.h
+++ b/src/aop.h
@@ -56,6 +56,8 @@ typedef void (*join_callback) (struct aop_joinpoint *);
 
 extern struct aop_pointcut *aop_match_assignment_by_type (struct aop_type *type);
 
+extern const char *aop_capture_lhs_name (struct aop_joinpoint *jp);
+
 extern void aop_register_pass (const char *pass_name, pass_callback callback);
 extern void aop_join_on (struct aop_pointcut *pc, join_callback callback);
 extern void aop_main ();