Skip to content

Commit eea02aa

Browse files
committed
Remove cyclic dependency between phasar_utils and phasar_config
1 parent 374b76e commit eea02aa

6 files changed

Lines changed: 24 additions & 19 deletions

File tree

include/phasar/Utils/PAMM.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#ifndef PHASAR_UTILS_PAMM_H_
1818
#define PHASAR_UTILS_PAMM_H_
1919

20+
#include "boost/program_options/variables_map.hpp"
21+
2022
#include <chrono> // high_resolution_clock::time_point, milliseconds
2123
#include <set> // set
2224
#include <string> // string
@@ -25,7 +27,7 @@
2527

2628
namespace llvm {
2729
class raw_ostream;
28-
}
30+
} // namespace llvm
2931

3032
namespace psr {
3133

@@ -188,7 +190,8 @@ class PAMM {
188190
/// \brief Exports the measured data to JSON - associated macro:
189191
/// EXPORT_MEASURED_DATA(PATH).
190192
/// \param OutputPath to exported JSON file.
191-
void exportMeasuredData(std::string OutputPath);
193+
void exportMeasuredData(std::string OutputPath,
194+
boost::program_options::variables_map &Config);
192195
};
193196

194197
} // namespace psr

include/phasar/Utils/Utilities.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,8 @@ struct StringIDLess {
162162
template <typename Fn> class scope_exit { // NOLINT
163163
public:
164164
template <typename FFn, typename = decltype(std::declval<FFn>()())>
165-
explicit scope_exit(FFn &&F) noexcept(
166-
std::is_nothrow_constructible_v<Fn, FFn> ||
167-
std::is_nothrow_constructible_v<Fn, FFn &>)
165+
scope_exit(FFn &&F) noexcept(std::is_nothrow_constructible_v<Fn, FFn> ||
166+
std::is_nothrow_constructible_v<Fn, FFn &>)
168167
: F(std::forward<FFn>(F)) {}
169168

170169
~scope_exit() { F(); }

lib/Config/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
file(GLOB_RECURSE CONFIG_SRC *.h *.cpp)
22

3+
set(PHASAR_LINK_LIBS
4+
phasar_utils
5+
)
6+
37
set(LLVM_LINK_COMPONENTS
48
Support
59
)

lib/Utils/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ if(PHASAR_ENABLE_PAMM STREQUAL "Off" AND NOT PHASAR_BUILD_UNITTESTS)
77
endif()
88

99
set(PHASAR_LINK_LIBS
10-
phasar_config
1110
)
1211

1312
set(LLVM_LINK_COMPONENTS

lib/Utils/PAMM.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
#include "nlohmann/json.hpp"
2626

27-
#include "phasar/Config/Configuration.h"
2827
#include "phasar/Utils/PAMM.h"
2928

3029
using namespace psr;
@@ -274,7 +273,8 @@ void PAMM::printMeasuredData(llvm::raw_ostream &Os) {
274273
Os << "\n----- END OF EVALUATION DATA -----\n\n";
275274
}
276275

277-
void PAMM::exportMeasuredData(std::string OutputPath) {
276+
void PAMM::exportMeasuredData(std::string OutputPath,
277+
boost::program_options::variables_map &Config) {
278278
// json file for holding all data
279279
json JsonData;
280280

@@ -313,18 +313,15 @@ void PAMM::exportMeasuredData(std::string OutputPath) {
313313

314314
// add analysis/project/source file information if available
315315
json JInfo;
316-
if (PhasarConfig::VariablesMap().count("project-id")) {
317-
JInfo["Project-ID"] =
318-
PhasarConfig::VariablesMap()["project-id"].as<std::string>();
316+
if (Config.count("project-id")) {
317+
JInfo["Project-ID"] = Config["project-id"].as<std::string>();
319318
}
320-
if (PhasarConfig::VariablesMap().count("module")) {
321-
JInfo["Module(s)"] =
322-
PhasarConfig::VariablesMap()["module"].as<std::vector<std::string>>();
319+
if (Config.count("module")) {
320+
JInfo["Module(s)"] = Config["module"].as<std::vector<std::string>>();
323321
}
324-
if (PhasarConfig::VariablesMap().count("data-flow-analysis")) {
322+
if (Config.count("data-flow-analysis")) {
325323
JInfo["Data-flow analysis"] =
326-
PhasarConfig::VariablesMap()["data-flow-analysis"]
327-
.as<std::vector<std::string>>();
324+
Config["data-flow-analysis"].as<std::vector<std::string>>();
328325
}
329326
if (!JInfo.is_null()) {
330327
JsonData["Info"] = JInfo;

unittests/Utils/PAMMTest.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#include "phasar/Utils/PAMM.h"
2+
#include "phasar/Config/Configuration.h"
3+
24
#include "gtest/gtest.h"
3-
#include <thread>
45

56
#include "llvm/Support/raw_ostream.h"
67

8+
#include <thread>
9+
710
using namespace psr;
811

912
/* Test fixture */
@@ -100,7 +103,7 @@ TEST_F(PAMMTest, HandleJSONOutput) {
100103
Pamm.addToHistogram("Test-Set", "2");
101104
Pamm.incCounter("setOpCount", 9);
102105
Pamm.stopTimer("timer3");
103-
Pamm.exportMeasuredData("HandleJSONOutputTest");
106+
Pamm.exportMeasuredData("HandleJSONOutputTest", PhasarConfig::VariablesMap());
104107
}
105108

106109
TEST_F(PAMMTest, DISABLED_PerformanceTimerBasic) {

0 commit comments

Comments
 (0)