mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-14 11:39:35 +00:00
Adding isConst() ASTMatcher for CXXMethodDecl nodes
Updated reference and unit tests. llvm-svn: 181522
This commit is contained in:
parent
395a6d4878
commit
fc4f7dc0a6
@ -1524,6 +1524,19 @@ Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOpe
|
||||
</pre></td></tr>
|
||||
|
||||
|
||||
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isConst0')"><a name="isConst0Anchor">isConst</a></td><td></td></tr>
|
||||
<tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const.
|
||||
|
||||
Given
|
||||
struct A {
|
||||
void foo() const;
|
||||
void bar();
|
||||
};
|
||||
|
||||
methodDecl(isConst()) matches A::foo() but not A::bar()
|
||||
</pre></td></tr>
|
||||
|
||||
|
||||
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isOverride0')"><a name="isOverride0Anchor">isOverride</a></td><td></td></tr>
|
||||
<tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method.
|
||||
|
||||
|
@ -2542,6 +2542,21 @@ AST_MATCHER(CXXMethodDecl, isVirtual) {
|
||||
return Node.isVirtual();
|
||||
}
|
||||
|
||||
/// \brief Matches if the given method declaration is const.
|
||||
///
|
||||
/// Given
|
||||
/// \code
|
||||
/// struct A {
|
||||
/// void foo() const;
|
||||
/// void bar();
|
||||
/// };
|
||||
/// \endcode
|
||||
///
|
||||
/// methodDecl(isConst()) matches A::foo() but not A::bar()
|
||||
AST_MATCHER(CXXMethodDecl, isConst) {
|
||||
return Node.isConst();
|
||||
}
|
||||
|
||||
/// \brief Matches if the given method declaration overrides another method.
|
||||
///
|
||||
/// Given
|
||||
|
@ -1507,6 +1507,13 @@ TEST(Matcher, MatchesVirtualMethod) {
|
||||
methodDecl(isVirtual())));
|
||||
}
|
||||
|
||||
TEST(Matcher, MatchesConstMethod) {
|
||||
EXPECT_TRUE(matches("struct A { void foo() const; };",
|
||||
methodDecl(isConst())));
|
||||
EXPECT_TRUE(notMatches("struct A { void foo(); };",
|
||||
methodDecl(isConst())));
|
||||
}
|
||||
|
||||
TEST(Matcher, MatchesOverridingMethod) {
|
||||
EXPECT_TRUE(matches("class X { virtual int f(); }; "
|
||||
"class Y : public X { int f(); };",
|
||||
|
Loading…
Reference in New Issue
Block a user