diff --git a/llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h b/llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h --- a/llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h +++ b/llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h @@ -122,6 +122,32 @@ : AsmRewrites(rewrites) {} }; +/// Ternary parse status returned by various parse* methods. +class ParseStatus { + enum class StatusTy { Success, Failure, NoMatch } Status; + +public: +#if __cplusplus >= 202002L + using enum StatusTy; +#else + static constexpr StatusTy Success = StatusTy::Success; + static constexpr StatusTy Failure = StatusTy::Failure; + static constexpr StatusTy NoMatch = StatusTy::NoMatch; +#endif + + constexpr ParseStatus() : Status(NoMatch) {} + + constexpr ParseStatus(StatusTy Status) : Status(Status) {} + + constexpr ParseStatus(bool Error) : Status(Error ? Failure : Success) {} + + template constexpr ParseStatus(T) = delete; + + constexpr bool isSuccess() const { return Status == StatusTy::Success; } + constexpr bool isFailure() const { return Status == StatusTy::Failure; } + constexpr bool isNoMatch() const { return Status == StatusTy::NoMatch; } +}; + enum OperandMatchResultTy { MatchOperand_Success, // operand matched successfully MatchOperand_NoMatch, // operand did not match @@ -408,6 +434,7 @@ } /// ParseDirective - Parse a target specific assembler directive + /// This method is deprecated, use 'parseDirective' instead. /// /// The parser is positioned following the directive name. The target /// specific directive parser should parse the entire directive doing or @@ -417,7 +444,19 @@ /// end-of-statement token and false is returned. /// /// \param DirectiveID - the identifier token of the directive. - virtual bool ParseDirective(AsmToken DirectiveID) = 0; + virtual bool ParseDirective(AsmToken DirectiveID) { return true; } + + /// Parses a target-specific assembler directive. + /// + /// The parser is positioned following the directive name. The target-specific + /// directive parser should parse the entire directive doing or recording any + /// target-specific work, or emit an error. On success, the entire line should + /// be parsed up to and including the end-of-statement token. On failure, the + /// parser is not required to read to the end of the line. If the directive is + /// not target-specific, no tokens should be consumed and NoMatch is returned. + /// + /// \param DirectiveID - The token identifying the directive. + virtual ParseStatus parseDirective(AsmToken DirectiveID); /// MatchAndEmitInstruction - Recognize a series of operands of a parsed /// instruction as an actual MCInst and emit it to the specified MCStreamer. diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -1999,20 +1999,12 @@ getTargetParser().flushPendingInstructions(getStreamer()); - SMLoc StartTokLoc = getTok().getLoc(); - bool TPDirectiveReturn = getTargetParser().ParseDirective(ID); - - if (hasPendingError()) - return true; - // Currently the return value should be true if we are - // uninterested but as this is at odds with the standard parsing - // convention (return true = error) we have instances of a parsed - // directive that fails returning true as an error. Catch these - // cases as best as possible errors here. - if (TPDirectiveReturn && StartTokLoc != getTok().getLoc()) + ParseStatus TPDirectiveReturn = getTargetParser().parseDirective(ID); + assert(TPDirectiveReturn.isFailure() == hasPendingError() && + "Should only return Failure iff there was an error"); + if (TPDirectiveReturn.isFailure()) return true; - // Return if we did some parsing or believe we succeeded. - if (!TPDirectiveReturn || StartTokLoc != getTok().getLoc()) + if (TPDirectiveReturn.isSuccess()) return false; // Next, check the extension directive map to see if any extension has diff --git a/llvm/lib/MC/MCParser/MCTargetAsmParser.cpp b/llvm/lib/MC/MCParser/MCTargetAsmParser.cpp --- a/llvm/lib/MC/MCParser/MCTargetAsmParser.cpp +++ b/llvm/lib/MC/MCParser/MCTargetAsmParser.cpp @@ -27,3 +27,24 @@ const MCSubtargetInfo &MCTargetAsmParser::getSTI() const { return *STI; } + +ParseStatus MCTargetAsmParser::parseDirective(AsmToken DirectiveID) { + SMLoc StartTokLoc = getTok().getLoc(); + // Delegate to ParseDirective by default for transition period. Once the + // transition is over, this method should just return NoMatch. + bool Res = ParseDirective(DirectiveID); + + // Some targets erroneously report success after emitting an error. + if (getParser().hasPendingError()) + return ParseStatus::Failure; + + // ParseDirective returns true if there was an error or if the directive is + // not target-specific. Disambiguate the two cases by comparing position of + // the lexer before and after calling the method: if no tokens were consumed, + // there was no match, otherwise there was a failure. + if (!Res) + return ParseStatus::Success; + if (getTok().getLoc() != StartTokLoc) + return ParseStatus::Failure; + return ParseStatus::NoMatch; +} diff --git a/llvm/lib/MC/MCParser/MasmParser.cpp b/llvm/lib/MC/MCParser/MasmParser.cpp --- a/llvm/lib/MC/MCParser/MasmParser.cpp +++ b/llvm/lib/MC/MCParser/MasmParser.cpp @@ -2304,21 +2304,15 @@ return (*Handler.second)(Handler.first, IDVal, IDLoc); // Next, let the target-specific assembly parser try. - SMLoc StartTokLoc = getTok().getLoc(); - bool TPDirectiveReturn = - ID.is(AsmToken::Identifier) && getTargetParser().ParseDirective(ID); + if (ID.isNot(AsmToken::Identifier)) + return false; - if (hasPendingError()) - return true; - // Currently the return value should be true if we are - // uninterested but as this is at odds with the standard parsing - // convention (return true = error) we have instances of a parsed - // directive that fails returning true as an error. Catch these - // cases as best as possible errors here. - if (TPDirectiveReturn && StartTokLoc != getTok().getLoc()) + ParseStatus TPDirectiveReturn = getTargetParser().ParseDirective(ID); + assert(TPDirectiveReturn.isFailure() == hasPendingError() && + "Should only return Failure iff there was an error"); + if (TPDirectiveReturn.isFailure()) return true; - // Return if we did some parsing or believe we succeeded. - if (!TPDirectiveReturn || StartTokLoc != getTok().getLoc()) + if (TPDirectiveReturn.isSuccess()) return false; // Finally, if no one else is interested in this directive, it must be diff --git a/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp b/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp --- a/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp +++ b/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp @@ -64,7 +64,7 @@ bool ParseInstruction(ParseInstructionInfo &Info, StringRef Name, SMLoc NameLoc, OperandVector &Operands) override; - bool ParseDirective(AsmToken DirectiveID) override; + ParseStatus parseDirective(AsmToken DirectiveID) override; OperandMatchResultTy parseMemriOperand(OperandVector &Operands); @@ -90,7 +90,7 @@ uint64_t const &ErrorInfo); bool missingFeature(SMLoc const &Loc, uint64_t const &ErrorInfo); - bool parseLiteralValues(unsigned SizeInBytes, SMLoc L); + ParseStatus parseLiteralValues(unsigned SizeInBytes, SMLoc L); public: AVRAsmParser(const MCSubtargetInfo &STI, MCAsmParser &Parser, @@ -674,19 +674,18 @@ return false; } -bool AVRAsmParser::ParseDirective(llvm::AsmToken DirectiveID) { +ParseStatus AVRAsmParser::parseDirective(llvm::AsmToken DirectiveID) { StringRef IDVal = DirectiveID.getIdentifier(); - if (IDVal.lower() == ".long") { - parseLiteralValues(SIZE_LONG, DirectiveID.getLoc()); - } else if (IDVal.lower() == ".word" || IDVal.lower() == ".short") { - parseLiteralValues(SIZE_WORD, DirectiveID.getLoc()); - } else if (IDVal.lower() == ".byte") { - parseLiteralValues(1, DirectiveID.getLoc()); - } - return true; + if (IDVal.lower() == ".long") + return parseLiteralValues(SIZE_LONG, DirectiveID.getLoc()); + if (IDVal.lower() == ".word" || IDVal.lower() == ".short") + return parseLiteralValues(SIZE_WORD, DirectiveID.getLoc()); + if (IDVal.lower() == ".byte") + return parseLiteralValues(1, DirectiveID.getLoc()); + return ParseStatus::NoMatch; } -bool AVRAsmParser::parseLiteralValues(unsigned SizeInBytes, SMLoc L) { +ParseStatus AVRAsmParser::parseLiteralValues(unsigned SizeInBytes, SMLoc L) { MCAsmParser &Parser = getParser(); AVRMCELFStreamer &AVRStreamer = static_cast(Parser.getStreamer()); @@ -698,7 +697,7 @@ MCSymbol *Symbol = getContext().getOrCreateSymbol(".text"); AVRStreamer.emitValueForModiferKind(Symbol, SizeInBytes, L, AVRMCExpr::VK_AVR_None); - return false; + return ParseStatus::NoMatch; } if (Parser.getTok().getKind() == AsmToken::Identifier && @@ -715,7 +714,10 @@ MCSymbol *Symbol = getContext().getOrCreateSymbol(Parser.getTok().getString()); AVRStreamer.emitValueForModiferKind(Symbol, SizeInBytes, L, ModifierKind); - return false; + Lex(); // Eat the symbol name. + if (parseToken(AsmToken::RParen)) + return ParseStatus::Failure; + return parseEOL(); } auto parseOne = [&]() -> bool { diff --git a/llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp b/llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp --- a/llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp +++ b/llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp @@ -47,7 +47,7 @@ bool ParseInstruction(ParseInstructionInfo &Info, StringRef Name, SMLoc NameLoc, OperandVector &Operands) override; - bool ParseDirective(AsmToken DirectiveID) override; + ParseStatus parseDirective(AsmToken DirectiveID) override; // "=" is used as assignment operator for assembly statment, so can't be used // for symbol assignment. @@ -516,7 +516,9 @@ return false; } -bool BPFAsmParser::ParseDirective(AsmToken DirectiveID) { return true; } +ParseStatus BPFAsmParser::parseDirective(AsmToken DirectiveID) { + return ParseStatus::NoMatch; +} extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeBPFAsmParser() { RegisterMCAsmParser X(getTheBPFTarget()); diff --git a/llvm/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp b/llvm/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp --- a/llvm/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp +++ b/llvm/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp @@ -62,7 +62,7 @@ bool parsePrePost(StringRef Type, int *OffsetValue); - bool ParseDirective(AsmToken DirectiveID) override; + ParseStatus parseDirective(AsmToken DirectiveID) override; bool ParseInstruction(ParseInstructionInfo &Info, StringRef Name, SMLoc NameLoc, OperandVector &Operands) override; @@ -649,7 +649,9 @@ } // end anonymous namespace -bool LanaiAsmParser::ParseDirective(AsmToken /*DirectiveId*/) { return true; } +ParseStatus LanaiAsmParser::parseDirective(AsmToken DirectiveID) { + return ParseStatus::NoMatch; +} bool LanaiAsmParser::MatchAndEmitInstruction(SMLoc IdLoc, unsigned &Opcode, OperandVector &Operands, diff --git a/llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp b/llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp --- a/llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp +++ b/llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp @@ -51,7 +51,9 @@ bool ParseInstruction(ParseInstructionInfo &Info, StringRef Name, SMLoc NameLoc, OperandVector &Operands) override; - bool ParseDirective(AsmToken DirectiveID) override { return true; } + ParseStatus parseDirective(AsmToken DirectiveID) override { + return ParseStatus::NoMatch; + } bool MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode, OperandVector &Operands, MCStreamer &Out, diff --git a/llvm/lib/Target/M68k/AsmParser/M68kAsmParser.cpp b/llvm/lib/Target/M68k/AsmParser/M68kAsmParser.cpp --- a/llvm/lib/Target/M68k/AsmParser/M68kAsmParser.cpp +++ b/llvm/lib/Target/M68k/AsmParser/M68kAsmParser.cpp @@ -72,7 +72,7 @@ SMLoc &EndLoc) override; bool ParseInstruction(ParseInstructionInfo &Info, StringRef Name, SMLoc NameLoc, OperandVector &Operands) override; - bool ParseDirective(AsmToken DirectiveID) override; + ParseStatus parseDirective(AsmToken DirectiveID) override; bool MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode, OperandVector &Operands, MCStreamer &Out, uint64_t &ErrorInfo, @@ -992,7 +992,9 @@ return false; } -bool M68kAsmParser::ParseDirective(AsmToken DirectiveID) { return true; } +ParseStatus M68kAsmParser::parseDirective(AsmToken DirectiveID) { + return ParseStatus::NoMatch; +} bool M68kAsmParser::invalidOperand(SMLoc const &Loc, OperandVector const &Operands, diff --git a/llvm/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp b/llvm/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp --- a/llvm/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp +++ b/llvm/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp @@ -53,7 +53,7 @@ bool ParseInstruction(ParseInstructionInfo &Info, StringRef Name, SMLoc NameLoc, OperandVector &Operands) override; - bool ParseDirective(AsmToken DirectiveID) override; + ParseStatus parseDirective(AsmToken DirectiveID) override; bool ParseDirectiveRefSym(AsmToken DirectiveID); unsigned validateTargetOperandClass(MCParsedAsmOperand &Op, @@ -424,27 +424,26 @@ } bool MSP430AsmParser::ParseDirectiveRefSym(AsmToken DirectiveID) { - StringRef Name; - if (getParser().parseIdentifier(Name)) - return TokError("expected identifier in directive"); + StringRef Name; + if (getParser().parseIdentifier(Name)) + return TokError("expected identifier in directive"); - MCSymbol *Sym = getContext().getOrCreateSymbol(Name); - getStreamer().emitSymbolAttribute(Sym, MCSA_Global); - return false; + MCSymbol *Sym = getContext().getOrCreateSymbol(Name); + getStreamer().emitSymbolAttribute(Sym, MCSA_Global); + return parseEOL(); } -bool MSP430AsmParser::ParseDirective(AsmToken DirectiveID) { +ParseStatus MSP430AsmParser::parseDirective(AsmToken DirectiveID) { StringRef IDVal = DirectiveID.getIdentifier(); - if (IDVal.lower() == ".long") { - ParseLiteralValues(4, DirectiveID.getLoc()); - } else if (IDVal.lower() == ".word" || IDVal.lower() == ".short") { - ParseLiteralValues(2, DirectiveID.getLoc()); - } else if (IDVal.lower() == ".byte") { - ParseLiteralValues(1, DirectiveID.getLoc()); - } else if (IDVal.lower() == ".refsym") { + if (IDVal.lower() == ".long") + return ParseLiteralValues(4, DirectiveID.getLoc()); + if (IDVal.lower() == ".word" || IDVal.lower() == ".short") + return ParseLiteralValues(2, DirectiveID.getLoc()); + if (IDVal.lower() == ".byte") + return ParseLiteralValues(1, DirectiveID.getLoc()); + if (IDVal.lower() == ".refsym") return ParseDirectiveRefSym(DirectiveID); - } - return true; + return ParseStatus::NoMatch; } bool MSP430AsmParser::ParseOperand(OperandVector &Operands) { diff --git a/llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp b/llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp --- a/llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp +++ b/llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp @@ -494,7 +494,7 @@ } // Override MCTargetAsmParser. - bool ParseDirective(AsmToken DirectiveID) override; + ParseStatus parseDirective(AsmToken DirectiveID) override; bool parseRegister(MCRegister &RegNo, SMLoc &StartLoc, SMLoc &EndLoc) override; bool ParseRegister(MCRegister &RegNo, SMLoc &StartLoc, SMLoc &EndLoc, @@ -1219,7 +1219,7 @@ return MatchOperand_Success; } -bool SystemZAsmParser::ParseDirective(AsmToken DirectiveID) { +ParseStatus SystemZAsmParser::parseDirective(AsmToken DirectiveID) { StringRef IDVal = DirectiveID.getIdentifier(); if (IDVal == ".insn") @@ -1229,7 +1229,7 @@ if (IDVal.startswith(".gnu_attribute")) return ParseGNUAttribute(DirectiveID.getLoc()); - return true; + return ParseStatus::NoMatch; } /// ParseDirectiveInsn @@ -1369,15 +1369,13 @@ return false; // Tag_GNU_S390_ABI_Vector tag is '8' and can be 0, 1, or 2. - if (Tag != 8 || (IntegerValue < 0 || IntegerValue > 2)) { - Error(Parser.getTok().getLoc(), - "Unrecognized .gnu_attribute tag/value pair."); - return false; - } + if (Tag != 8 || (IntegerValue < 0 || IntegerValue > 2)) + return Error(Parser.getTok().getLoc(), + "Unrecognized .gnu_attribute tag/value pair."); Parser.getStreamer().emitGNUAttribute(Tag, IntegerValue); - return true; + return false; } bool SystemZAsmParser::ParseRegister(MCRegister &RegNo, SMLoc &StartLoc, diff --git a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp --- a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp +++ b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp @@ -785,13 +785,7 @@ // This function processes wasm-specific directives streamed to // WebAssemblyTargetStreamer, all others go to the generic parser // (see WasmAsmParser). - bool ParseDirective(AsmToken DirectiveID) override { - // This function has a really weird return value behavior that is different - // from all the other parsing functions: - // - return true && no tokens consumed -> don't know this directive / let - // the generic parser handle it. - // - return true && tokens consumed -> a parsing error occurred. - // - return false -> processed this directive successfully. + ParseStatus parseDirective(AsmToken DirectiveID) override { assert(DirectiveID.getKind() == AsmToken::Identifier); auto &Out = getStreamer(); auto &TOut = @@ -803,13 +797,13 @@ if (DirectiveID.getString() == ".globaltype") { auto SymName = expectIdent(); if (SymName.empty()) - return true; + return ParseStatus::Failure; if (expect(AsmToken::Comma, ",")) - return true; + return ParseStatus::Failure; auto TypeTok = Lexer.getTok(); auto TypeName = expectIdent(); if (TypeName.empty()) - return true; + return ParseStatus::Failure; auto Type = WebAssembly::parseType(TypeName); if (!Type) return error("Unknown type in .globaltype directive: ", TypeTok); @@ -839,14 +833,14 @@ // .tabletype SYM, ELEMTYPE[, MINSIZE[, MAXSIZE]] auto SymName = expectIdent(); if (SymName.empty()) - return true; + return ParseStatus::Failure; if (expect(AsmToken::Comma, ",")) - return true; + return ParseStatus::Failure; auto ElemTypeTok = Lexer.getTok(); auto ElemTypeName = expectIdent(); if (ElemTypeName.empty()) - return true; + return ParseStatus::Failure; std::optional ElemType = WebAssembly::parseType(ElemTypeName); if (!ElemType) @@ -854,7 +848,7 @@ wasm::WasmLimits Limits = DefaultLimits(); if (isNext(AsmToken::Comma) && parseLimits(&Limits)) - return true; + return ParseStatus::Failure; // Now that we have the name and table type, we can actually create the // symbol @@ -874,7 +868,7 @@ // parses the locals separately. auto SymName = expectIdent(); if (SymName.empty()) - return true; + return ParseStatus::Failure; auto WasmSym = cast(Ctx.getOrCreateSymbol(SymName)); if (WasmSym->isDefined()) { // We push 'Function' either when a label is parsed or a .functype @@ -890,7 +884,7 @@ if (CurrentState != FunctionLabel) { // This .functype indicates a start of a function. if (ensureEmptyNestingStack()) - return true; + return ParseStatus::Failure; push(Function); } CurrentState = FunctionStart; @@ -898,7 +892,7 @@ } auto Signature = std::make_unique(); if (parseSignature(Signature.get())) - return true; + return ParseStatus::Failure; TC.funcDecl(*Signature); WasmSym->setSignature(Signature.get()); addSignature(std::move(Signature)); @@ -911,47 +905,50 @@ if (DirectiveID.getString() == ".export_name") { auto SymName = expectIdent(); if (SymName.empty()) - return true; + return ParseStatus::Failure; if (expect(AsmToken::Comma, ",")) - return true; + return ParseStatus::Failure; auto ExportName = expectIdent(); auto WasmSym = cast(Ctx.getOrCreateSymbol(SymName)); WasmSym->setExportName(storeName(ExportName)); TOut.emitExportName(WasmSym, ExportName); + return expect(AsmToken::EndOfStatement, "EOL"); } if (DirectiveID.getString() == ".import_module") { auto SymName = expectIdent(); if (SymName.empty()) - return true; + return ParseStatus::Failure; if (expect(AsmToken::Comma, ",")) - return true; + return ParseStatus::Failure; auto ImportModule = expectIdent(); auto WasmSym = cast(Ctx.getOrCreateSymbol(SymName)); WasmSym->setImportModule(storeName(ImportModule)); TOut.emitImportModule(WasmSym, ImportModule); + return expect(AsmToken::EndOfStatement, "EOL"); } if (DirectiveID.getString() == ".import_name") { auto SymName = expectIdent(); if (SymName.empty()) - return true; + return ParseStatus::Failure; if (expect(AsmToken::Comma, ",")) - return true; + return ParseStatus::Failure; auto ImportName = expectIdent(); auto WasmSym = cast(Ctx.getOrCreateSymbol(SymName)); WasmSym->setImportName(storeName(ImportName)); TOut.emitImportName(WasmSym, ImportName); + return expect(AsmToken::EndOfStatement, "EOL"); } if (DirectiveID.getString() == ".tagtype") { auto SymName = expectIdent(); if (SymName.empty()) - return true; + return ParseStatus::Failure; auto WasmSym = cast(Ctx.getOrCreateSymbol(SymName)); auto Signature = std::make_unique(); if (parseRegTypeList(Signature->Params)) - return true; + return ParseStatus::Failure; WasmSym->setSignature(Signature.get()); addSignature(std::move(Signature)); WasmSym->setType(wasm::WASM_SYMBOL_TYPE_TAG); @@ -966,7 +963,7 @@ Lexer.getTok()); SmallVector Locals; if (parseRegTypeList(Locals)) - return true; + return ParseStatus::Failure; TC.localDecl(Locals); TOut.emitLocal(Locals); CurrentState = FunctionLocals; @@ -978,7 +975,7 @@ DirectiveID.getString() == ".int32" || DirectiveID.getString() == ".int64") { if (CheckDataSection()) - return true; + return ParseStatus::Failure; const MCExpr *Val; SMLoc End; if (Parser.parseExpression(Val, End)) @@ -991,7 +988,7 @@ if (DirectiveID.getString() == ".asciz") { if (CheckDataSection()) - return true; + return ParseStatus::Failure; std::string S; if (Parser.parseEscapedString(S)) return error("Cannot parse string constant: ", Lexer.getTok()); @@ -999,7 +996,7 @@ return expect(AsmToken::EndOfStatement, "EOL"); } - return true; // We didn't process this directive. + return ParseStatus::NoMatch; // We didn't process this directive. } // Called either when the first instruction is parsed of the function ends. diff --git a/llvm/lib/Target/Xtensa/AsmParser/XtensaAsmParser.cpp b/llvm/lib/Target/Xtensa/AsmParser/XtensaAsmParser.cpp --- a/llvm/lib/Target/Xtensa/AsmParser/XtensaAsmParser.cpp +++ b/llvm/lib/Target/Xtensa/AsmParser/XtensaAsmParser.cpp @@ -36,7 +36,7 @@ SMLoc getLoc() const { return getParser().getTok().getLoc(); } // Override MCTargetAsmParser. - bool ParseDirective(AsmToken DirectiveID) override; + ParseStatus parseDirective(AsmToken DirectiveID) override; bool parseRegister(MCRegister &RegNo, SMLoc &StartLoc, SMLoc &EndLoc) override; bool ParseInstruction(ParseInstructionInfo &Info, StringRef Name, @@ -697,7 +697,9 @@ return false; } -bool XtensaAsmParser::ParseDirective(AsmToken DirectiveID) { return true; } +ParseStatus XtensaAsmParser::parseDirective(AsmToken DirectiveID) { + return ParseStatus::NoMatch; +} // Force static initialization. extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeXtensaAsmParser() {