Computer Laboratory

Tool.cpp File Reference
#include "AST.h"
#include "Debug.h"
#include "llvm/Support/CommandLine.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendActions.h"
#include "clang/Tooling/CompilationDatabase.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/Support/PrettyStackTrace.h"
#include <google/protobuf/text_format.h>
+ Include dependency graph for Tool.cpp:

Go to the source code of this file.

Functions

cl::opt< string > OutputFile ("o", cl::desc("<output file>"), cl::Required)
 
cl::list< string > SourcePaths (cl::Positional, cl::desc("<source0> [... <sourceN>]"), cl::OneOrMore)
 
int main (int argc, const char **argv)
 

Function Documentation

int main ( int  argc,
const char **  argv 
)

Definition at line 63 of file Tool.cpp.

References OutputFile(), tesla::panic(), and SourcePaths().

63  {
64  llvm::PrettyStackTraceProgram X(argc, argv);
65 
66  // Add a preprocessor definition to indicate we're doing TESLA parsing.
67  std::vector<const char*> args(argv, argv + argc);
68  args.push_back("-D");
69  args.push_back("__TESLA_ANALYSER__");
70 
71  // Change argc and argv to refer to the vector's memory.
72  // The CompilationDatabase will modify these, so we shouldn't pass in
73  // args.data() directly.
74  argc = (int) args.size();
75  assert(((size_t) argc) == args.size()); // check for overflow
76 
77  argv = args.data();
78 
79  OwningPtr<CompilationDatabase> Compilations(
80  FixedCompilationDatabase::loadFromCommandLine(argc, argv));
81 
82  if (!Compilations)
83  panic(
84  "Need compilation options, e.g. tesla-analyser foo.c -- -I ../include");
85 
86  cl::ParseCommandLineOptions(argc, argv);
87 
88  OwningPtr<TeslaActionFactory> Factory(new TeslaActionFactory(OutputFile));
89 
90  ClangTool Tool(*Compilations, SourcePaths);
91  return Tool.run(Factory.get());
92 }

+ Here is the call graph for this function:

cl::opt<string> OutputFile ( "o"  ,
cl::  desc"<output file>",
cl::Required   
)

Referenced by main().

+ Here is the caller graph for this function:

cl::list<string> SourcePaths ( cl::Positional  ,
cl::  desc"<source0> [... <sourceN>]",
cl::OneOrMore   
)

Referenced by main().

+ Here is the caller graph for this function: