[PATCH] D27207: Adds hasUnqualifiedDesugaredType to allow matching through type sugar.

Ɓukasz Anforowicz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 29 14:26:01 PST 2016


lukasza added inline comments.


================
Comment at: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:253
+      matches("struct A {}; using B = A; B b;",
+              varDecl(hasType(hasUnqualifiedDesugaredType(recordType())))));
+}
----------------
# deep testing suggestion

If we do end up landing the implementation of hasUnqualifiedDesugaredType from this CL, then I think it might be good to tweak the test so that it verifies that the matching here is "deep" (i.e. that the matcher doesn't just strip a single level of sugar).

    matches("struct A {}; using B = A; using C = B; C c;", ...


# deep-vs-shallow-vs-everythingInBetween

At one point, when discussing the old implementation of hasDeclaration (before https://reviews.llvm.org/D27104) we were wondering whether it should match for all the cases below:

    std::string input = "struct A {}; using B = A; using C = B; using D = C; D d;";
    EXPECT_TRUE(matches(input,
        varDecl(...something-hasDeclaration-something...(typeAliasDecl(hasName("B"))))));
    EXPECT_TRUE(matches(input,
        varDecl(...something-hasDeclaration-something...(typeAliasDecl(hasName("C"))))));
    EXPECT_TRUE(matches(input,
        varDecl(...something-hasDeclaration-something...(typeAliasDecl(hasName("D"))))));

This is not something I want or care about myself, but I wanted to check if the above is something to think about.  For example - maybe exposing a singleStepDesugarsTo(...) matcher is better (because it can be used to build the hasUnqualifiedDesugaredType).

As I said - this is not very important to me (I only care about full desugaring all the way to a tag type), but it might be something to ponder before committing to the current implementation of hasUnqualifiedDesugaredType.


https://reviews.llvm.org/D27207





More information about the cfe-commits mailing list