@@ -215,17 +215,18 @@ void AccessorBuilder::emitGetterDefinition() const {
215215 std::string fromLlvm;
216216
217217 if (!m_arg.type ->isVarArgList ()) {
218- fromLlvm = tgfmt (" getArgOperand($index)" , &m_fmt);
218+ fromLlvm = tgfmt (
219+ " getArgOperand(static_cast<uint32_t>(ArgumentIndex::$Name))" , &m_fmt);
219220 if (auto *attr = dyn_cast<Attr>(m_arg.type ))
220221 fromLlvm = tgfmt (attr->getFromLlvmValue (), &m_fmt, fromLlvm);
221222 else if (m_arg.type ->isTypeArg ())
222223 fromLlvm += " ->getType()" ;
223224 } else {
224225 fromLlvm = tgfmt (
225226 R"( ::llvm::make_range(
226- value_op_iterator(arg_begin() + $index ),
227+ value_op_iterator(arg_begin() + static_cast<uint32_t>(ArgumentIndex::$Name$0) ),
227228 value_op_iterator(arg_end())))" ,
228- &m_fmt);
229+ &m_fmt, " Start " );
229230 }
230231
231232 m_fmt.addSubst (" fromLlvm" , fromLlvm);
@@ -251,7 +252,7 @@ void AccessorBuilder::emitSetterDefinition() const {
251252 m_os << tgfmt (R"(
252253
253254 void $_op::set$Name($cppType $name) {
254- setArgOperand($index , $toLlvm);
255+ setArgOperand(static_cast<uint32_t>(ArgumentIndex::$Name) , $toLlvm);
255256 })" ,
256257 &m_fmt);
257258}
@@ -263,32 +264,27 @@ void AccessorBuilder::emitVarArgReplacementDefinition() const {
263264
264265 $_op *$_op::replace$Name(::llvm::ArrayRef<Value *> $name) {
265266 ::llvm::SmallVector<Value *> newArgs;
266- if ($index > 0)
267- newArgs.append(arg_begin(), arg_begin() + $index );
267+ if (static_cast<uint32_t>(ArgumentIndex::$Name$0) > 0)
268+ newArgs.append(arg_begin(), arg_begin() + static_cast<uint32_t>(ArgumentIndex::$Name$0) );
268269 newArgs.append($name.begin(), $name.end());
269270 $_op *newOp = ::llvm::cast<$_op>(::llvm::CallInst::Create(getCalledFunction(), newArgs, this->getName(), this->getIterator()));
270271 newOp->copyMetadata(*this);
271272 this->replaceAllUsesWith(newOp);
272273 this->eraseFromParent();
273274 return newOp;
274275 })" ,
275- &m_fmt);
276+ &m_fmt, " Start " );
276277}
277278
278279void OperationBase::emitArgumentAccessorDefinitions (llvm::raw_ostream &out,
279280 FmtContext &fmt) const {
280- unsigned numSuperclassArgs = 0 ;
281- if (m_superclass)
282- numSuperclassArgs = m_superclass->getNumFullArguments ();
283-
284281 for (const auto &indexedArg : llvm::enumerate (m_arguments)) {
285282 FmtContextScope scope (fmt);
286283
287284 const NamedValue &arg = indexedArg.value ();
288285 AccessorBuilder builder{fmt, out, arg, m_attrTypes[indexedArg.index ()]};
289286
290287 fmt.withContext (" getContext()" );
291- fmt.addSubst (" index" , Twine (numSuperclassArgs + indexedArg.index ()));
292288 fmt.addSubst (" cppType" , arg.type ->getGetterCppType ());
293289 fmt.addSubst (" name" , arg.name );
294290 fmt.addSubst (" Name" , convertToCamelFromSnakeCase (arg.name , true ));
@@ -342,7 +338,8 @@ static std::string evaluateAttrLlvmType(raw_ostream &errs, raw_ostream &out,
342338}
343339
344340// Implement constructor here, where BuilderMethod is fully defined.
345- Operation::Operation (GenDialectsContext &context) : m_system(context, m_scope) {}
341+ Operation::Operation (GenDialectsContext &context)
342+ : m_system(context, m_scope) {}
346343
347344// Default destructor instantiated explicitly to avoid having to add more
348345// includes in the header.
@@ -790,7 +787,8 @@ void BuilderMethod::emitDefinition(raw_ostream &out, FmtContext &fmt,
790787 )" ,
791788 &fmt);
792789 } else {
793- out << tgfmt (" return ::llvm::cast<$_op>($_builder.CreateCall($fn, std::nullopt, $_instname));\n " ,
790+ out << tgfmt (" return ::llvm::cast<$_op>($_builder.CreateCall($fn, "
791+ " std::nullopt, $_instname));\n " ,
794792 &fmt);
795793 }
796794
0 commit comments