[PATCH] D111769: [Polly] Switch checkIslAstExprInt to use RAII instead of manually freeing Expr
Max Fan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 13 17:18:39 PDT 2021
InnovativeInventor created this revision.
InnovativeInventor added a reviewer: Meinersbur.
InnovativeInventor added a project: Polly.
Herald added a reviewer: bollu.
InnovativeInventor requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
If I'm understanding `isl-noexceptions.h` properly, the destructors for `Init` and `Inc` should be called once they fall out of scope, which should call `isl_ast_expr_free` and free `Expr`.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D111769
Files:
polly/lib/CodeGen/IslNodeBuilder.cpp
Index: polly/lib/CodeGen/IslNodeBuilder.cpp
===================================================================
--- polly/lib/CodeGen/IslNodeBuilder.cpp
+++ polly/lib/CodeGen/IslNodeBuilder.cpp
@@ -64,6 +64,7 @@
#include <cassert>
#include <cstdint>
#include <cstring>
+#include <memory>
#include <string>
#include <utility>
#include <vector>
@@ -148,14 +149,12 @@
/// Return true if a return value of Predicate is true for the value represented
/// by passed isl_ast_expr_int.
-static bool checkIslAstExprInt(__isl_take isl_ast_expr *Expr,
+static bool checkIslAstExprInt(isl::ast_expr Expr,
isl_bool (*Predicate)(__isl_keep isl_val *)) {
- if (isl_ast_expr_get_type(Expr) != isl_ast_expr_int) {
- isl_ast_expr_free(Expr);
+ if (isl_ast_expr_get_type(Expr.get()) != isl_ast_expr_int) {
return false;
}
- auto ExprVal = isl_ast_expr_get_val(Expr);
- isl_ast_expr_free(Expr);
+ auto ExprVal = isl_ast_expr_get_val(Expr.get());
if (Predicate(ExprVal) != isl_bool_true) {
isl_val_free(ExprVal);
return false;
@@ -187,10 +186,10 @@
}
isl::ast_expr Init = For.init();
- if (!checkIslAstExprInt(Init.release(), isl_val_is_zero))
+ if (!checkIslAstExprInt(Init, isl_val_is_zero))
return -1;
isl::ast_expr Inc = For.inc();
- if (!checkIslAstExprInt(Inc.release(), isl_val_is_one))
+ if (!checkIslAstExprInt(Inc, isl_val_is_one))
return -1;
CmpInst::Predicate Predicate;
isl::ast_expr UB = getUpperBound(For, Predicate);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111769.379558.patch
Type: text/x-patch
Size: 1514 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211014/0e8de0cb/attachment.bin>
More information about the llvm-commits
mailing list