r176441 - hasQualifer() matcher should return false if there's no qualifier
Edwin Vane
edwin.vane at intel.com
Mon Mar 4 09:51:00 PST 2013
Author: revane
Date: Mon Mar 4 11:51:00 2013
New Revision: 176441
URL: http://llvm.org/viewvc/llvm-project?rev=176441&view=rev
Log:
hasQualifer() matcher should return false if there's no qualifier
Instead of passing NULL on to sub-matcher, just return false. Updated tests and
regenerated docs.
Author: Tareq A Siraj <tareq.a.siraj at intel.com>
Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=176441&r1=176440&r2=176441&view=diff
==============================================================================
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Mon Mar 4 11:51:00 2013
@@ -2509,7 +2509,7 @@ Example matches true (matcher = hasCondi
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>></td><td class="name" onclick="toggle('hasQualifier0')"><a name="hasQualifier0Anchor">hasQualifier</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>> InnerMatcher</td></tr>
<tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier,
-matches InnerMatcher.
+matches InnerMatcher if the qualifier exists.
Given
namespace N {
Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=176441&r1=176440&r2=176441&view=diff
==============================================================================
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Mar 4 11:51:00 2013
@@ -2965,7 +2965,7 @@ AST_TYPE_MATCHER(RecordType, recordType)
AST_TYPE_MATCHER(ElaboratedType, elaboratedType);
/// \brief Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier,
-/// matches \c InnerMatcher.
+/// matches \c InnerMatcher if the qualifier exists.
///
/// Given
/// \code
@@ -2981,7 +2981,10 @@ AST_TYPE_MATCHER(ElaboratedType, elabora
/// matches the type of the variable declaration of \c d.
AST_MATCHER_P(ElaboratedType, hasQualifier,
internal::Matcher<NestedNameSpecifier>, InnerMatcher) {
- return InnerMatcher.matches(*Node.getQualifier(), Finder, Builder);
+ if (const NestedNameSpecifier *Qualifier = Node.getQualifier())
+ return InnerMatcher.matches(*Qualifier, Finder, Builder);
+
+ return false;
}
/// \brief Matches ElaboratedTypes whose named type matches \c InnerMatcher.
Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=176441&r1=176440&r2=176441&view=diff
==============================================================================
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Mon Mar 4 11:51:00 2013
@@ -3469,6 +3469,10 @@ TEST(ElaboratedTypeNarrowing, hasQualifi
"}"
"M::D d;",
elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N")))))));
+ EXPECT_TRUE(notMatches(
+ "struct D {"
+ "} d;",
+ elaboratedType(hasQualifier(nestedNameSpecifier()))));
}
TEST(ElaboratedTypeNarrowing, namesType) {
More information about the cfe-commits
mailing list