@@ -105,11 +105,11 @@ const IR::Node *ExpressionConverter::postorder(IR::Primitive *primitive) {
105105 }
106106
107107 const IR::Expression *method =
108- new IR::Member (structure->paramReference (structure->parserPacketIn ),
108+ new IR::Member (primitive-> srcInfo , structure->paramReference (structure->parserPacketIn ),
109109 P4::P4CoreLibrary::instance ().packetIn .lookahead .Id ());
110110 auto typeargs = new IR::Vector<IR::Type>();
111111 typeargs->push_back (IR::Type_Bits::get (aval + bval));
112- auto lookahead = new IR::MethodCallExpression (method, typeargs);
112+ auto lookahead = new IR::MethodCallExpression (primitive-> srcInfo , method, typeargs);
113113 auto result = new IR::Slice (primitive->srcInfo , lookahead, bval - 1 , 0 );
114114 result->type = IR::Type_Bits::get (bval);
115115 return result;
@@ -123,7 +123,7 @@ const IR::Node *ExpressionConverter::postorder(IR::Primitive *primitive) {
123123 } else {
124124 auto func = new IR::PathExpression (IR::ID (primitive->srcInfo , primitive->name ));
125125 auto args = new IR::Vector<IR::Argument>;
126- for (auto *op : primitive->operands ) args->push_back (new IR::Argument (op));
126+ for (auto *op : primitive->operands ) args->push_back (new IR::Argument (op-> srcInfo , op ));
127127 auto result = new IR::MethodCallExpression (primitive->srcInfo , func, args);
128128 return result;
129129 }
@@ -158,7 +158,7 @@ const IR::Node *ExpressionConverter::postorder(IR::ConcreteHeaderRef *nhr) {
158158 if (nhr->type ->is <IR::Type_Header>()) {
159159 auto type = nhr->type ->to <IR::Type_Header>();
160160 if (structure->parameterTypes .count (type->name )) {
161- auto path = new IR::Path (nhr->ref ->name );
161+ auto path = new IR::Path (nhr->srcInfo , nhr-> ref ->name );
162162 auto result = new IR::PathExpression (nhr->srcInfo , nhr->type , path);
163163 result->type = nhr->type ;
164164 return result;
@@ -171,7 +171,7 @@ const IR::Node *ExpressionConverter::postorder(IR::ConcreteHeaderRef *nhr) {
171171 } else if (nhr->type ->is <IR::Type_Struct>()) {
172172 auto type = nhr->type ->to <IR::Type_Struct>();
173173 if (structure->parameterTypes .count (type->name )) {
174- auto path = new IR::Path (nhr->ref ->name );
174+ auto path = new IR::Path (nhr->srcInfo , nhr-> ref ->name );
175175 auto result = new IR::PathExpression (nhr->srcInfo , nhr->type , path);
176176 return result;
177177 } else if (structure->metadataTypes .count (type->name )) {
@@ -288,7 +288,7 @@ ExpressionConverter::funcType ExpressionConverter::get(cstring type) {
288288const IR::Node *StatementConverter::preorder (IR::Apply *apply) {
289289 auto table = structure->tables .get (apply->name );
290290 auto newname = structure->tables .get (table);
291- auto tbl = new IR::PathExpression (newname);
291+ auto tbl = new IR::PathExpression (apply-> srcInfo , new IR::Path (apply-> srcInfo , newname) );
292292 auto method = new IR::Member (apply->srcInfo , tbl, IR::ID (IR::IApply::applyMethodName));
293293 auto call = new IR::MethodCallExpression (apply->srcInfo , method);
294294 if (apply->actions .size () == 0 ) {
@@ -319,9 +319,9 @@ const IR::Node *StatementConverter::preorder(IR::Apply *apply) {
319319
320320 if (!otherLabels) {
321321 StatementConverter conv (structure, renameMap);
322- auto hitcase = hit ? conv.convert (hit) : new IR::EmptyStatement ();
322+ auto hitcase = hit ? conv.convert (hit) : new IR::EmptyStatement (apply-> srcInfo );
323323 auto misscase = miss ? conv.convert (miss) : nullptr ;
324- auto check = new IR::Member (call, IR::Type_Table::hit);
324+ auto check = new IR::Member (apply-> srcInfo , call, IR::Type_Table::hit);
325325 auto ifstat = new IR::IfStatement (apply->srcInfo , check, hitcase, misscase);
326326 prune ();
327327 return ifstat;
@@ -340,7 +340,7 @@ const IR::Node *StatementConverter::preorder(IR::Apply *apply) {
340340 }
341341 const IR::Expression *destination;
342342 if (a.first == " default" ) {
343- destination = new IR::DefaultExpression ();
343+ destination = new IR::DefaultExpression (a. second -> srcInfo );
344344 } else {
345345 cstring act_name = a.first ;
346346 auto path = apply->position .get <IR::Path>(act_name);
@@ -353,7 +353,7 @@ const IR::Node *StatementConverter::preorder(IR::Apply *apply) {
353353 auto swcase = new IR::SwitchCase (a.second ->srcInfo , destination, stat);
354354 cases.insert (insert_at, swcase);
355355 }
356- auto check = new IR::Member (call, IR::Type_Table::action_run);
356+ auto check = new IR::Member (apply-> srcInfo , call, IR::Type_Table::action_run);
357357 auto sw = new IR::SwitchStatement (apply->srcInfo , check, std::move (cases));
358358 prune ();
359359 return sw;
@@ -365,8 +365,8 @@ const IR::Node *StatementConverter::preorder(IR::Primitive *primitive) {
365365 auto control = structure->controls .get (primitive->name );
366366 if (control != nullptr ) {
367367 auto instanceName = ::P4::get (renameMap, control->name );
368- auto ctrl = new IR::PathExpression (IR::ID (instanceName));
369- auto method = new IR::Member (ctrl, IR::ID (IR::IApply::applyMethodName));
368+ auto ctrl = new IR::PathExpression (IR::ID (primitive-> srcInfo , instanceName));
369+ auto method = new IR::Member (primitive-> srcInfo , ctrl, IR::ID (IR::IApply::applyMethodName));
370370 auto args = structure->createApplyArguments (control->name );
371371 auto call = new IR::MethodCallExpression (primitive->srcInfo , method, args);
372372 auto stat = new IR::MethodCallStatement (primitive->srcInfo , call);
@@ -383,7 +383,7 @@ const IR::Node *StatementConverter::preorder(IR::If *cond) {
383383 BUG_CHECK (pred != nullptr , " Expected to get an expression when converting %1%" , cond->pred );
384384 const IR::Statement *t, *f;
385385 if (cond->ifTrue == nullptr )
386- t = new IR::EmptyStatement ();
386+ t = new IR::EmptyStatement (cond-> srcInfo );
387387 else
388388 t = conv.convert (cond->ifTrue );
389389
@@ -467,16 +467,17 @@ const IR::StructField *TypeConverter::postorder(IR::StructField *field) {
467467 ValidateLenExpr vle (type, field);
468468 vle.setCalledBy (this );
469469 lenexpr->apply (vle);
470- auto scale = new IR::Mul (lenexpr->srcInfo , lenexpr, new IR::Constant (8 ));
471- auto fieldlen =
472- new IR::Sub (scale->srcInfo , scale, new IR::Constant (type->width_bits ()));
473- field->addAnnotation (
474- new IR::Annotation (IR::Annotation::lengthAnnotation, {fieldlen}));
470+ auto scale =
471+ new IR::Mul (lenexpr->srcInfo , lenexpr, new IR::Constant (lenexpr->srcInfo , 8 ));
472+ auto fieldlen = new IR::Sub (scale->srcInfo , scale,
473+ new IR::Constant (scale->srcInfo , type->width_bits ()));
474+ field->addAnnotation (new IR::Annotation (
475+ field->srcInfo , IR::Annotation::lengthAnnotation, {fieldlen}));
475476 }
476477 }
477478 }
478479 if (auto vec = structure->listIndexes (type->name .name , field->name .name ))
479- field->addAnnotation (new IR::Annotation (" field_list" _cs, *vec));
480+ field->addAnnotation (new IR::Annotation (field-> srcInfo , " field_list" _cs, *vec));
480481 return field;
481482}
482483
@@ -504,14 +505,16 @@ class FixupExtern : public Modifier {
504505 void postorder (IR::Type_Extern *type) override {
505506 if (extname != type->name ) {
506507 type->addAnnotationIfNew (IR::Annotation::nameAnnotation,
507- new IR::StringLiteral (type->name .name ), false );
508+ new IR::StringLiteral (type->srcInfo , type-> name .name ), false );
508509 type->name = extname;
509510 }
510511 // FIXME -- should create ctors based on attributes? For now just create a
511512 // FIXME -- 0-arg one if needed
512513 if (!type->lookupMethod (type->name , new IR::Vector<IR::Argument>())) {
513514 type->methods .push_back (new IR::Method (
514- type->name , new IR::Type_Method (new IR::ParameterList (), type->getName ())));
515+ type->srcInfo , type->name ,
516+ new IR::Type_Method (type->srcInfo , new IR::ParameterList (type->srcInfo ),
517+ type->getName ())));
515518 }
516519 }
517520 void postorder (IR::Method *meth) override {
@@ -526,7 +529,7 @@ class FixupExtern : public Modifier {
526529 bool preorder (IR::Parameter *param) override {
527530 BUG_CHECK (typeParams, " recursion failure" );
528531 if (param->type ->is <IR::Type_FieldListCalculation>()) {
529- auto n = new IR::Type_Var (structure->makeUniqueName (" FL" _cs));
532+ auto n = new IR::Type_Var (param-> srcInfo , structure->makeUniqueName (" FL" _cs));
530533 param->type = n;
531534 typeParams->push_back (n);
532535 }
@@ -561,19 +564,23 @@ const IR::Declaration_Instance *ExternConverter::convertExternInstance(
561564 warning (ErrorType::WARN_UNSUPPORTED, " %s: P4_14 extern not fully supported" , ext);
562565 if (structure->extern_remap .count (et)) et = structure->extern_remap .at (et);
563566 rv->name = name;
564- rv->type = new IR::Type_Name (new IR::Path (structure->extern_types .get (et)));
567+ rv->type = new IR::Type_Name (ext->srcInfo ,
568+ new IR::Path (ext->srcInfo , structure->extern_types .get (et)));
565569 return rv->apply (TypeConverter (structure))->to <IR::Declaration_Instance>();
566570}
567571
568572const IR::Statement *ExternConverter::convertExternCall (ProgramStructure *structure,
569573 const IR::Declaration_Instance *ext,
570574 const IR::Primitive *prim) {
571575 ExpressionConverter conv (structure);
572- auto extref = new IR::PathExpression (structure->externs .get (ext));
576+ auto extref = new IR::PathExpression (prim->srcInfo ,
577+ new IR::Path (prim->srcInfo , structure->externs .get (ext)));
573578 auto method = new IR::Member (prim->srcInfo , extref, prim->name );
574579 auto args = new IR::Vector<IR::Argument>();
575- for (unsigned i = 1 ; i < prim->operands .size (); ++i)
576- args->push_back (new IR::Argument (conv.convert (prim->operands .at (i))));
580+ for (unsigned i = 1 ; i < prim->operands .size (); ++i) {
581+ auto converted = conv.convert (prim->operands .at (i));
582+ args->push_back (new IR::Argument (converted->srcInfo , converted));
583+ }
577584 auto mc = new IR::MethodCallExpression (prim->srcInfo , method, args);
578585 return new IR::MethodCallStatement (prim->srcInfo , mc);
579586}
0 commit comments