[clang] 8021078 - [ASTMatchers] Change internal method API
Stephen Kelly via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 7 07:38:43 PST 2021
Author: Stephen Kelly
Date: 2021-02-07T15:37:35Z
New Revision: 8021078bc993073d703b91eae8f9b9ed8de478dc
URL: https://github.com/llvm/llvm-project/commit/8021078bc993073d703b91eae8f9b9ed8de478dc
DIFF: https://github.com/llvm/llvm-project/commit/8021078bc993073d703b91eae8f9b9ed8de478dc.diff
LOG: [ASTMatchers] Change internal method API
This will make it possible to parse matchers built dynamically.
Added:
Modified:
clang/include/clang/ASTMatchers/Dynamic/Parser.h
clang/lib/ASTMatchers/Dynamic/Parser.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/ASTMatchers/Dynamic/Parser.h b/clang/include/clang/ASTMatchers/Dynamic/Parser.h
index 70bbe816accd..384e88ff5edf 100644
--- a/clang/include/clang/ASTMatchers/Dynamic/Parser.h
+++ b/clang/include/clang/ASTMatchers/Dynamic/Parser.h
@@ -234,6 +234,8 @@ class Parser {
bool parseBindID(std::string &BindID);
bool parseExpressionImpl(VariantValue *Value);
bool parseMatcherExpressionImpl(const TokenInfo &NameToken,
+ const TokenInfo &OpenToken,
+ llvm::Optional<MatcherCtor> Ctor,
VariantValue *Value);
bool parseIdentifierPrefixImpl(VariantValue *Value);
diff --git a/clang/lib/ASTMatchers/Dynamic/Parser.cpp b/clang/lib/ASTMatchers/Dynamic/Parser.cpp
index a0037549ca61..7715e2a17799 100644
--- a/clang/lib/ASTMatchers/Dynamic/Parser.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Parser.cpp
@@ -405,8 +405,18 @@ bool Parser::parseIdentifierPrefixImpl(VariantValue *Value) {
Tokenizer->SkipNewlines();
+ assert(NameToken.Kind == TokenInfo::TK_Ident);
+ TokenInfo OpenToken = Tokenizer->consumeNextToken();
+ if (OpenToken.Kind != TokenInfo::TK_OpenParen) {
+ Error->addError(OpenToken.Range, Error->ET_ParserNoOpenParen)
+ << OpenToken.Text;
+ return false;
+ }
+
+ llvm::Optional<MatcherCtor> Ctor = S->lookupMatcherCtor(NameToken.Text);
+
// Parse as a matcher expression.
- return parseMatcherExpressionImpl(NameToken, Value);
+ return parseMatcherExpressionImpl(NameToken, OpenToken, Ctor, Value);
}
bool Parser::parseBindID(std::string &BindID) {
@@ -451,17 +461,9 @@ bool Parser::parseBindID(std::string &BindID) {
/// If the input is malformed, or some argument has an error, it
/// returns \c false.
bool Parser::parseMatcherExpressionImpl(const TokenInfo &NameToken,
+ const TokenInfo &OpenToken,
+ llvm::Optional<MatcherCtor> Ctor,
VariantValue *Value) {
- assert(NameToken.Kind == TokenInfo::TK_Ident);
- const TokenInfo OpenToken = Tokenizer->consumeNextToken();
- if (OpenToken.Kind != TokenInfo::TK_OpenParen) {
- Error->addError(OpenToken.Range, Error->ET_ParserNoOpenParen)
- << OpenToken.Text;
- return false;
- }
-
- llvm::Optional<MatcherCtor> Ctor = S->lookupMatcherCtor(NameToken.Text);
-
if (!Ctor) {
Error->addError(NameToken.Range, Error->ET_RegistryMatcherNotFound)
<< NameToken.Text;
More information about the cfe-commits
mailing list