OmniSciDB  c1a53651b2
 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 199 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 233 of file UdfCompiler.cpp.

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

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

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

Definition at line 202 of file UdfCompiler.cpp.

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

Definition at line 222 of file UdfCompiler.cpp.

222  {
223  llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> diag_options =
224  new DiagnosticOptions();
225  if (!diag_options) {
226  throw std::runtime_error(
227  "Failed to initialize UDF compiler diagnostic options. Aborting UDF compiler "
228  "initialization. Is clang/clang++ installed?");
229  }
230  return UdfClangDriver(clang_path, diag_options);
231 }
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 219 of file UdfCompiler.cpp.

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

Definition at line 214 of file UdfCompiler.cpp.

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

Definition at line 217 of file UdfCompiler.cpp.

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

Definition at line 215 of file UdfCompiler.cpp.

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

Definition at line 213 of file UdfCompiler.cpp.

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

Definition at line 216 of file UdfCompiler.cpp.

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

Definition at line 218 of file UdfCompiler.cpp.

Referenced by UdfClangDriver().


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