This provides better support for TypeLocs to allow TypeLoc-related
matchers to feature stricter typing and to avoid relying on the dynamic
casting of TypeLocs in matchers.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Looks good! Please add a test to be sure it compiles/works correctly. Thanks!
clang/include/clang/AST/ASTTypeTraits.h | ||
---|---|---|
57 | Here and below -- looks like clang format did this? I'd recommend you revert this line and others like it -- only change formatting on lines you've otherwise edited. |
clang/include/clang/AST/ASTTypeTraits.h | ||
---|---|---|
476 | The create/get don't seem to match. If we instead construct a T in create(), we should be able to read it as a BaseT* (assuming is_pointer_interconvertible_base_of<BaseT, T> is true) |
clang/include/clang/AST/ASTTypeTraits.h | ||
---|---|---|
476 | Done, constructing a T instead of a BaseT seems to work! |
clang/unittests/AST/ASTTypeTraitsTest.cpp | ||
---|---|---|
207 | let's assert that matches.size() == 1 and then just use nodes[0]. |
clang/unittests/AST/ASTTypeTraitsTest.cpp | ||
---|---|---|
212 | These two EXPECTs are meant to ensure that the overloaded equality and less-than operators do function correctly when handling nodes of the TypeLoc family. In both cases, there is behavior specifically for these nodes, and I've made minor updates to both (changing isSame to isBaseOf). Additionally, this may give a little more confidence that template specialization functioned correctly. I will note that the QualType test performs a similar set of checks, presumably for similar reasoning. |
clang/unittests/AST/ASTTypeTraitsTest.cpp | ||
---|---|---|
234 | Maybe also check EXPECT_EQ(&tl, &ptl); ? |
Here and below -- looks like clang format did this? I'd recommend you revert this line and others like it -- only change formatting on lines you've otherwise edited.