[DeLICM] Refector out parseSetOrNull. NFC.
authorMichael Kruse <llvm@meinersbur.de>
Mon, 20 Mar 2017 15:37:32 +0000 (15:37 +0000)
committerMichael Kruse <llvm@meinersbur.de>
Mon, 20 Mar 2017 15:37:32 +0000 (15:37 +0000)
Note that the isl::union_set(isl_ctx,std::string) constructor will
auto-convert the char* to an std::string. Converting a nullptr to
std::string is undefined in C++11 (sect. 21.4.2.9).

llvm-svn: 298259

polly/unittests/DeLICM/DeLICMTest.cpp

index 2486ab6..f44e342 100644 (file)
@@ -51,32 +51,24 @@ typedef struct {
   const char *WrittenStr;
 } Knowledge;
 
+isl::union_set parseSetOrNull(isl_ctx *Ctx, const char *Str) {
+  if (!Str)
+    return nullptr;
+  return isl::union_set(Ctx, Str);
+}
+
 bool checkIsConflictingNonsymmetric(Knowledge Existing, Knowledge Proposed) {
   std::unique_ptr<isl_ctx, decltype(&isl_ctx_free)> Ctx(isl_ctx_alloc(),
                                                         &isl_ctx_free);
 
   // Parse knowledge.
-  auto ExistingOccupied =
-      Existing.OccupiedStr
-          ? give(isl_union_set_read_from_str(Ctx.get(), Existing.OccupiedStr))
-          : nullptr;
-  auto ExistingUnused =
-      Existing.UndefStr
-          ? give(isl_union_set_read_from_str(Ctx.get(), Existing.UndefStr))
-          : nullptr;
-  auto ExistingWritten =
-      give(isl_union_set_read_from_str(Ctx.get(), Existing.WrittenStr));
-
-  auto ProposedOccupied =
-      Proposed.OccupiedStr
-          ? give(isl_union_set_read_from_str(Ctx.get(), Proposed.OccupiedStr))
-          : nullptr;
-  auto ProposedUnused =
-      Proposed.UndefStr
-          ? give(isl_union_set_read_from_str(Ctx.get(), Proposed.UndefStr))
-          : nullptr;
-  auto ProposedWritten =
-      give(isl_union_set_read_from_str(Ctx.get(), Proposed.WrittenStr));
+  auto ExistingOccupied = parseSetOrNull(Ctx.get(), Existing.OccupiedStr);
+  auto ExistingUnused = parseSetOrNull(Ctx.get(), Existing.UndefStr);
+  auto ExistingWritten = parseSetOrNull(Ctx.get(), Existing.WrittenStr);
+
+  auto ProposedOccupied = parseSetOrNull(Ctx.get(), Proposed.OccupiedStr);
+  auto ProposedUnused = parseSetOrNull(Ctx.get(), Proposed.UndefStr);
+  auto ProposedWritten = parseSetOrNull(Ctx.get(), Proposed.WrittenStr);
 
   // Determine universe (set of all possible domains).
   auto Universe =