本文整理汇总了C++中MatchFinder类的典型用法代码示例。如果您正苦于以下问题:C++ MatchFinder类的具体用法?C++ MatchFinder怎么用?C++ MatchFinder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MatchFinder类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST
TEST(StmtDepthMetricTest, ObjCTryCatchFinally)
{
StmtDepthCallback depthCallback(4);
MatchFinder finder;
finder.addMatcher(functionDeclMatcher, &depthCallback);
testMatcherOnObjCCode(finder, "void m() { @try { int c = 3; } @catch (id ex) { int a = 1; } @finally { int b = 2; {{}}} }");
}
示例2: TEST
TEST(NPathComplexityMetricTest, NestedIfElseStmt)
{
NPathCallback nPathCallback(4);
MatchFinder finder;
finder.addMatcher(functionDeclMatcher, &nPathCallback);
testMatcherOnCode(finder, "void mthd() { if (1) { if (1) {} else {} } else { if (1) {} else {} } }");
}
示例3: TEST
TEST(CyclomaticComplexityMetricTest, EmptyFunction)
{
CyclomaticCallback ccnCallback(1);
MatchFinder finder;
finder.addMatcher(functionDeclMatcher, &ccnCallback);
testMatcherOnCode(finder, "void m() {}");
}
示例4: main
/*
* Main @TestNeed
*/
int main(int argc, const char **argv){
CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
ClangTool Tool(OptionsParser.getCompilations(),
OptionsParser.getSourcePathList());
ReturnChecker rc;
MatchFinder finder;
finder.addMatcher(FuncStmtMatcher, &rc);
Tool.run(newFrontendActionFactory(&finder));
return 0;
}
示例5: main
int main(int argc, const char **argv) {
CommonOptionsParser op(argc, argv, ToolingSampleCategory);
ClangTool Tool(op.getCompilations(), op.getSourcePathList());
CallPrinter Printer;
MatchFinder Finder;
Finder.addMatcher(CallMatcher, &Printer);
return Tool.run(newFrontendActionFactory(&Finder).get());
}
示例6: main
int main(int argc, const char** argv) {
CommonOptionsParser OptionsParser(argc, argv, ToolCategory);
ClangTool Tool(OptionsParser.getCompilations(),
OptionsParser.getSourcePathList());
ComparisonPrinter Printer;
MatchFinder Finder;
Finder.addMatcher(ComparisonMatcher, &Printer);
return Tool.run(newFrontendActionFactory(&Finder).get());
}
示例7: functionDecl
clang::ast_matchers::MatchFinder MatchContainer::getMatcher()
{
MatchFinder finder;
// Some debug bind slot
onStmtMatch.emplace("dump", [](Stmt const * d) {d->dump(); });
onTypeMatch.emplace("dump", [](Type const * d) {d->dump(); });
onDeclMatch.emplace("dump", [](Decl const * d) {d->dump(); });
onDeclMatch.emplace("print_name", [](Decl const * d)
{
if(auto* nd = dyn_cast<NamedDecl>(d))
llvm::errs() << nd->getNameAsString() << "\n";
});
//free operators
DeclarationMatcher out_stream_op =
functionDecl(
unless(hasDeclContext(recordDecl())),
matchesName("operator[\\+-\\*\\^\\[\\(\\!\\&\\|\\~\\=\\/\\%\\<\\>]")
).bind("free_operator");
finder.addMatcher(out_stream_op, this);
declPrinters.emplace("free_operator", [](DPrinter&, Decl*) {});
onDeclMatch.emplace("free_operator", [this](Decl const * d)
{
if(auto* funcDecl = dyn_cast<FunctionDecl>(d))
{
auto getParamTypeName = [](ParmVarDecl const * typeParam)
{
QualType canType = typeParam->getType().getCanonicalType()
.getUnqualifiedType().getNonReferenceType();
canType.removeLocalConst();
return canType.getAsString();
};
if(funcDecl->getNumParams() > 0)
{
std::string const left_name = getParamTypeName(funcDecl->getParamDecl(0));
freeOperator.emplace(left_name, funcDecl);
if(funcDecl->getNumParams() > 1)
{
std::string const right_name = getParamTypeName(funcDecl->getParamDecl(1));
if(right_name != left_name)
freeOperatorRight.emplace(right_name, funcDecl);
}
}
}
});
for(auto printerRegisterers : CustomPrinters::getInstance().getRegisterers())
printerRegisterers(*this, finder);
return finder;
}
示例8: main
/*
* Main @TestNeed
*/
int main(int argc, const char **argv){
CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
//Create an ClangTool instance to run a FrontendAction over a set of files
ClangTool Tool(OptionsParser.getCompilations(),
OptionsParser.getSourcePathList());
//tool::MyFactory Factory;
GlobalVarChecker gvc;
MatchFinder finder;
finder.addMatcher(VarDeclMatcher, &gvc);
Tool.run(newFrontendActionFactory(&finder));
return 0;
}
示例9: main
int main(int argc, const char **argv)
{
CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
ClangTool Tool(OptionsParser.getCompilations(),
OptionsParser.getSourcePathList());
//tooling::MyFactory Factory;
ParmPrinter Printer;
MatchFinder Finder;
Finder.addMatcher(funcMatcher, &Printer);
Tool.run(newFrontendActionFactory(&Finder));
return 0;
}