OmniSciDB  a5dc49c757
 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 202 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 236 of file UdfCompiler.cpp.

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

240  , diag_client(new TextDiagnosticPrinter(llvm::errs(), diag_options.get()))
241  , diag_id(new clang::DiagnosticIDs())
243  , diag_client_owner(diags.takeClient())
244  , the_driver(clang_path.c_str(), llvm::sys::getDefaultTargetTriple(), diags)
245  , clang_version(get_clang_version(clang_path)) {
246  the_driver.CCPrintOptions = 0;
247 
248  if (!boost::filesystem::exists(the_driver.ResourceDir)) {
249  LOG(WARNING) << "clang driver ResourceDir=" << the_driver.ResourceDir
250  << " does not exist";
251  }
252 
253  // Replace clang driver resource directory with clang compiler
254  // resource directory
255  std::string clang_resource_dir = exec_output(clang_path + " -print-resource-dir");
256 
257  // trim clang_resource_dir string from right
258  clang_resource_dir.erase(
259  std::find_if(clang_resource_dir.rbegin(),
260  clang_resource_dir.rend(),
261  [](unsigned char ch) { return !std::isspace(ch); })
262  .base(),
263  clang_resource_dir.end());
264 
265  if (clang_resource_dir != the_driver.ResourceDir) {
266  LOG(WARNING) << "Resetting clang driver ResourceDir to " << clang_resource_dir
267  << " (was " << the_driver.ResourceDir << ")";
268  the_driver.ResourceDir = clang_resource_dir;
269  }
270 
271  // QE-720
272 #if LLVM_VERSION_MAJOR >= 10
273  diags.setSeverity(
274 #if LLVM_VERSION_MAJOR >= 14
275  clang::diag::warn_drv_new_cuda_version,
276 #else
277  clang::diag::warn_drv_unknown_cuda_version,
278 #endif
279  clang::diag::Severity::Ignored,
280  clang::SourceLocation());
281 #endif
282 
283  // Ignore `error: cannot find libdevice for sm_75` as irrelevant for
284  // astparser as well as for LLVM IR generation
285  diags.setSeverity(clang::diag::err_drv_no_cuda_libdevice,
286  clang::diag::Severity::Ignored,
287  clang::SourceLocation());
288 }
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 204 of file UdfCompiler.cpp.

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

Definition at line 205 of file UdfCompiler.cpp.

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

Definition at line 225 of file UdfCompiler.cpp.

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

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

Definition at line 217 of file UdfCompiler.cpp.

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

Definition at line 220 of file UdfCompiler.cpp.

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

Definition at line 218 of file UdfCompiler.cpp.

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

Definition at line 216 of file UdfCompiler.cpp.

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

Definition at line 219 of file UdfCompiler.cpp.

Referenced by UdfClangDriver().

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

Definition at line 221 of file UdfCompiler.cpp.

Referenced by UdfClangDriver().


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