forked from OSchip/llvm-project
Introduce BoundNodes::getMap.
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 llvm-svn: 194112
This commit is contained in:
parent
5dd4916f63
commit
093a729e03
|
@ -86,6 +86,16 @@ public:
|
|||
}
|
||||
/// @}
|
||||
|
||||
/// \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)
|
||||
|
|
|
@ -98,7 +98,6 @@ public:
|
|||
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:
|
||||
|
@ -106,6 +105,11 @@ private:
|
|||
/// - we need an assignment operator
|
||||
typedef std::map<std::string, ast_type_traits::DynTypedNode> IDToNodeMap;
|
||||
|
||||
const IDToNodeMap &getMap() const {
|
||||
return NodeMap;
|
||||
}
|
||||
|
||||
private:
|
||||
IDToNodeMap NodeMap;
|
||||
};
|
||||
|
||||
|
|
|
@ -659,6 +659,7 @@ public:
|
|||
}
|
||||
|
||||
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)) {
|
||||
|
@ -668,8 +669,13 @@ public:
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue