@@ -154,10 +154,9 @@ bool MCAssembler::evaluateFixup(const MCFragment *DF, const MCFixup &Fixup,
154
154
// On error claim to have completely evaluated the fixup, to prevent any
155
155
// further processing from being done.
156
156
const MCExpr *Expr = Fixup.getValue ();
157
- MCContext &Ctx = getContext ();
158
157
Value = 0 ;
159
158
if (!Expr->evaluateAsRelocatable (Target, this )) {
160
- Ctx. reportError (Fixup.getLoc (), " expected relocatable expression" );
159
+ reportError (Fixup.getLoc (), " expected relocatable expression" );
161
160
return true ;
162
161
}
163
162
@@ -218,13 +217,12 @@ uint64_t MCAssembler::computeFragmentSize(const MCFragment &F) const {
218
217
auto &FF = cast<MCFillFragment>(F);
219
218
int64_t NumValues = 0 ;
220
219
if (!FF.getNumValues ().evaluateKnownAbsolute (NumValues, *this )) {
221
- getContext ().reportError (FF.getLoc (),
222
- " expected assembly-time absolute expression" );
220
+ reportError (FF.getLoc (), " expected assembly-time absolute expression" );
223
221
return 0 ;
224
222
}
225
223
int64_t Size = NumValues * FF.getValueSize ();
226
224
if (Size < 0 ) {
227
- getContext (). reportError (FF.getLoc (), " invalid number of bytes" );
225
+ reportError (FF.getLoc (), " invalid number of bytes" );
228
226
return 0 ;
229
227
}
230
228
return Size;
@@ -268,26 +266,25 @@ uint64_t MCAssembler::computeFragmentSize(const MCFragment &F) const {
268
266
const MCOrgFragment &OF = cast<MCOrgFragment>(F);
269
267
MCValue Value;
270
268
if (!OF.getOffset ().evaluateAsValue (Value, *this )) {
271
- getContext ().reportError (OF.getLoc (),
272
- " expected assembly-time absolute expression" );
273
- return 0 ;
269
+ reportError (OF.getLoc (), " expected assembly-time absolute expression" );
270
+ return 0 ;
274
271
}
275
272
276
273
uint64_t FragmentOffset = getFragmentOffset (OF);
277
274
int64_t TargetLocation = Value.getConstant ();
278
275
if (const auto *SA = Value.getAddSym ()) {
279
276
uint64_t Val;
280
277
if (!getSymbolOffset (*SA, Val)) {
281
- getContext (). reportError (OF.getLoc (), " expected absolute expression" );
278
+ reportError (OF.getLoc (), " expected absolute expression" );
282
279
return 0 ;
283
280
}
284
281
TargetLocation += Val;
285
282
}
286
283
int64_t Size = TargetLocation - FragmentOffset;
287
284
if (Size < 0 || Size >= 0x40000000 ) {
288
- getContext (). reportError (
289
- OF. getLoc (), " invalid .org offset '" + Twine (TargetLocation ) +
290
- " ' (at offset ' " + Twine (FragmentOffset) + " ')" );
285
+ reportError (OF. getLoc (), " invalid .org offset ' " + Twine (TargetLocation) +
286
+ " ' (at offset '" + Twine (FragmentOffset ) +
287
+ " ')" );
291
288
return 0 ;
292
289
}
293
290
return Size;
@@ -481,17 +478,15 @@ const MCSymbol *MCAssembler::getBaseSymbol(const MCSymbol &Symbol) const {
481
478
const MCExpr *Expr = Symbol.getVariableValue ();
482
479
MCValue Value;
483
480
if (!Expr->evaluateAsValue (Value, *this )) {
484
- getContext ().reportError (Expr->getLoc (),
485
- " expression could not be evaluated" );
481
+ reportError (Expr->getLoc (), " expression could not be evaluated" );
486
482
return nullptr ;
487
483
}
488
484
489
485
const MCSymbol *SymB = Value.getSubSym ();
490
486
if (SymB) {
491
- getContext ().reportError (
492
- Expr->getLoc (),
493
- Twine (" symbol '" ) + SymB->getName () +
494
- " ' could not be evaluated in a subtraction expression" );
487
+ reportError (Expr->getLoc (),
488
+ Twine (" symbol '" ) + SymB->getName () +
489
+ " ' could not be evaluated in a subtraction expression" );
495
490
return nullptr ;
496
491
}
497
492
@@ -501,9 +496,8 @@ const MCSymbol *MCAssembler::getBaseSymbol(const MCSymbol &Symbol) const {
501
496
502
497
const MCSymbol &ASym = *A;
503
498
if (ASym.isCommon ()) {
504
- getContext ().reportError (Expr->getLoc (),
505
- " Common symbol '" + ASym.getName () +
506
- " ' cannot be used in assignment expr" );
499
+ reportError (Expr->getLoc (), " Common symbol '" + ASym.getName () +
500
+ " ' cannot be used in assignment expr" );
507
501
return nullptr ;
508
502
}
509
503
@@ -690,8 +684,7 @@ static void writeFragment(raw_ostream &OS, const MCAssembler &Asm,
690
684
assert (ControlledNopLength >= 0 && " Expected non-negative NOP size" );
691
685
692
686
if (ControlledNopLength > MaximumNopLength) {
693
- Asm.getContext ().reportError (NF.getLoc (),
694
- " illegal NOP size " +
687
+ Asm.reportError (NF.getLoc (), " illegal NOP size " +
695
688
std::to_string (ControlledNopLength) +
696
689
" . (expected within [0, " +
697
690
std::to_string (MaximumNopLength) + " ])" );
@@ -800,15 +793,13 @@ void MCAssembler::writeSectionData(raw_ostream &OS,
800
793
// directives to fill the contents of virtual sections.
801
794
const MCDataFragment &DF = cast<MCDataFragment>(F);
802
795
if (DF.getFixups ().size ())
803
- getContext ().reportError (SMLoc (), Sec->getVirtualSectionKind () +
804
- " section '" + Sec->getName () +
805
- " ' cannot have fixups" );
796
+ reportError (SMLoc (), Sec->getVirtualSectionKind () + " section '" +
797
+ Sec->getName () + " ' cannot have fixups" );
806
798
for (char C : DF.getContents ())
807
799
if (C) {
808
- getContext ().reportError (SMLoc (),
809
- Sec->getVirtualSectionKind () +
810
- " section '" + Sec->getName () +
811
- " ' cannot have non-zero initializers" );
800
+ reportError (SMLoc (), Sec->getVirtualSectionKind () + " section '" +
801
+ Sec->getName () +
802
+ " ' cannot have non-zero initializers" );
812
803
break ;
813
804
}
814
805
break ;
@@ -1050,9 +1041,9 @@ bool MCAssembler::relaxLEB(MCLEBFragment &LF) {
1050
1041
bool Relaxed, UseZeroPad;
1051
1042
std::tie (Relaxed, UseZeroPad) = getBackend ().relaxLEB128 (LF, Value);
1052
1043
if (!Relaxed) {
1053
- getContext (). reportError (LF.getValue ().getLoc (),
1054
- Twine (LF.isSigned () ? " .s" : " .u" ) +
1055
- " leb128 expression is not absolute" );
1044
+ reportError (LF.getValue ().getLoc (),
1045
+ Twine (LF.isSigned () ? " .s" : " .u" ) +
1046
+ " leb128 expression is not absolute" );
1056
1047
LF.setValue (MCConstantExpr::create (0 , Context));
1057
1048
}
1058
1049
uint8_t Tmp[10 ]; // maximum size: ceil(64/7)
@@ -1165,8 +1156,8 @@ bool MCAssembler::relaxDwarfCallFrameFragment(MCDwarfCallFrameFragment &DF) {
1165
1156
int64_t Value;
1166
1157
bool Abs = DF.getAddrDelta ().evaluateAsAbsolute (Value, *this );
1167
1158
if (!Abs) {
1168
- getContext (). reportError (DF.getAddrDelta ().getLoc (),
1169
- " invalid CFI advance_loc expression" );
1159
+ reportError (DF.getAddrDelta ().getLoc (),
1160
+ " invalid CFI advance_loc expression" );
1170
1161
DF.setAddrDelta (MCConstantExpr::create (0 , Context));
1171
1162
return false ;
1172
1163
}
@@ -1244,6 +1235,10 @@ bool MCAssembler::layoutOnce() {
1244
1235
return Changed;
1245
1236
}
1246
1237
1238
+ void MCAssembler::reportError (SMLoc L, const Twine &Msg) const {
1239
+ getContext ().reportError (L, Msg);
1240
+ }
1241
+
1247
1242
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1248
1243
LLVM_DUMP_METHOD void MCAssembler::dump () const {
1249
1244
raw_ostream &OS = errs ();
0 commit comments