From 31ebbe40a08ac48ceb4df4f8d9008c038d9ccd94 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 29 Sep 2016 10:20:24 +0200 Subject: [PATCH] Cycles: Improve OpenCL line information handling Previously it was falling back to just a path after #include statement was finished. Now we fall back to a proper current file name after dealing with the preprocessor statement. --- intern/cycles/util/util_path.cpp | 10 ++++++---- intern/cycles/util/util_path.h | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/intern/cycles/util/util_path.cpp b/intern/cycles/util/util_path.cpp index 9ec67cb0330..62ef8fc0b48 100644 --- a/intern/cycles/util/util_path.cpp +++ b/intern/cycles/util/util_path.cpp @@ -778,7 +778,9 @@ static string line_directive(const string& path, int line) } -string path_source_replace_includes(const string& source, const string& path) +string path_source_replace_includes(const string& source, + const string& path, + const string& source_filename) { /* Our own little c preprocessor that replaces #includes with the file * contents, to work around issue of opencl drivers not supporting @@ -807,12 +809,12 @@ string path_source_replace_includes(const string& source, const string& path) * and avoids having list of include directories.x */ text = path_source_replace_includes( - text, path_dirname(filepath)); - text = path_source_replace_includes(text, path); + text, path_dirname(filepath), filename); + text = path_source_replace_includes(text, path, filename); /* Use line directives for better error messages. */ line = line_directive(filepath, 1) + token.replace(0, n_end + 1, "\n" + text + "\n") - + line_directive(path, i); + + line_directive(path_join(path, source_filename), i); } } } diff --git a/intern/cycles/util/util_path.h b/intern/cycles/util/util_path.h index 4a89d87cbc6..70dbb5ae403 100644 --- a/intern/cycles/util/util_path.h +++ b/intern/cycles/util/util_path.h @@ -66,7 +66,9 @@ bool path_read_text(const string& path, string& text); bool path_remove(const string& path); /* source code utility */ -string path_source_replace_includes(const string& source, const string& path); +string path_source_replace_includes(const string& source, + const string& path, + const string& source_filename=""); /* cache utility */ void path_cache_clear_except(const string& name, const set& except);