mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-25 23:00:15 +00:00
Fixing a bug where hasType(decl()) would fail to match on C code involving structs or unions.
llvm-svn: 246860
This commit is contained in:
parent
23a4df27ab
commit
c129c69105
@ -668,16 +668,14 @@ private:
|
||||
return matchesDecl(Node.getDecl(), Finder, Builder);
|
||||
}
|
||||
|
||||
/// \brief Extracts the CXXRecordDecl or EnumDecl of a QualType and returns
|
||||
/// whether the inner matcher matches on it.
|
||||
/// \brief Extracts the TagDecl of a QualType and returns whether the inner
|
||||
/// matcher matches on it.
|
||||
bool matchesSpecialized(const QualType &Node, ASTMatchFinder *Finder,
|
||||
BoundNodesTreeBuilder *Builder) const {
|
||||
/// FIXME: Add other ways to convert...
|
||||
if (Node.isNull())
|
||||
return false;
|
||||
if (const EnumType *AsEnum = dyn_cast<EnumType>(Node.getTypePtr()))
|
||||
return matchesDecl(AsEnum->getDecl(), Finder, Builder);
|
||||
return matchesDecl(Node->getAsCXXRecordDecl(), Finder, Builder);
|
||||
return matchesDecl(Node->getAsTagDecl(), Finder, Builder);
|
||||
}
|
||||
|
||||
/// \brief Gets the TemplateDecl from a TemplateSpecializationType
|
||||
|
@ -919,6 +919,9 @@ TEST(TypeMatcher, MatchesClassType) {
|
||||
|
||||
EXPECT_TRUE(
|
||||
matches("class A { public: A *a; class B {}; };", TypeAHasClassB));
|
||||
|
||||
EXPECT_TRUE(matchesC("struct S {}; void f(void) { struct S s; }",
|
||||
varDecl(hasType(namedDecl(hasName("S"))))));
|
||||
}
|
||||
|
||||
TEST(Matcher, BindMatchedNodes) {
|
||||
|
@ -119,6 +119,12 @@ testing::AssertionResult matchesObjC(const std::string &Code,
|
||||
"", FileContentMappings(), "input.m");
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
testing::AssertionResult matchesC(const std::string &Code, const T &AMatcher) {
|
||||
return matchesConditionally(Code, AMatcher, true, "", FileContentMappings(),
|
||||
"input.c");
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
testing::AssertionResult notMatchesObjC(const std::string &Code,
|
||||
const T &AMatcher) {
|
||||
|
Loading…
Reference in New Issue
Block a user