38 if (
parseToken(Token::l_paren,
"expected '(' in callsite location"))
47 if (
getToken().isNot(Token::bare_identifier) ||
58 if (
parseToken(Token::r_paren,
"expected ')' in callsite location"))
78 "expected '>' after fused location metadata"))
87 locations.push_back(newLoc);
92 " in fused location"))
108 if (
getToken().isNot(Token::integer))
110 "expected integer line number in FileLineColLoc");
114 "expected integer line number in FileLineColLoc");
118 if (
parseToken(Token::colon,
"expected ':' in FileLineColLoc"))
122 if (
getToken().isNot(Token::integer))
124 "expected integer column number in FileLineColLoc");
126 if (!column.has_value())
127 return emitError(
"expected integer column number in FileLineColLoc");
147 "expected ')' after child location of NameLoc"))
158 if (
getToken().is(Token::hash_identifier)) {
162 if (!(loc = dyn_cast<LocationAttr>(locAttr)))
163 return emitError(
"expected location attribute, but got") << locAttr;
172 if (!
getToken().is(Token::bare_identifier))
176 if (
getToken().getSpelling() ==
"callsite")
180 if (
getToken().getSpelling() ==
"fused")
184 if (
getToken().getSpelling() ==
"unknown") {
@ Square
Square brackets surrounding zero or more operands.
Attributes are known-constant values of operations.
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.
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 parseFusedLocation(LocationAttr &loc)
Parse a fused location instance.
ParseResult parseCallSiteLocation(LocationAttr &loc)
Parse a callsite location instance.
ParseResult parseNameOrFileLineColLocation(LocationAttr &loc)
Parse a name or FileLineCol 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...