bool parseIdentifier(StringRef &Res) override;
void eatToEndOfStatement() override;
- void checkForValidSection() override;
+ bool checkForValidSection() override;
/// }
return HadError || getContext().hadError();
}
-void AsmParser::checkForValidSection() {
+bool AsmParser::checkForValidSection() {
if (!ParsingInlineAsm && !getStreamer().getCurrentSection().first) {
- printError(getTok().getLoc(),
- "expected section directive before assembly directive");
Out.InitSections(false);
+ return Error(getTok().getLoc(),
+ "expected section directive before assembly directive");
}
+ return false;
}
/// \brief Throw away the rest of the line for testing purposes.
case AsmToken::Colon: {
if (!getTargetParser().isLabel(ID))
break;
- checkForValidSection();
+ if (checkForValidSection())
+ return true;
// identifier ':' -> Label.
Lex();
if (ParsingInlineAsm && (IDVal == "even"))
Info.AsmRewrites->emplace_back(AOK_EVEN, IDLoc, 4);
- checkForValidSection();
+ if (checkForValidSection())
+ return true;
// Canonicalize the opcode to lower case.
std::string OpcodeStr = IDVal.lower();
/// ::= ( .ascii | .asciz | .string ) [ "string" ( , "string" )* ]
bool AsmParser::parseDirectiveAscii(StringRef IDVal, bool ZeroTerminated) {
if (getLexer().isNot(AsmToken::EndOfStatement)) {
- checkForValidSection();
+ if (checkForValidSection())
+ return true;
while (true) {
std::string Data;
/// ::= (.byte | .short | ... ) [ expression (, expression)* ]
bool AsmParser::parseDirectiveValue(unsigned Size) {
if (getLexer().isNot(AsmToken::EndOfStatement)) {
- checkForValidSection();
+ if (checkForValidSection())
+ return true;
while (true) {
const MCExpr *Value;
/// ::= .octa [ hexconstant (, hexconstant)* ]
bool AsmParser::parseDirectiveOctaValue() {
if (getLexer().isNot(AsmToken::EndOfStatement)) {
- checkForValidSection();
+ if (checkForValidSection())
+ return true;
while (true) {
if (getTok().is(AsmToken::Error))
/// ::= (.single | .double) [ expression (, expression)* ]
bool AsmParser::parseDirectiveRealValue(const fltSemantics &Semantics) {
if (getLexer().isNot(AsmToken::EndOfStatement)) {
- checkForValidSection();
+ if (checkForValidSection())
+ return true;
while (true) {
APInt AsInt;
/// parseDirectiveZero
/// ::= .zero expression
bool AsmParser::parseDirectiveZero() {
- checkForValidSection();
-
SMLoc NumBytesLoc = Lexer.getLoc();
const MCExpr *NumBytes;
- if (parseExpression(NumBytes))
+ if (checkForValidSection() || parseExpression(NumBytes))
return true;
int64_t Val = 0;
/// parseDirectiveFill
/// ::= .fill expression [ , expression [ , expression ] ]
bool AsmParser::parseDirectiveFill() {
- checkForValidSection();
-
SMLoc NumValuesLoc = Lexer.getLoc();
const MCExpr *NumValues;
- if (parseExpression(NumValues))
+ if (checkForValidSection() || parseExpression(NumValues))
return true;
int64_t FillSize = 1;
/// parseDirectiveOrg
/// ::= .org expression [ , expression ]
bool AsmParser::parseDirectiveOrg() {
- checkForValidSection();
-
const MCExpr *Offset;
- if (parseExpression(Offset))
+ if (checkForValidSection() || parseExpression(Offset))
return true;
// Parse optional fill expression.
/// parseDirectiveAlign
/// ::= {.align, ...} expression [ , expression [ , expression ]]
bool AsmParser::parseDirectiveAlign(bool IsPow2, unsigned ValueSize) {
- checkForValidSection();
-
SMLoc AlignmentLoc = getLexer().getLoc();
int64_t Alignment;
- if (parseAbsoluteExpression(Alignment))
+ if (checkForValidSection() || parseAbsoluteExpression(Alignment))
return true;
SMLoc MaxBytesLoc;
/// parseDirectiveBundleAlignMode
/// ::= {.bundle_align_mode} expression
bool AsmParser::parseDirectiveBundleAlignMode() {
- checkForValidSection();
-
// Expect a single argument: an expression that evaluates to a constant
// in the inclusive range 0-30.
SMLoc ExprLoc = getLexer().getLoc();
int64_t AlignSizePow2;
- if (parseAbsoluteExpression(AlignSizePow2) ||
+ if (checkForValidSection() || parseAbsoluteExpression(AlignSizePow2) ||
parseToken(AsmToken::EndOfStatement, "unexpected token after expression "
"in '.bundle_align_mode' "
"directive") ||
/// parseDirectiveBundleLock
/// ::= {.bundle_lock} [align_to_end]
bool AsmParser::parseDirectiveBundleLock() {
- checkForValidSection();
+ if (checkForValidSection())
+ return true;
bool AlignToEnd = false;
if (getLexer().isNot(AsmToken::EndOfStatement)) {
/// parseDirectiveBundleLock
/// ::= {.bundle_lock}
bool AsmParser::parseDirectiveBundleUnlock() {
- checkForValidSection();
-
- if (parseToken(AsmToken::EndOfStatement,
+ if (checkForValidSection() ||
+ parseToken(AsmToken::EndOfStatement,
"unexpected token in '.bundle_unlock' directive"))
return true;
/// parseDirectiveSpace
/// ::= (.skip | .space) expression [ , expression ]
bool AsmParser::parseDirectiveSpace(StringRef IDVal) {
- checkForValidSection();
SMLoc NumBytesLoc = Lexer.getLoc();
const MCExpr *NumBytes;
- if (parseExpression(NumBytes))
+ if (checkForValidSection() || parseExpression(NumBytes))
return true;
int64_t FillExpr = 0;
/// parseDirectiveDCB
/// ::= .dcb.{b, l, w} expression, expression
bool AsmParser::parseDirectiveDCB(StringRef IDVal, unsigned Size) {
- checkForValidSection();
-
SMLoc NumValuesLoc = Lexer.getLoc();
int64_t NumValues;
- if (parseAbsoluteExpression(NumValues))
+ if (checkForValidSection() || parseAbsoluteExpression(NumValues))
return true;
if (NumValues < 0) {
/// parseDirectiveRealDCB
/// ::= .dcb.{d, s} expression, expression
bool AsmParser::parseDirectiveRealDCB(StringRef IDVal, const fltSemantics &Semantics) {
- checkForValidSection();
-
SMLoc NumValuesLoc = Lexer.getLoc();
int64_t NumValues;
- if (parseAbsoluteExpression(NumValues))
+ if (checkForValidSection() || parseAbsoluteExpression(NumValues))
return true;
if (NumValues < 0) {
/// parseDirectiveDS
/// ::= .ds.{b, d, l, p, s, w, x} expression
bool AsmParser::parseDirectiveDS(StringRef IDVal, unsigned Size) {
- checkForValidSection();
SMLoc NumValuesLoc = Lexer.getLoc();
int64_t NumValues;
- if (parseAbsoluteExpression(NumValues))
+ if (checkForValidSection() || parseAbsoluteExpression(NumValues))
return true;
if (NumValues < 0) {
/// parseDirectiveLEB128
/// ::= (.sleb128 | .uleb128) [ expression (, expression)* ]
bool AsmParser::parseDirectiveLEB128(bool Signed) {
- checkForValidSection();
+ if (checkForValidSection())
+ return true;
+
const MCExpr *Value;
while (true) {
/// parseDirectiveComm
/// ::= ( .comm | .lcomm ) identifier , size_expression [ , align_expression ]
bool AsmParser::parseDirectiveComm(bool IsLocal) {
- checkForValidSection();
+ if (checkForValidSection())
+ return true;
SMLoc IDLoc = getLexer().getLoc();
StringRef Name;