Hello,
I’m trying to write a matcher for a break in a for loop. I’m writing it that way:
breakStmt(
hasAncestor(anyOf(
forStmt().bind(breakForParent), // A break can happen in a for
doStmt(), // or in another loop
whileStmt(),
cxxForRangeStmt(),
switchStmt() // or in a switch
))
The goal is to match the closest ancestor that can have some meaning for a break statement, and detect if it is a for loop or another statement.
This looks to work fine when I’m in clang-query, but when I try to compile the code (with visual C++), I have the following error:
1>c:\dev\klangation\caip\src\analyzers\ccpp\klang\cppqr.cpp(149): error C2784: ‘clang::ast_matchers::internal::ArgumentAdaptingMatcherFunc<clang::ast_matchers::internal::HasAncestorMatcher,clang::ast_matchers::internal::TypeListclang::Decl,clang::NestedNameSpecifierLoc,clang::Stmt,clang::TypeLoc,clang::ast_matchers::internal::TypeListclang::Decl,clang::NestedNameSpecifierLoc,clang::Stmt,clang::TypeLoc>::Adaptor clang::ast_matchers::internal::ArgumentAdaptingMatcherFunc<clang::ast_matchers::internal::HasAncestorMatcher,clang::ast_matchers::internal::TypeListclang::Decl,clang::NestedNameSpecifierLoc,clang::Stmt,clang::TypeLoc,clang::ast_matchers::internal::TypeListclang::Decl,clang::NestedNameSpecifierLoc,clang::Stmt,clang::TypeLoc>::operator ()(const clang::ast_matchers::internal::Matcher &) const’ : could not deduce template argument for ‘const clang::ast_matchers::internal::Matcher &’ from ‘clang::ast_matchers::internal::VariadicOperatorMatcher<clang::ast_matchers::internal::Matcherclang::Stmt,ResultT,ResultT,ResultT,ResultT>’
1> with
1> [
1> ResultT=clang::ast_matchers::internal::BindableMatcherclang::Stmt
1> ]
1> c:\users\ljo.conan\data\llvm\3.9.0.5\yle\stable\package\2c0843cc59ff2d07e33c808b3398bc624e6b54e4\include\clang\astmatchers\astmatchersinternal.h(1054) : see declaration of ‘clang::ast_matchers::internal::ArgumentAdaptingMatcherFunc<clang::ast_matchers::internal::HasAncestorMatcher,clang::ast_matchers::internal::TypeListclang::Decl,clang::NestedNameSpecifierLoc,clang::Stmt,clang::TypeLoc,clang::ast_matchers::internal::TypeListclang::Decl,clang::NestedNameSpecifierLoc,clang::Stmt,clang::TypeLoc>::operator ()’
Is this something I’m not supposed to do, or is it more something like a bug in clang or in my compiler?
Thank you,