
Conventionally, parsing methods return false on success and true on error. However, directive parsing methods need a third state: the directive is not target specific. AsmParser::parseStatement detected this case by using a fragile heuristic: if the target parser did not consume any tokens, the directive is assumed to be not target-specific. Some targets fail to follow the convention: they return success after emitting an error or do not consume the entire line and return failure on successful parsing. This was partially worked around by checking for pending errors in parseStatement. This patch tries to improve the situation by introducing parseDirective method that returns ParseStatus -- three-state class. The new method should eventually replace the old one returning bool. ParseStatus is intentionally implicitly constructible from bool to allow uses like `return Error(Loc, "message")`. It also has a potential to replace OperandMatchResulTy as it is more convenient to use due to the implicit construction from bool and more type safe. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D154101
14 lines
384 B
ArmAsm
14 lines
384 B
ArmAsm
# RUN: not llvm-mc -triple=wasm32 %s 2>&1 | FileCheck %s
|
|
|
|
# CHECK: [[#@LINE+1]]:16: error: Expected identifier, got: 42
|
|
.import_module 42
|
|
|
|
# CHECK: [[#@LINE+1]]:19: error: Expected ,, instead got:
|
|
.import_module foo
|
|
|
|
# CHECK: [[#@LINE+1]]:20: error: Expected identifier, got:
|
|
.import_module foo,
|
|
|
|
# CHECK: [[#@LINE+1]]:24: error: Expected EOL, instead got: ,
|
|
.import_module foo, bar,
|