From e1e18a41994a524b4b2dbe19abc934a1b1db1e27 Mon Sep 17 00:00:00 2001 From: doe300 Date: Wed, 21 Feb 2018 11:57:44 +0100 Subject: [PATCH] Adds support for OpenCL source-files --- src/compile_commands.cc | 8 ++++++++ src/source.cc | 3 +++ src/usages_clang.cc | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/compile_commands.cc b/src/compile_commands.cc index 89a40df..5f11afe 100644 --- a/src/compile_commands.cc +++ b/src/compile_commands.cc @@ -147,6 +147,14 @@ std::vector CompileCommands::get_arguments(const boost::filesystem: arguments.emplace_back("cuda_runtime.h"); } + if(extension==".cl") { + arguments.emplace_back("-xcl"); + arguments.emplace_back("-cl-std=CL2.0"); + arguments.emplace_back("-Xclang"); + arguments.emplace_back("-finclude-default-header"); + arguments.emplace_back("-Wno-gcc-compat"); + } + if(!build_path.empty()) { arguments.emplace_back("-working-directory"); arguments.emplace_back(build_path.string()); diff --git a/src/source.cc b/src/source.cc index b8e4914..740c893 100644 --- a/src/source.cc +++ b/src/source.cc @@ -70,6 +70,9 @@ Glib::RefPtr Source::guess_language(const boost::filesystem::path else language=language_manager->get_language("cpp"); } + else if(language->get_id()=="opencl") { + language = language_manager->get_language("cpp"); + } return language; } diff --git a/src/usages_clang.cc b/src/usages_clang.cc index e59bc9d..6b861b1 100644 --- a/src/usages_clang.cc +++ b/src/usages_clang.cc @@ -561,7 +561,8 @@ bool Usages::Clang::is_source(const boost::filesystem::path &path) { auto ext = path.extension(); if(ext == ".c" || // c sources ext == ".cpp" || ext == ".cxx" || ext == ".cc" || ext == ".C" || ext == ".c++" || // c++ sources - ext == ".cu") // CUDA sources + ext == ".cu" || // CUDA sources + ext == ".cl") // OpenCL sources return true; else return false;