Computer Laboratory

cat.cpp File Reference
#include "Automaton.h"
#include "Manifest.h"
#include "tesla.pb.h"
#include <google/protobuf/text_format.h>
#include <llvm/IR/Function.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/Module.h>
#include <llvm/Support/CommandLine.h>
#include <llvm/Support/raw_ostream.h>
#include <llvm/Pass.h>
+ Include dependency graph for cat.cpp:

Go to the source code of this file.

Functions

cl::list< string > InputFiles (cl::desc("<input files>"), cl::Positional, cl::OneOrMore)
 
cl::opt< string > OutputFile ("o", cl::desc("<output file>"), cl::init("-"))
 
int main (int argc, char *argv[])
 

Function Documentation

cl::list<string> InputFiles ( cl::  desc"<input files>",
cl::Positional  ,
cl::OneOrMore   
)

Referenced by main().

+ Here is the caller graph for this function:

int main ( int  argc,
char *  argv[] 
)

Definition at line 60 of file cat.cpp.

References InputFiles(), and OutputFile().

60  {
61  cl::ParseCommandLineOptions(argc, argv);
62 
63  auto& err = llvm::errs();
64 
65  ManifestFile Result;
66 
67  for (auto& Filename : InputFiles) {
68  OwningPtr<Manifest> Manifest(Manifest::load(llvm::errs(),
69  Automaton::Unlinked,
70  Filename));
71  if (!Manifest) {
72  err << "Unable to read manifest '" << Filename << "'\n";
73  return 1;
74  }
75 
76  for (auto i : Manifest->AllAutomata())
77  *Result.add_automaton() = *i.second;
78 
79  for (auto i : Manifest->RootAutomata())
80  *Result.add_root() = *i;
81  }
82 
83  string ProtobufText;
84  google::protobuf::TextFormat::PrintToString(Result, &ProtobufText);
85 
86  bool UseFile = (OutputFile != "-");
87  OwningPtr<raw_fd_ostream> outfile;
88 
89  if (UseFile) {
90  string OutErrorInfo;
91  outfile.reset(new raw_fd_ostream(OutputFile.c_str(), OutErrorInfo));
92  }
93  raw_ostream& out = UseFile ? *outfile : llvm::outs();
94  out << ProtobufText;
95 
96  google::protobuf::ShutdownProtobufLibrary();
97 
98  return 0;
99 }

+ Here is the call graph for this function:

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