Update dependencies (#396)
* Clang requires that all errors are checked (even success)
* opencl header was split into two
* added a new baked header for the base header
* Fixed a compiler warning in replaceBarriers()
diff --git a/lib/Compiler.cpp b/lib/Compiler.cpp
index 4dc6a97..72da53a 100644
--- a/lib/Compiler.cpp
+++ b/lib/Compiler.cpp
@@ -483,8 +483,6 @@
// Disable generation of lifetime intrinsic.
instance.getCodeGenOpts().DisableLifetimeMarkers = true;
instance.getFrontendOpts().Inputs.push_back(kernelFile);
- // instance.getPreprocessorOpts().addRemappedFile(
- // overiddenInputFilename, errorOrInputFile.get().release());
instance.getPreprocessorOpts().addRemappedFile(overiddenInputFilename,
memory_buffer.release());
@@ -507,6 +505,12 @@
instance.getPreprocessorOpts().Includes.push_back("openclc.h");
+ std::unique_ptr<llvm::MemoryBuffer> openCLBaseBuiltinMemoryBuffer(
+ new OpenCLBuiltinMemoryBuffer(opencl_base_builtins_header_data,
+ opencl_base_builtins_header_size - 1));
+
+ instance.getPreprocessorOpts().Includes.push_back("opencl-c-base.h");
+
// Add the VULKAN macro.
instance.getPreprocessorOpts().addMacroDef("VULKAN=100");
@@ -533,6 +537,13 @@
instance.getSourceManager().overrideFileContents(
entry, std::move(openCLBuiltinMemoryBuffer));
+ auto base_entry = instance.getFileManager().getVirtualFile(
+ includePrefix + "opencl-c-base.h",
+ openCLBaseBuiltinMemoryBuffer->getBufferSize(), 0);
+
+ instance.getSourceManager().overrideFileContents(
+ base_entry, std::move(openCLBaseBuiltinMemoryBuffer));
+
return 0;
}
@@ -783,7 +794,7 @@
return -1;
}
- action.Execute();
+ auto result = action.Execute();
action.EndSourceFile();
clang::DiagnosticConsumer *const consumer =
@@ -795,7 +806,7 @@
if ((num_errors > 0) || (num_warnings > 0)) {
llvm::errs() << log;
}
- if (num_errors > 0) {
+ if (result || num_errors > 0) {
return -1;
}
@@ -918,7 +929,7 @@
return -1;
}
- action.Execute();
+ auto result = action.Execute();
action.EndSourceFile();
clang::DiagnosticConsumer *const consumer =
@@ -926,7 +937,7 @@
consumer->finish();
auto num_errors = consumer->getNumErrors();
- if (num_errors > 0) {
+ if (result || num_errors > 0) {
llvm::errs() << log << "\n";
return -1;
}