[DeLICM] Refector out parseSetOrNull. NFC.

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
This commit is contained in:
Michael Kruse 2017-03-20 15:37:32 +00:00
parent d75d56e9bf
commit 0d10696693
1 changed files with 12 additions and 20 deletions

View File

@ -51,32 +51,24 @@ typedef struct {
const char *WrittenStr; const char *WrittenStr;
} Knowledge; } 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) { bool checkIsConflictingNonsymmetric(Knowledge Existing, Knowledge Proposed) {
std::unique_ptr<isl_ctx, decltype(&isl_ctx_free)> Ctx(isl_ctx_alloc(), std::unique_ptr<isl_ctx, decltype(&isl_ctx_free)> Ctx(isl_ctx_alloc(),
&isl_ctx_free); &isl_ctx_free);
// Parse knowledge. // Parse knowledge.
auto ExistingOccupied = auto ExistingOccupied = parseSetOrNull(Ctx.get(), Existing.OccupiedStr);
Existing.OccupiedStr auto ExistingUnused = parseSetOrNull(Ctx.get(), Existing.UndefStr);
? give(isl_union_set_read_from_str(Ctx.get(), Existing.OccupiedStr)) auto ExistingWritten = parseSetOrNull(Ctx.get(), Existing.WrittenStr);
: 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 = auto ProposedOccupied = parseSetOrNull(Ctx.get(), Proposed.OccupiedStr);
Proposed.OccupiedStr auto ProposedUnused = parseSetOrNull(Ctx.get(), Proposed.UndefStr);
? give(isl_union_set_read_from_str(Ctx.get(), Proposed.OccupiedStr)) auto ProposedWritten = parseSetOrNull(Ctx.get(), Proposed.WrittenStr);
: 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));
// Determine universe (set of all possible domains). // Determine universe (set of all possible domains).
auto Universe = auto Universe =