当前位置: 首页>>代码示例>>C++>>正文


C++ MatchFinder类代码示例

本文整理汇总了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; {{}}} }");
}
开发者ID:poornigga,项目名称:oclint,代码行数:8,代码来源:StmtDepthMetricTest.cpp

示例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 {} } }");
}
开发者ID:poornigga,项目名称:oclint,代码行数:8,代码来源:NPathComplexityMetricTest.cpp

示例3: TEST

TEST(CyclomaticComplexityMetricTest, EmptyFunction)
{
    CyclomaticCallback ccnCallback(1);
    MatchFinder finder;
    finder.addMatcher(functionDeclMatcher, &ccnCallback);

    testMatcherOnCode(finder, "void m() {}");
}
开发者ID:poornigga,项目名称:oclint,代码行数:8,代码来源:CyclomaticComplexityMetricTest.cpp

示例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;
}
开发者ID:KrishnaPG,项目名称:CodingAssistant-Clang,代码行数:13,代码来源:MatchReturn.cpp

示例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());

}
开发者ID:bencouturier,项目名称:clang-tests,代码行数:11,代码来源:call_matcher.cpp

示例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());
}
开发者ID:jlucangelio,项目名称:clang-tools,代码行数:11,代码来源:IntegerPromotion.cpp

示例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;
}
开发者ID:lhamot,项目名称:CPP2D,代码行数:53,代码来源:MatchContainer.cpp

示例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;
}
开发者ID:KrishnaPG,项目名称:CodingAssistant-Clang,代码行数:15,代码来源:CheckGlobalVar.cpp

示例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;
}
开发者ID:KrishnaPG,项目名称:CodingAssistant-Clang,代码行数:13,代码来源:MatchRefParm.cpp


注:本文中的MatchFinder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。