aboutsummaryrefslogtreecommitdiff
path: root/mlir/lib/Query
diff options
context:
space:
mode:
Diffstat (limited to 'mlir/lib/Query')
-rw-r--r--mlir/lib/Query/Matcher/Parser.cpp8
-rw-r--r--mlir/lib/Query/Query.cpp5
2 files changed, 7 insertions, 6 deletions
diff --git a/mlir/lib/Query/Matcher/Parser.cpp b/mlir/lib/Query/Matcher/Parser.cpp
index e392a88..7bfe03d 100644
--- a/mlir/lib/Query/Matcher/Parser.cpp
+++ b/mlir/lib/Query/Matcher/Parser.cpp
@@ -27,7 +27,7 @@ struct Parser::TokenInfo {
}
// Known identifiers.
- static const char *const ID_Extract;
+ static const char *const idExtract;
llvm::StringRef text;
TokenKind kind = TokenKind::Eof;
@@ -35,7 +35,7 @@ struct Parser::TokenInfo {
VariantValue value;
};
-const char *const Parser::TokenInfo::ID_Extract = "extract";
+const char *const Parser::TokenInfo::idExtract = "extract";
class Parser::CodeTokenizer {
public:
@@ -452,13 +452,13 @@ bool Parser::parseMatcherExpressionImpl(const TokenInfo &nameToken,
}
if (chainCallToken.kind != TokenKind::Ident ||
- chainCallToken.text != TokenInfo::ID_Extract) {
+ chainCallToken.text != TokenInfo::idExtract) {
error->addError(chainCallToken.range,
ErrorType::ParserMalformedChainedExpr);
return false;
}
- if (chainCallToken.text == TokenInfo::ID_Extract &&
+ if (chainCallToken.text == TokenInfo::idExtract &&
!parseChainedExpression(functionName))
return false;
}
diff --git a/mlir/lib/Query/Query.cpp b/mlir/lib/Query/Query.cpp
index 375e820..cf8a4d2 100644
--- a/mlir/lib/Query/Query.cpp
+++ b/mlir/lib/Query/Query.cpp
@@ -121,12 +121,13 @@ LogicalResult MatchQuery::run(llvm::raw_ostream &os, QuerySession &qs) const {
Operation *rootOp = qs.getRootOp();
int matchCount = 0;
matcher::MatchFinder finder;
+
+ StringRef functionName = matcher.getFunctionName();
auto matches = finder.collectMatches(rootOp, std::move(matcher));
// An extract call is recognized by considering if the matcher has a name.
// TODO: Consider making the extract more explicit.
- if (matcher.hasFunctionName()) {
- auto functionName = matcher.getFunctionName();
+ if (!functionName.empty()) {
std::vector<Operation *> flattenedMatches =
finder.flattenMatchedOps(matches);
Operation *function =