Skip to content

Commit 11ed46a

Browse files
author
Daniel Kroening
committed
added source_locationt::full_path()
1 parent ebce18a commit 11ed46a

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/util/source_location.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@ void source_locationt::merge(const source_locationt &from)
7171
}
7272
}
7373

74+
/// get a path to the file in given source location
75+
std::string source_locationt::full_path() const
76+
{
77+
if(get_file().empty())
78+
return std::string();
79+
80+
const auto file = id2string(get_file());
81+
82+
if(is_built_in(file))
83+
return std::string();
84+
85+
return concat_dir_file(id2string(get_working_directory()), file);
86+
}
87+
7488
std::ostream &operator << (
7589
std::ostream &out,
7690
const source_locationt &source_location)

src/util/source_location.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ class source_locationt:public irept
185185
return static_cast<const source_locationt &>(get_nil_irep());
186186
}
187187

188+
/// get a path to the file, including working directory
189+
std::string full_path() const;
190+
188191
protected:
189192
std::string as_string(bool print_cwd) const;
190193
};

0 commit comments

Comments
 (0)