[mlir][Parser] Fix crash when resolving invalid operands with missing location (#128163) When `resolveOperands` reports an error and no valid `SMLoc` was provided, report the error at the beginning of the op instead of crashing. ``` Assert `Ptr >= BufStart && Ptr <= Buffer->getBufferEnd()' in llvm/lib/Support/SourceMgr.cpp:llvm::SourceMgr::SrcBuffer::getLineNumberSpecialized failed ``` E.g., this is currently the case when parsing the following op with a type but without any operands: ``` let assemblyFormat = "$str (`,` $args^)? attr-dict (`:` type($args)^)?"; ``` Reported error (with this PR): ``` within split at mlir/test/IR/invalid-ops.mlir:122 offset :4:1: error: custom op 'test.variadic_args_types_split' number of operands and types do not match: got 0 operands and 1 types test.variadic_args_types_split "hello_world" : i32 ^ ``` In the ODS-generated C++, the `SMLoc` is populated when parsing the optional group containing `$args`. However, this group is missing in the test case. There are likely additional hand-written parsers that suffer from the same problem. Note: I tried emitting a second `SMLoc` for the optional type group in the `OpFormatGen.cpp`, but this adds quite a bit of complexity in the code base for little improvement in user experience.
Welcome to the LLVM project!
This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.
The LLVM project has multiple components. The core of the project is itself called “LLVM”. This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.
C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.
Other components include: the libc++ C++ standard library, the LLD linker, and more.
Consult the Getting Started with LLVM page for information on building and running LLVM.
For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.
Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.
The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.