OmniSciDB  471d68cefb
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{UdfCompiler.cpp}::UdfClangDriver Class Reference

Public Member Functions

clang::driver::Driver * getClangDriver ()
 
std::tuple< int, int, int > getClangVersion () const
 
 UdfClangDriver (const UdfClangDriver &)=delete
 

Static Public Member Functions

static UdfClangDriver init (const std::string &clang_path)
 

Protected Member Functions

 UdfClangDriver (const std::string &clang_path, llvm::IntrusiveRefCntPtr< clang::DiagnosticOptions > diag_options)
 

Private Attributes

llvm::IntrusiveRefCntPtr
< clang::DiagnosticOptions > 
diag_options
 
clang::DiagnosticConsumer * diag_client
 
llvm::IntrusiveRefCntPtr
< clang::DiagnosticIDs > 
diag_id
 
clang::DiagnosticsEngine diags
 
std::unique_ptr
< clang::DiagnosticConsumer > 
diag_client_owner
 
clang::driver::Driver the_driver
 
std::tuple< int, int, int > clang_version
 

Detailed Description

Definition at line 198 of file UdfCompiler.cpp.

Constructor & Destructor Documentation

anonymous_namespace{UdfCompiler.cpp}::UdfClangDriver::UdfClangDriver ( const UdfClangDriver )
delete
anonymous_namespace{UdfCompiler.cpp}::UdfClangDriver::UdfClangDriver ( const std::string &  clang_path,
llvm::IntrusiveRefCntPtr< clang::DiagnosticOptions >  diag_options 
)
protected

Definition at line 232 of file UdfCompiler.cpp.

References anonymous_namespace{UdfCompiler.cpp}::exec_output(), LOG, the_driver, and logger::WARNING.

236  , diag_client(new TextDiagnosticPrinter(llvm::errs(), diag_options.get()))
237  , diag_id(new clang::DiagnosticIDs())
239  , diag_client_owner(diags.takeClient())
240  , the_driver(clang_path.c_str(), llvm::sys::getDefaultTargetTriple(), diags)
241  , clang_version(get_clang_version(clang_path)) {
242  the_driver.CCPrintOptions = 0;
243 
244  if (!boost::filesystem::exists(the_driver.ResourceDir)) {
245  LOG(WARNING) << "clang driver ResourceDir=" << the_driver.ResourceDir
246  << " does not exist";
247  }
248 
249  // Replace clang driver resource directory with clang compiler
250  // resource directory
251  std::string clang_resource_dir = exec_output(clang_path + " -print-resource-dir");
252 
253  // trim clang_resource_dir string from right
254  clang_resource_dir.erase(
255  std::find_if(clang_resource_dir.rbegin(),
256  clang_resource_dir.rend(),
257  [](unsigned char ch) { return !std::isspace(ch); })
258  .base(),
259  clang_resource_dir.end());
260 
261  if (clang_resource_dir != the_driver.ResourceDir) {
262  LOG(WARNING) << "Resetting clang driver ResourceDir to " << clang_resource_dir
263  << " (was " << the_driver.ResourceDir << ")";
264  the_driver.ResourceDir = clang_resource_dir;
265  }
266 }
std::unique_ptr< clang::DiagnosticConsumer > diag_client_owner
#define LOG(tag)
Definition: Logger.h:203
llvm::IntrusiveRefCntPtr< clang::DiagnosticIDs > diag_id
std::string exec_output(std::string cmd)
std::tuple< int, int, int > get_clang_version(const std::string &clang_path)
llvm::IntrusiveRefCntPtr< clang::DiagnosticOptions > diag_options

+ Here is the call graph for this function:

Member Function Documentation

clang::driver::Driver* anonymous_namespace{UdfCompiler.cpp}::UdfClangDriver::getClangDriver ( )
inline

Definition at line 200 of file UdfCompiler.cpp.

200 { return &the_driver; }
std::tuple<int, int, int> anonymous_namespace{UdfCompiler.cpp}::UdfClangDriver::getClangVersion ( ) const
inline

Definition at line 201 of file UdfCompiler.cpp.

201 { return clang_version; }
UdfClangDriver anonymous_namespace{UdfCompiler.cpp}::UdfClangDriver::init ( const std::string &  clang_path)
static

Definition at line 221 of file UdfCompiler.cpp.

221  {
222  llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> diag_options =
223  new DiagnosticOptions();
224  if (!diag_options) {
225  throw std::runtime_error(
226  "Failed to initialize UDF compiler diagnostic options. Aborting UDF compiler "
227  "initialization. Is clang/clang++ installed?");
228  }
229  return UdfClangDriver(clang_path, diag_options);
230 }
llvm::IntrusiveRefCntPtr< clang::DiagnosticOptions > diag_options

Member Data Documentation

std::tuple<int, int, int> anonymous_namespace{UdfCompiler.cpp}::UdfClangDriver::clang_version
private

Definition at line 218 of file UdfCompiler.cpp.

clang::DiagnosticConsumer* anonymous_namespace{UdfCompiler.cpp}::UdfClangDriver::diag_client
private

Definition at line 213 of file UdfCompiler.cpp.

std::unique_ptr<clang::DiagnosticConsumer> anonymous_namespace{UdfCompiler.cpp}::UdfClangDriver::diag_client_owner
private

Definition at line 216 of file UdfCompiler.cpp.

llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> anonymous_namespace{UdfCompiler.cpp}::UdfClangDriver::diag_id
private

Definition at line 214 of file UdfCompiler.cpp.

llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> anonymous_namespace{UdfCompiler.cpp}::UdfClangDriver::diag_options
private

Definition at line 212 of file UdfCompiler.cpp.

clang::DiagnosticsEngine anonymous_namespace{UdfCompiler.cpp}::UdfClangDriver::diags
private

Definition at line 215 of file UdfCompiler.cpp.

clang::driver::Driver anonymous_namespace{UdfCompiler.cpp}::UdfClangDriver::the_driver
private

Definition at line 217 of file UdfCompiler.cpp.

Referenced by UdfClangDriver().


The documentation for this class was generated from the following file: