"should not see dependent types here" in AST traversal

Hi.
I am programming a clang tool, that traverses the ASTs for multiple files generating info on memberusages.
Naturally when parsing an AST the visitors traverse through each included h/hpp file even if it is not a user made file but something like glfw.
Since eventually I want to make sourcefile transformations, I want to exclude those kinds of files.
Therefore I use an AST matcher file_match:

isExpansionInFileMatching(“foo.c|bar.c|include/*”)

I use it like this:

cxxRecordDecl(file_match, hasDefinition(), unless(isUnion())).bind(coop_class_s);

This used to work as intended until I tried to parse a bigger existing project - not a mere test file.
Not only will my matchers match on ‘non-user’ files like: type_traits, I also get an error message:

…/llvm/tools/clang/include/clang/AST/TypeNodes.def:87: clang::TypeInfo clang::ASTContext::getTypeInfoImpl(const clang::Type*) const: Assertion `!T->isDependentType() && “should not see dependent types here”’

TypeNodes.def:87:
NON_CANONICAL_UNLESS_DEPENDENT_TYPE(TypeOfExpr, Type)

I don’t have an understanding of what those def files are and I also can’t see what this assertion type is supposed to mean.
And I have no idea how my matcher seems to be ignored.

Could someone help?

On 23/11/2018 16:34, Julian Mueller via cfe-dev wrote:> Hi.
> I am programming a clang tool, that traverses the ASTs for multiple
> files generating info on memberusages.
> Naturally when parsing an AST the visitors traverse through each
> included h/hpp file even if it is not a user made file but something
> like glfw.
> Since eventually I want to make sourcefile transformations, I want to
> exclude those kinds of files.
> Therefore I use an AST matcher /file_match/:
>
> isExpansionInFileMatching("foo.c|bar.c|include/*")

Surely most of the headers used in your translation units are in directories matching "include/*" (even vector etc is in /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/bits/stl_bvector.h).

I suggest using a different pattern, such as the name of the root directory of your project.

Also, you might be able to use the --header-filter command line parameter of clang-tidy to include only particular files.

> I also get an error message:
>
> .../llvm/tools/clang/include/clang/AST/TypeNodes.def:87: clang::TypeInfo
> clang::ASTContext::getTypeInfoImpl(const clang::Type*) const: Assertion
> `!T->isDependentType() && "should not see dependent types here"'
>
> TypeNodes.def:87:
> NON_CANONICAL_UNLESS_DEPENDENT_TYPE(TypeOfExpr, Type)

I suggest creating an http://sscce.org/ for this.

Thanks,

Stephen.