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"))
109 if (
getToken().isNot(Token::integer))
111 "expected integer line number in FileLineColLoc");
115 "expected integer line number in FileLineColLoc");
119 if (
parseToken(Token::colon,
"expected ':' in FileLineColLoc"))
123 if (
getToken().isNot(Token::integer))
125 "expected integer column number in FileLineColLoc");
127 if (!column.has_value())
128 return emitError(
"expected integer column number in FileLineColLoc");
148 "expected ')' after child location of NameLoc"))
159 if (
getToken().is(Token::hash_identifier)) {
163 if (!(loc = dyn_cast<LocationAttr>(locAttr)))
164 return emitError(
"expected location attribute, but got") << locAttr;
173 if (!
getToken().is(Token::bare_identifier))
177 if (
getToken().getSpelling() ==
"callsite")
181 if (
getToken().getSpelling() ==
"fused")
185 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.
This class represents success/failure for parsing-like operations that find it important to chain tog...
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.
Detect if any of the given parameter types has a sub-element handler.
Include the generated interface declarations.
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...