The purpose of this function is to allow clients of the dynamic AST matcher
to enumerate each binding.
Differential Revision: http://llvm-reviews.chandlerc.com/D2095
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194112
91177308-0d34-0410-b5e6-
96231b3b80d8
}
/// @}
+ /// \brief Type of mapping from binding identifiers to bound nodes. This type
+ /// is an associative container with a key type of \c std::string and a value
+ /// type of \c clang::ast_type_traits::DynTypedNode
+ typedef internal::BoundNodesMap::IDToNodeMap IDToNodeMap;
+
+ /// \brief Retrieve mapping from binding identifiers to bound nodes.
+ const IDToNodeMap &getMap() const {
+ return MyBoundNodes.getMap();
+ }
+
private:
/// \brief Create BoundNodes from a pre-filled map of bindings.
BoundNodes(internal::BoundNodesMap &MyBoundNodes)
return NodeMap < Other.NodeMap;
}
-private:
/// \brief A map from IDs to the bound nodes.
///
/// Note that we're using std::map here, as for memoization:
/// - we need an assignment operator
typedef std::map<std::string, ast_type_traits::DynTypedNode> IDToNodeMap;
+ const IDToNodeMap &getMap() const {
+ return NodeMap;
+ }
+
+private:
IDToNodeMap NodeMap;
};
}
virtual bool run(const BoundNodes *Nodes) {
+ const BoundNodes::IDToNodeMap &M = Nodes->getMap();
if (Nodes->getNodeAs<T>(Id)) {
++Count;
if (const NamedDecl *Named = Nodes->getNodeAs<NamedDecl>(Id)) {
llvm::raw_string_ostream OS(Name);
NNS->print(OS, PrintingPolicy(LangOptions()));
}
+ BoundNodes::IDToNodeMap::const_iterator I = M.find(Id);
+ EXPECT_NE(M.end(), I);
+ if (I != M.end())
+ EXPECT_EQ(Nodes->getNodeAs<T>(Id), I->second.get<T>());
return true;
}
+ EXPECT_TRUE(M.count(Id) == 0 || M.find(Id)->second.template get<T>() == 0);
return false;
}