2323#include " boost/program_options.hpp"
2424
2525#include " llvm/ADT/iterator_range.h"
26- #include " llvm/Support/ManagedStatic.h"
2726
2827#include " phasar/Config/Version.h"
2928
@@ -36,57 +35,63 @@ class PhasarConfig {
3635public:
3736 // / Current Phasar version
3837 // NOLINTNEXTLINE(readability-identifier-naming)
39- static std::string PhasarVersion () { return XSTR (PHASAR_VERSION); }
38+ [[nodiscard]] static std::string PhasarVersion () {
39+ return XSTR (PHASAR_VERSION);
40+ }
4041
4142 // / Stores the label/ tag with which we annotate the LLVM IR.
4243 // NOLINTNEXTLINE(readability-identifier-naming)
43- static std::string MetaDataKind () { return " psr.id" ; }
44+ [[nodiscard]] static std::string MetaDataKind () { return " psr.id" ; }
4445
46+ // / Specifies the directory in which important configuration files are
47+ // / located.
4548 // NOLINTNEXTLINE(readability-identifier-naming)
46- static std::string ConfigurationDirectory () { return ConfigDir; }
49+ [[nodiscard]] static const std::string & ConfigurationDirectory ();
4750
4851 // / Specifies the directory in which Phasar is located.
4952 // NOLINTNEXTLINE(readability-identifier-naming)
50- static std::string PhasarDirectory () { return PhasarDir; }
53+ [[nodiscard]] static const std::string & PhasarDirectory ();
5154
5255 // / Name of the file storing all standard header search paths used for
5356 // / compilation.
5457 // NOLINTNEXTLINE(readability-identifier-naming)
55- static std::string HeaderSearchPathsFileName () {
58+ [[nodiscard]] static std::string HeaderSearchPathsFileName () {
5659 return " standard_header_paths.conf" ;
5760 }
5861
5962 // / Name of the compile_commands.json file (in case we wish to rename)
6063 // NOLINTNEXTLINE(readability-identifier-naming)
61- static std::string CompileCommandsJson () { return " compile_commands.json" ; }
64+ [[nodiscard]] static std::string CompileCommandsJson () {
65+ return " compile_commands.json" ;
66+ }
6267
6368 // / Default Source- and Sink-Functions path
6469 // NOLINTNEXTLINE(readability-identifier-naming)
65- static std::string DefaultSourceSinkFunctionsPath () {
66- return std::string (PhasarDirectory () +
67- " config/phasar-source-sink-function.json" );
70+ [[nodiscard]] static std::string DefaultSourceSinkFunctionsPath () {
71+ return PhasarDirectory () + " config/phasar-source-sink-function.json" ;
6872 }
6973
7074 // Variables to be used in JSON export format
7175 // / Identifier for call graph export
7276 // NOLINTNEXTLINE(readability-identifier-naming)
73- static std::string JsonCallGraphID () { return " psr.cg" ; }
77+ [[nodiscard]] static std::string JsonCallGraphID () { return " psr.cg" ; }
7478
7579 // / Identifier for type hierarchy graph export
7680 // NOLINTNEXTLINE(readability-identifier-naming)
77- static std::string JsonTypeHierarchyID () { return " psr.th" ; }
81+ [[nodiscard]] static std::string JsonTypeHierarchyID () { return " psr.th" ; }
7882
7983 // / Identifier for points-to graph export
8084 // NOLINTNEXTLINE(readability-identifier-naming)
81- static std::string JsonPointsToGraphID () { return " psr.pt" ; }
85+ [[nodiscard]] static std::string JsonPointsToGraphID () { return " psr.pt" ; }
8286
8387 // / Identifier for data-flow results export
8488 // NOLINTNEXTLINE(readability-identifier-naming)
85- static std::string JsonDataFlowID () { return " psr.df" ; }
89+ [[nodiscard]] static std::string JsonDataFlowID () { return " psr.df" ; }
8690
87- static PhasarConfig &getPhasarConfig ();
91+ [[nodiscard]] static PhasarConfig &getPhasarConfig ();
8892
89- llvm::iterator_range<std::set<std::string>::iterator> specialFunctionNames () {
93+ [[nodiscard]] llvm::iterator_range<std::set<std::string>::iterator>
94+ specialFunctionNames () const {
9095 return llvm::make_range (SpecialFuncNames.begin (), SpecialFuncNames.end ());
9196 }
9297
@@ -102,7 +107,7 @@ class PhasarConfig {
102107
103108 // / Variables map of the parsed command-line parameters
104109 // NOLINTNEXTLINE(readability-identifier-naming)
105- static boost::program_options::variables_map &VariablesMap () {
110+ [[nodiscard]] static boost::program_options::variables_map &VariablesMap () {
106111 static boost::program_options::variables_map VMap;
107112 return VMap;
108113 }
@@ -116,40 +121,21 @@ class PhasarConfig {
116121private:
117122 PhasarConfig ();
118123
119- static std::string readConfigFile (const std::string &Path);
120124 void loadGlibcSpecialFunctionNames ();
121125 void loadLLVMSpecialFunctionNames ();
122126
123127 std::set<std::string> SpecialFuncNames;
124128
125- // / Specifies the directory in which important configuration files are
126- // / located.
127- inline static const std::string ConfigDir = []() {
128- auto *EnvHome = std::getenv (" HOME" );
129- std::string ConfigFolder = " config/" ;
130- if (EnvHome) { // Check if HOME was defined in the environment
131- std::string PhasarConfDir = std::string (EnvHome) + " /.config/phasar/" ;
132- if (std::filesystem::exists (PhasarConfDir) &&
133- std::filesystem::is_directory (PhasarConfDir)) {
134- ConfigFolder = PhasarConfDir;
135- }
136- }
137- return ConfigFolder;
138- }();
139-
140- // / Specifies the directory in which Phasar is located.
141- static const std::string PhasarDir;
142-
143129 // / Name of the file storing all glibc function names.
144- static inline const std::string GLIBCFunctionListFileName =
130+ static inline auto GLIBCFunctionListFileName =
145131 " glibc_function_list_v1-04.05.17.conf" ;
146132
147133 // / Name of the file storing all LLVM intrinsic function names.
148- static inline const std::string LLVMIntrinsicFunctionListFileName =
134+ static inline auto LLVMIntrinsicFunctionListFileName =
149135 " llvm_intrinsics_function_list_v1-04.05.17.conf" ;
150136
151137 // / Log file directory
152- static inline const std::string LogFileDirectory = " log/" ;
138+ static inline auto LogFileDirectory = " log/" ;
153139};
154140
155141} // namespace psr
0 commit comments