[PATCH] D54408: [ASTMatchers] Add matchers available through casting to derived
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 31 08:13:22 PST 2018
aaron.ballman added inline comments.
================
Comment at: lib/ASTMatchers/Dynamic/Registry.cpp:651
+llvm::Optional<std::pair<ASTNodeKind, std::string>>
+getNodeConstructorType(MatcherCtor targetCtor) {
+ const auto &ctors = RegistryData->nodeConstructors();
----------------
targetCtor -> TargetCtor
================
Comment at: lib/ASTMatchers/Dynamic/Registry.cpp:653
+ const auto &ctors = RegistryData->nodeConstructors();
+ auto it = llvm::find_if(
+ ctors, [targetCtor](const NodeConstructorMap::value_type &ctor) {
----------------
it -> It
================
Comment at: lib/ASTMatchers/Dynamic/Registry.cpp:654
+ auto it = llvm::find_if(
+ ctors, [targetCtor](const NodeConstructorMap::value_type &ctor) {
+ return ctor.second.second == targetCtor;
----------------
ctor -> Ctor
================
Comment at: lib/ASTMatchers/Dynamic/Registry.cpp:657-659
+ if (it == ctors.end()) {
+ return llvm::None;
+ }
----------------
Elide braces
================
Comment at: lib/ASTMatchers/Dynamic/Registry.cpp:683
+ if (Scope == ExactOnly) {
+ if (Matcher.isConvertibleTo(StaticType, &Specificity,
+ &LeastDerivedKind) &&
----------------
Can combine with the previous `if` statement, I believe.
================
Comment at: lib/ASTMatchers/Dynamic/Registry.cpp:689
+
+ auto TypeForMatcherOpt = getNodeConstructorType(&Matcher);
+ if (TypeForMatcherOpt &&
----------------
Don't use `auto` here please.
================
Comment at: lib/ASTMatchers/Dynamic/Registry.cpp:692
+ StaticType.isBaseOf(TypeForMatcherOpt->first)) {
+ auto Derived = getDerivedResults(TypeForMatcherOpt->first, Name);
+ Result.insert(Result.end(), Derived.begin(), Derived.end());
----------------
Don't use `auto` here please.
================
Comment at: lib/ASTMatchers/Dynamic/Registry.cpp:705
+getDerivedResults(ast_type_traits::ASTNodeKind StaticType, StringRef Name) {
+ auto NestedResult = getMatchingMatchersImpl(StaticType, ExactOnly);
+
----------------
Don't use `auto` here please.
================
Comment at: lib/ASTMatchers/Dynamic/Registry.cpp:711
+
+ for (const auto &item : NestedResult) {
+ Result.emplace_back((Name + "(" + item.MatcherString + ")").str());
----------------
item -> Item
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D54408/new/
https://reviews.llvm.org/D54408
More information about the cfe-commits
mailing list