[cfe-dev] Problem to write a matcher for a break in a for loop
Loïc Joly via cfe-dev
cfe-dev at lists.llvm.org
Tue Jul 4 09:17:10 PDT 2017
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::TypeList<clang::Decl,clang::NestedNameSpecifierLoc,clang::Stmt,clang::TypeLoc>,clang::ast_matchers::internal::TypeList<clang::Decl,clang::NestedNameSpecifierLoc,clang::Stmt,clang::TypeLoc>>::Adaptor<T> clang::ast_matchers::internal::ArgumentAdaptingMatcherFunc<clang::ast_matchers::internal::HasAncestorMatcher,clang::ast_matchers::internal::TypeList<clang::Decl,clang::NestedNameSpecifierLoc,clang::Stmt,clang::TypeLoc>,clang::ast_matchers::internal::TypeList<clang::Decl,clang::NestedNameSpecifierLoc,clang::Stmt,clang::TypeLoc>>::operator ()(const clang::ast_matchers::internal::Matcher<From> &) const' : could not deduce template argument for 'const clang::ast_matchers::internal::Matcher<From> &' from 'clang::ast_matchers::internal::VariadicOperatorMatcher<clang::ast_matchers::internal::Matcher<clang::Stmt>,ResultT,ResultT,ResultT,ResultT>'
1> with
1> [
1> ResultT=clang::ast_matchers::internal::BindableMatcher<clang::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::TypeList<clang::Decl,clang::NestedNameSpecifierLoc,clang::Stmt,clang::TypeLoc>,clang::ast_matchers::internal::TypeList<clang::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,
---
Loïc Joly
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170704/0a6cae54/attachment.html>
More information about the cfe-dev
mailing list