Skip to content

Commit 4109001

Browse files
committed
Fix cgmerge to handle callgraphs with null meta field
1 parent 6705bdd commit 4109001

3 files changed

Lines changed: 14 additions & 8 deletions

File tree

AUTHORS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,5 @@ Tim Heldmann <Scientific Computing>
2020
Marek Beckmann <Scientific Computing>
2121
Silas Martens <Scientific Computing>
2222

23-
2423
External Contributors
2524
Jan-Patrick Lehr <AMD>

cgcollector/lib/src/JSONManager.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,11 @@ nlohmann::json buildFromJSONv2(FuncMapT& functionMap, const std::string& filenam
170170
auto ps = it.value()["callers"].get<std::set<std::string>>();
171171
fi.parents.insert(ps.begin(), ps.end());
172172

173-
readNumStmts(it.value(), fi);
174-
readFileOrigin(it.value(), fi);
173+
if(!it.value()["meta"].is_null()) {
174+
readNumStmts(it.value(), fi);
175+
readFileOrigin(it.value(), fi);
176+
}
177+
175178
}
176179

177180
// Now the functions map holds all the information

cgcollector/tools/CGMerge.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,12 @@ nlohmann::json mergeFileFormatTwo(const std::string& wholeCGFilename, const std:
7373
} else {
7474
auto& c = wholeCG[it.key()];
7575
auto& v = it.value();
76+
if (v["meta"].is_null()) {
77+
doMerge(c, v); // skip merging metadata
78+
7679
// TODO multiple bodies possible, if the body is in header?
7780
// TODO separate merge of meta information
78-
if (v["hasBody"].get<bool>() && c["hasBody"].get<bool>()) {
81+
} else if (v["hasBody"].get<bool>() && c["hasBody"].get<bool>()) {
7982
// std::cout << "WARNING: merge of " << it.key()
8083
// << " has detected multiple bodies (equal number of statements would be good.)" << std::endl;
8184
// TODO check for equal values
@@ -105,10 +108,11 @@ nlohmann::json mergeFileFormatTwo(const std::string& wholeCGFilename, const std:
105108
// callees, isVirtual, doesOverride and overriddenFunctions unchanged
106109
// hasBody unchanged
107110
// numStatements unchanged
108-
} else {
109-
// nothing special
110-
}
111-
if (!c["meta"].contains("estimateCallCount") && v["meta"].contains("estimateCallCount")) {
111+
}
112+
113+
if (c["meta"].is_null()) {
114+
// Metadata is null, nothing to merge
115+
} else if (!c["meta"].contains("estimateCallCount") && v["meta"].contains("estimateCallCount")) {
112116
c["meta"]["estimateCallCount"] = v["meta"]["estimateCallCount"];
113117
} else if (c["meta"].contains("estimateCallCount") && v["meta"].contains("estimateCallCount")) {
114118
auto& ccalls = c["meta"]["estimateCallCount"]["calls"];

0 commit comments

Comments
 (0)