Skip to content

Commit 868a05d

Browse files
Tim Renouftrenouf
Tim Renouf
authored andcommitted
Handle op with no args
Dunno if it's just my compiler (clang 13), but it refused to implicitly construct ArrayRef<Value*> out of an empty array of args.
1 parent abced2a commit 868a05d

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

lib/TableGen/GenDialect.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,19 +1381,22 @@ void llvm_dialects::genDialectDefs(raw_ostream& out, RecordKeeper& records) {
13811381
}
13821382
}
13831383

1384-
out << tgfmt("::llvm::Value* const $0[] = {\n", &fmt, args);
1385-
for (const auto& [name, type, arg]
1386-
: llvm::zip_first(argNames, argTypes, fullArguments)) {
1387-
if (auto* attr = dyn_cast<Attr>(arg.type)) {
1388-
out << tgfmt(attr->getToLlvmValue(), &fmt, name, type);
1389-
} else {
1390-
out << name;
1384+
if (!argNames.empty()) {
1385+
out << tgfmt("::llvm::Value* const $0[] = {\n", &fmt, args);
1386+
for (const auto& [name, type, arg]
1387+
: llvm::zip_first(argNames, argTypes, fullArguments)) {
1388+
if (auto* attr = dyn_cast<Attr>(arg.type)) {
1389+
out << tgfmt(attr->getToLlvmValue(), &fmt, name, type);
1390+
} else {
1391+
out << name;
1392+
}
1393+
out << ",\n";
13911394
}
1392-
out << ",\n";
1393-
}
1394-
out << "};\n\n";
1395+
out << "};\n\n";
13951396

1396-
out << tgfmt("return $_builder.CreateCall($0, $1);\n", &fmt, fn, args);
1397+
out << tgfmt("return $_builder.CreateCall($0, $1);\n", &fmt, fn, args);
1398+
} else
1399+
out << tgfmt("return $_builder.CreateCall($0);\n", &fmt, fn);
13971400
out << "}\n\n";
13981401

13991402
// Emit argument getters.

0 commit comments

Comments
 (0)