tan  0.0.1
clang_frontend.cpp
1 #include "tan/tan.h"
2 #include "llvm_api/clang_frontend.h"
3 #include <llvm/Support/CommandLine.h>
4 #include <algorithm>
5 #include <iostream>
6 
8 
9 int clang_compile(vector<str> input_files, TanCompilation *config) {
10  vector<const char *> args;
11  size_t n_import = config->import_dirs.size();
12 
13  args.push_back("clang++");
14  args.push_back("-c");
15  // args.push_back("-v");
16  args.push_back("-fintegrated-cc1"); // don't create another process to run -cc1
17 
18  // includes
19  for (size_t i = 0; i < n_import; ++i) {
20  args.push_back("-I");
21  args.push_back(config->import_dirs[i].c_str());
22  }
23 
24  // opt level
25  str opt_level = opt_level_to_string(config->opt_level);
26  args.push_back(opt_level.c_str());
27 
28  // input files
29  std::for_each(input_files.begin(), input_files.end(), [&args](const auto &s) { args.push_back(s.c_str()); });
30 
31  std::for_each(input_files.begin(), input_files.end(), [](const auto &a) { std::cout << a << ' '; });
32  std::cout << ' ';
33 
34  return clang_main((int)args.size(), (char **)args.data());
35 }
Compilation configuration.
Definition: tan.h:42
vector< str > import_dirs
Library search paths.
Definition: tan.h:49
TanOptLevel opt_level
Type of compilation,.
Definition: tan.h:44