Skip to content

Commit 397a6da

Browse files
author
Daniel Kroening
committed
added source_locationt::full_path()
1 parent af06d4e commit 397a6da

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/util/source_location.cpp

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

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 the empty string is returned.
77+
std::string source_locationt::full_path() const
78+
{
79+
if(get_file().empty())
80+
return std::string();
81+
82+
const auto file = id2string(get_file());
83+
84+
if(is_built_in(file))
85+
return std::string();
86+
87+
return concat_dir_file(id2string(get_working_directory()), file);
88+
}
89+
7490
std::ostream &operator << (
7591
std::ostream &out,
7692
const source_locationt &source_location)

src/util/source_location.h

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

188+
std::string full_path() const;
189+
188190
protected:
189191
std::string as_string(bool print_cwd) const;
190192
};

0 commit comments

Comments
 (0)