39 if (
parseToken(Token::l_paren,
"expected '(' in callsite location"))
48 if (
getToken().isNot(Token::bare_identifier) ||
59 if (
parseToken(Token::r_paren,
"expected ')' in callsite location"))
79 "expected '>' after fused location metadata"))
88 locations.push_back(newLoc);
93 " in fused location"))
106 std::optional<unsigned> startLine, startColumn, endLine, endColumn;
111 if (
getToken().isNot(Token::integer))
113 "expected integer line number in FileLineColRange");
117 "expected integer line number in FileLineColRange");
121 if (
getToken().isNot(Token::colon)) {
128 if (
getToken().isNot(Token::integer)) {
130 "expected integer column number in FileLineColRange");
133 if (!startColumn.has_value())
134 return emitError(
"expected integer column number in FileLineColRange");
144 if (
getToken().is(Token::integer)) {
148 "expected integer line number in FileLineColRange");
154 if (
getToken().isNot(Token::colon)) {
156 "expected either integer or `:` post `to` in FileLineColRange");
161 if (
getToken().isNot(Token::integer)) {
163 "expected integer column number in FileLineColRange");
166 if (!endColumn.has_value())
167 return emitError(
"expected integer column number in FileLineColRange");
170 if (endLine.has_value()) {
172 *startColumn, *endLine, *endColumn);
175 *startColumn, *endColumn);
193 "expected ')' after child location of NameLoc"))
204 if (
getToken().is(Token::hash_identifier)) {
208 if (!(loc = dyn_cast<LocationAttr>(locAttr)))
209 return emitError(
"expected location attribute, but got") << locAttr;
218 if (!
getToken().is(Token::bare_identifier))
222 if (
getToken().getSpelling() ==
"callsite")
226 if (
getToken().getSpelling() ==
"fused")
230 if (
getToken().getSpelling() ==
"unknown") {
@ Square
Square brackets surrounding zero or more operands.
Attributes are known-constant values of operations.
static FileLineColLoc get(StringAttr filename, unsigned line, unsigned column)
Location objects represent source locations information in MLIR.
std::string getStringValue() const
Given a token containing a string literal, return its value, including removing the quote characters ...
std::optional< unsigned > getUnsignedIntegerValue() const
For an integer token, return its value as an unsigned.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
ParseResult parseToken(Token::Kind expectedToken, const Twine &message)
Consume the specified token if present and return success.
InFlightDiagnostic emitError(const Twine &message={})
Emit an error and return failure.
Attribute parseAttribute(Type type={})
Parse an arbitrary attribute with an optional type.
StringRef getTokenSpelling() const
ParseResult parseLocationInstance(LocationAttr &loc)
Parse a raw location instance.
void consumeToken()
Advance the current lexer onto the next token.
MLIRContext * getContext() const
InFlightDiagnostic emitWrongTokenError(const Twine &message={})
Emit an error about a "wrong token".
ParseResult parseCommaSeparatedList(Delimiter delimiter, function_ref< ParseResult()> parseElementFn, StringRef contextMessage=StringRef())
Parse a list of comma-separated items with an optional delimiter.
ParseResult parseNameOrFileLineColRange(LocationAttr &loc)
Parse a name or FileLineCol location instance.
ParseResult parseFusedLocation(LocationAttr &loc)
Parse a fused location instance.
bool isCurrentTokenAKeyword() const
Returns true if the current token corresponds to a keyword.
ParseResult parseCallSiteLocation(LocationAttr &loc)
Parse a callsite location instance.
Attribute parseExtendedAttr(Type type)
Parse an extended attribute.
const Token & getToken() const
Return the current token the parser is inspecting.
bool consumeIf(Token::Kind kind)
If the current token has the specified kind, consume it and return true.
Include the generated interface declarations.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...