File tree 2 files changed +16
-0
lines changed 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,19 @@ void source_locationt::merge(const source_locationt &from)
71
71
}
72
72
}
73
73
74
+ // / Get a path to the file, including working directory.
75
+ // / \return Full path unless the file name is empty or refers
76
+ // / to a built-in, in which case {} is returned.
77
+ optionalt<std::string> source_locationt::full_path () const
78
+ {
79
+ const auto file = id2string (get_file ());
80
+
81
+ if (file.empty () || is_built_in (file))
82
+ return {};
83
+
84
+ return concat_dir_file (id2string (get_working_directory ()), file);
85
+ }
86
+
74
87
std::ostream &operator << (
75
88
std::ostream &out,
76
89
const source_locationt &source_location)
Original file line number Diff line number Diff line change 12
12
13
13
#include " invariant.h"
14
14
#include " irep.h"
15
+ #include " optional.h"
15
16
#include " prefix.h"
16
17
17
18
#include < string>
@@ -185,6 +186,8 @@ class source_locationt:public irept
185
186
return static_cast <const source_locationt &>(get_nil_irep ());
186
187
}
187
188
189
+ optionalt<std::string> full_path () const ;
190
+
188
191
protected:
189
192
std::string as_string (bool print_cwd) const ;
190
193
};
You can’t perform that action at this time.
0 commit comments