File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -3808,11 +3808,18 @@ class SourceFile {
38083808 }
38093809#endif
38103810
3811+ // Allow adding to paths gotten from BACKWARD_CXX_SOURCE_PREFIXES after loading the
3812+ // library; this can be useful when the library is loaded when the locations are unknown
3813+ // Warning: Because this edits the static paths variable, it is *not* intrinsiclly thread safe
3814+ static void add_paths_to_env_variable_impl (const std::string & to_add) {
3815+ get_mutable_paths_from_env_variable ().push_back (to_add);
3816+ }
3817+
38113818private:
38123819 details::handle<std::ifstream *, details::default_delete<std::ifstream *> >
38133820 _file;
38143821
3815- std::vector<std::string> get_paths_from_env_variable_impl () {
3822+ static std::vector<std::string> get_paths_from_env_variable_impl () {
38163823 std::vector<std::string> paths;
38173824 const char *prefixes_str = std::getenv (" BACKWARD_CXX_SOURCE_PREFIXES" );
38183825 if (prefixes_str && prefixes_str[0 ]) {
@@ -3821,9 +3828,13 @@ class SourceFile {
38213828 return paths;
38223829 }
38233830
3824- const std::vector<std::string> &get_paths_from_env_variable () {
3825- static std::vector<std::string> paths = get_paths_from_env_variable_impl ();
3826- return paths;
3831+ static std::vector<std::string> &get_mutable_paths_from_env_variable () {
3832+ static volatile std::vector<std::string> paths = get_paths_from_env_variable_impl ();
3833+ return const_cast <std::vector<std::string>&>(paths);
3834+ }
3835+
3836+ static const std::vector<std::string> &get_paths_from_env_variable () {
3837+ return get_mutable_paths_from_env_variable ();
38273838 }
38283839
38293840#ifdef BACKWARD_ATLEAST_CXX11
You can’t perform that action at this time.
0 commit comments