diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2019-11-15 09:23:39 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2019-11-15 09:23:39 +0200 |
commit | 96c59ff30a2dbe2cc441024c81caaf79823441ac (patch) | |
tree | 3e6108d8bb34627ff1947e6455bded3ca4af2335 /libbuild2/types.hxx | |
parent | 11f990b55294a9eb8d5d4f29fa9a277702ca72b9 (diff) |
Fix bug in cc::parser location storage
Diffstat (limited to 'libbuild2/types.hxx')
-rw-r--r-- | libbuild2/types.hxx | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/libbuild2/types.hxx b/libbuild2/types.hxx index bedcf1a..8566c50 100644 --- a/libbuild2/types.hxx +++ b/libbuild2/types.hxx @@ -311,12 +311,12 @@ namespace build2 // Diagnostics location. // + // Note that location maintains a shallow reference to path. Zero lines or + // columns are not printed. + // class location { public: - // Note that location maintains a shallow reference to path. Zero lines - // or columns are not printed. - // explicit location (const path* f = nullptr, uint64_t l = 0, uint64_t c = 0) : file (f), line (l), column (c) {} @@ -333,6 +333,27 @@ namespace build2 uint64_t column; }; + // Similar (and implicit-convertible) to the above but stores a copy of the + // path. + // + class location_value: public location + { + public: + location_value () = default; + + explicit + location_value (const location& l) + : location (path_name (file_value, l.file.name), l.line, l.column), + file_value (l.file.path != nullptr ? *l.file.path : path ()) {} + + explicit + location_value (location&& l) + : location (path_name (file_value, move (l.file.name)), l.line, l.column), + file_value (l.file.path != nullptr ? *l.file.path : path ()) {} + + path file_value; + }; + // See context. // enum class run_phase {load, match, execute}; |