forked from OSchip/llvm-project
[ASTMatchers] Don't assert-fail in specifiesTypeLoc().
The specifiesTypeLoc() matcher narrows a nestedNameSpecifier matcher based on a typeloc within the NNS. However, the matcher does not guard against NNS which are a namespace, and cause getTypeLoc to assert-fail. llvm-svn: 334929
This commit is contained in:
parent
068246886a
commit
8f7adcd7fb
|
@ -5536,7 +5536,8 @@ AST_MATCHER_P(NestedNameSpecifier, specifiesType,
|
|||
/// matches "A::"
|
||||
AST_MATCHER_P(NestedNameSpecifierLoc, specifiesTypeLoc,
|
||||
internal::Matcher<TypeLoc>, InnerMatcher) {
|
||||
return Node && InnerMatcher.matches(Node.getTypeLoc(), Finder, Builder);
|
||||
return Node && Node.getNestedNameSpecifier()->getAsType() &&
|
||||
InnerMatcher.matches(Node.getTypeLoc(), Finder, Builder);
|
||||
}
|
||||
|
||||
/// Matches on the prefix of a \c NestedNameSpecifier.
|
||||
|
|
|
@ -1450,6 +1450,10 @@ TEST(NNS, MatchesNestedNameSpecifierPrefixes) {
|
|||
"struct A { struct B { struct C {}; }; }; A::B::C c;",
|
||||
nestedNameSpecifierLoc(hasPrefix(
|
||||
specifiesTypeLoc(loc(qualType(asString("struct A"))))))));
|
||||
EXPECT_TRUE(matches(
|
||||
"namespace N { struct A { struct B { struct C {}; }; }; } N::A::B::C c;",
|
||||
nestedNameSpecifierLoc(hasPrefix(
|
||||
specifiesTypeLoc(loc(qualType(asString("struct N::A"))))))));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue