diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-09-29 11:20:24 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-09-29 11:20:24 +0300 |
commit | 31ebbe40a08ac48ceb4df4f8d9008c038d9ccd94 (patch) | |
tree | 321bdd5e956e5c362cd3d432ae2426a6a9724a63 /intern | |
parent | 94c919349b66ef18f8cc5d3263f73222752cac93 (diff) |
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.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/util/util_path.cpp | 10 | ||||
-rw-r--r-- | 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<string>& except); |