From b6a4ecc40502c3f297fd18790829ec52185f8e24 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 5 Aug 2023 15:18:12 +0200 Subject: [PATCH] PetScan::get_summary: extract out PetScan::cache_summary This will be reused in an upcoming commit. Signed-off-by: Sven Verdoolaege --- scan.cc | 15 ++++++++++++--- scan.h | 2 ++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/scan.cc b/scan.cc index d936683..290053d 100644 --- a/scan.cc +++ b/scan.cc @@ -2323,6 +2323,17 @@ static struct pet_array *extract_array(__isl_keep pet_expr *access, return array; } +/* Store (a copy of) "summary" in the cache of function summaries + * for function declaration "fd" and then give it back to the caller. + */ +__isl_give pet_function_summary *PetScan::cache_summary(clang::FunctionDecl *fd, + __isl_take pet_function_summary *summary) +{ + summary_cache[fd] = pet_function_summary_copy(summary); + + return summary; +} + /* Extract a function summary from the body of "fd", * with pet_tree representation "tree", extracted using "body_scan". * @@ -2453,9 +2464,7 @@ __isl_give pet_function_summary *PetScan::get_summary(FunctionDecl *fd) summary = get_summary_from_tree(tree, fd, body_scan); - summary_cache[fd] = pet_function_summary_copy(summary); - - return summary; + return cache_summary(fd, summary); } /* If "fd" has a function body, then extract a function summary from diff --git a/scan.h b/scan.h index b829686..8ace13a 100644 --- a/scan.h +++ b/scan.h @@ -266,6 +266,8 @@ private: clang::FunctionDecl *fd); __isl_give pet_expr *extract_assume(clang::Expr *expr); + __isl_give pet_function_summary *cache_summary(clang::FunctionDecl *fd, + __isl_take pet_function_summary *summary); __isl_give pet_function_summary *get_summary_from_tree( __isl_take pet_tree *tree, clang::FunctionDecl *fd, PetScan &body_scan); -- 2.11.4.GIT