示例#1
0
TEST(newFrontendActionFactory, CreatesFrontendActionFactoryFromFactoryType) {
  IndependentFrontendActionCreator Creator;
  std::unique_ptr<FrontendActionFactory> Factory(
      newFrontendActionFactory(&Creator));
  std::unique_ptr<FrontendAction> Action(Factory->create());
  EXPECT_TRUE(Action.get() != nullptr);
}
示例#2
0
TEST(newFrontendActionFactory, CreatesFrontendActionFactoryFromFactoryType) {
  IndependentFrontendActionCreator Creator;
  llvm::OwningPtr<FrontendActionFactory> Factory(
    newFrontendActionFactory(&Creator));
  llvm::OwningPtr<FrontendAction> Action(Factory->create());
  EXPECT_TRUE(Action.get() != NULL);
}
/*
 * 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;
}
/*
 * 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;
}
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;
}
//Main @TestNeed
int main(int argc, const char **argv){
	CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
	ClangTool Tool(OptionsParser.getCompilations(),
					OptionsParser.getSourcePathList());
	CallExprChecker cec;
	MatchFinder finder;
	finder.addMatcher(mallocMatcher, &cec);
	finder.addMatcher(freeMatcher, &cec);
	finder.addMatcher(reallocMatcher, &cec);
	finder.addMatcher(memcpyAryMatcher, &cec);
	finder.addMatcher(memcpyPtrMatcher, &cec);
	finder.addMatcher(memcmpAryMatcher, &cec);
	finder.addMatcher(memcmpPtrMatcher, &cec);
	Tool.run(newFrontendActionFactory(&finder));
	return 0;
} 
int main(int argc, const char **argv)
{
    //CommonOptionsParser constructor will parse arguments and create a
    //CompilationDatabase. In case of error it will terminate the program.
    CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
    //once we have a CompilationDatabase, we can create a ClangTool and run our
    //FrontendAction over some code.
    ClangTool Tool(OptionsParser.getCompilations(),
                   OptionsParser.getSourcePathList());
    //tooling::MyFactory Factory;
    FunctionPrinter Printer;
    MatchFinder Finder;
    Finder.addMatcher(funcMatcher, &Printer);

    Tool.run(newFrontendActionFactory(&Finder));
    return 0;
}
示例#8
0
TEST(newFrontendActionFactory, InjectsSourceFileCallbacks) {
  VerifyEndCallback EndCallback;

  FixedCompilationDatabase Compilations("/", std::vector<std::string>());
  std::vector<std::string> Sources;
  Sources.push_back("/a.cc");
  Sources.push_back("/b.cc");
  ClangTool Tool(Compilations, Sources);

  Tool.mapVirtualFile("/a.cc", "void a() {}");
  Tool.mapVirtualFile("/b.cc", "void b() {}");

  std::unique_ptr<FrontendActionFactory> Action(
      newFrontendActionFactory(&EndCallback, &EndCallback));
  Tool.run(Action.get());

  EXPECT_TRUE(EndCallback.Matched);
  EXPECT_EQ(2u, EndCallback.BeginCalled);
  EXPECT_EQ(2u, EndCallback.EndCalled);
}
示例#9
0
文件: test_pr61445.cpp 项目: emsr/tr2
  void
  newFrontendActionFactory(FactoryT *, int *)
  {
    class A
    {
      void
      m_fn1()
      {
        B(0, 0);
      }

      class B
      {
      public:
        B(FactoryT, int);
      };
    };

    newFrontendActionFactory(&a);
  }
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());
	
	//tooling::MyFactory Factory;
	FloatChecker fc;
	IntChecker ic;
	StringChecker sc;
	MatchFinder finder;
	
	finder.addMatcher(FloatLiteralMatcher , &fc);
	finder.addMatcher(IntLiteralMatcher , &ic);
	finder.addMatcher(StringLiteralMatcher , &sc);
	Tool.run(newFrontendActionFactory(&finder));

	llvm::outs() << "Avoid magic number : " << count << "\n";
	return 0;
}
示例#11
0
void InheritanceBuilder::process(const llvm::Twine &Code) {
  MatchFinder MF;
  tackOnto(MF);
  runToolOnCode(newFrontendActionFactory(&MF)->create(), Code);
}