The new unit tests demonstrates that without unwrapping ElaboratedType
and TemplateSpecializationType we end up with a somewhat absurd
situation where a ParmVarDecl's type doesn't have *any* associated
declaration.
Fixes PR30331.
Differential D24361
hasDeclaration(qualType(...)) matcher should unwrap ElaboratedType and TemplateSpecializationType Authored by lukasza on Sep 8 2016, 12:15 PM.
Details
Diff Detail Event TimelineComment Actions I am assuming that the expectation I expressed in the unit test is a valid/correct expectation. I guess this is the first thing to validate/ack in the review :-)
Comment Actions Richard, could you please take a look?
Comment Actions
Comment Actions Reverted changes in the patch that are not related to the issue of hasDeclaration not matching *anything* in some cases. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There is also a question whether I should not only start supporting not only qualType(hasDeclaration(...)) when qualType wraps an ElaboratedType node, but also start supporting elaboratedType(hasDeclaration(...)).
Snippets of a patch that could achieve this (but then again - I am not sure if this is desirable and/or necessary):
+++ include/clang/ASTMatchers/ASTMatchersInternal.h (working copy) ... + /// \brief Gets the QualType from ElaboratedType + /// and returns whether the inner matches on it. + bool matchesSpecialized(const ElaboratedType &Node, + ASTMatchFinder *Finder, + BoundNodesTreeBuilder *Builder) const { + return matchesSpecialized(Node.getNamedType(), Finder, Builder); + } + ... /// \brief All types that are supported by HasDeclarationMatcher above. -typedef TypeList<CallExpr, CXXConstructExpr, DeclRefExpr, EnumType, - InjectedClassNameType, LabelStmt, AddrLabelExpr, MemberExpr, - QualType, RecordType, TagType, TemplateSpecializationType, - TemplateTypeParmType, TypedefType, +typedef TypeList<AutoType, CallExpr, CXXConstructExpr, DeclRefExpr, ElaboratedType, + EnumType, InjectedClassNameType, LabelStmt, AddrLabelExpr, + MemberExpr, QualType, RecordType, TagType, + TemplateSpecializationType, TemplateTypeParmType, TypedefType, UnresolvedUsingType> HasDeclarationSupportedTypes;