Skip to content

Commit 5e4783f

Browse files
committed
Reformat
1 parent 2611019 commit 5e4783f

31 files changed

Lines changed: 332 additions & 347 deletions

graph/include/metacg/metadata/FileInfoMD.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
2-
* File: FileInfoMD.h
3-
* License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at
4-
* https://github.com/tudasc/metacg/LICENSE.txt
5-
*/
2+
* File: FileInfoMD.h
3+
* License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at
4+
* https://github.com/tudasc/metacg/LICENSE.txt
5+
*/
66

77
#ifndef CGCOLLECTOR2_FILEINFOMETADATA_H
88
#define CGCOLLECTOR2_FILEINFOMETADATA_H
@@ -19,7 +19,7 @@ class FileInfoMetadata : public metacg::MetaData::Registrar<FileInfoMetadata> {
1919
public:
2020
static constexpr const char* key = "FilePropertiesMetaData";
2121
FileInfoMetadata() : origin("INVALID"), fromSystemInclude(false), lineNumber(0) {}
22-
explicit FileInfoMetadata(const nlohmann::json& j, metacg::StrToNodeMapping& strToNode){
22+
explicit FileInfoMetadata(const nlohmann::json& j, metacg::StrToNodeMapping& strToNode) {
2323
if (j.is_null()) {
2424
metacg::MCGLogger::instance().getConsole()->trace("Could not retrieve meta data for fileProperties");
2525
return;
@@ -38,7 +38,7 @@ class FileInfoMetadata : public metacg::MetaData::Registrar<FileInfoMetadata> {
3838
return j;
3939
}
4040

41-
void applyMapping(const metacg::GraphMapping&) final{}
41+
void applyMapping(const metacg::GraphMapping&) final {}
4242

4343
void merge(const MetaData&, std::optional<metacg::MergeAction>, const metacg::GraphMapping&) final {}
4444
const char* getKey() const final { return key; }

pgis/test/unit/CallgraphTest.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
#include "gtest/gtest.h"
88

9-
109
#include "metacg/Callgraph.h"
1110
#include "metacg/LoggerUtil.h"
1211

tools/cage/CMakeLists.txt

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,24 @@ add_subdirectory(test)
33

44
add_library(cage-plugin-interface INTERFACE)
55

6-
target_sources(cage-plugin-interface PUBLIC
7-
FILE_SET HEADERS
8-
BASE_DIRS include
9-
FILES include/cage/interface/CaGePlugin.h
6+
target_sources(
7+
cage-plugin-interface
8+
PUBLIC FILE_SET
9+
HEADERS
10+
BASE_DIRS
11+
include
12+
FILES
13+
include/cage/interface/CaGePlugin.h
1014
)
1115

1216
target_link_libraries(cage-plugin-interface INTERFACE metacg::metacg)
1317
add_llvm(cage-plugin-interface INTERFACE)
1418

15-
16-
install(TARGETS cage-plugin-interface EXPORT cage-plugin-interfaceExport
17-
FILE_SET HEADERS DESTINATION include/)
19+
install(
20+
TARGETS cage-plugin-interface
21+
EXPORT cage-plugin-interfaceExport
22+
FILE_SET HEADERS
23+
DESTINATION include/
24+
)
1825

1926
install(TARGETS cage cage-plugin LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})

tools/cage/CaGeDemoPlugin/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ project(CaGeDemoPlugin)
44
find_package(metacg REQUIRED)
55

66
if(metacg_FOUND)
7-
message(STATUS "metacg found")
7+
message(STATUS "metacg found")
88
endif()
99

1010
add_library(CaGeDemoPlugin SHARED CaGeDemoPlugin.cpp)
1111

12-
#Build metadata as separate shared object
13-
#This .so can be preloaded to inform many graphlib tools about custom metadata
12+
# Build metadata as separate shared object This .so can be preloaded to inform many graphlib tools about custom metadata
1413
add_library(CaGeDemoMD SHARED CaGeDemoMD.h)
1514
set_target_properties(CaGeDemoMD PROPERTIES LINKER_LANGUAGE CXX)
1615
target_link_libraries(CaGeDemoPlugin PRIVATE CaGeDemoMD)

tools/cage/CaGeDemoPlugin/CaGeDemoMD.h

Lines changed: 60 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -9,83 +9,78 @@
99
#include "metacg/metadata/MetaData.h"
1010

1111
namespace clang {
12-
class FunctionDecl;
12+
class FunctionDecl;
1313
}
1414

15-
1615
class CaGeDemoMD : public metacg::MetaData::Registrar<CaGeDemoMD> {
17-
public:
18-
static constexpr const char* key = "CaCeDemoMetadata";
16+
public:
17+
static constexpr const char* key = "CaCeDemoMetadata";
1918

20-
CaGeDemoMD() = default;
21-
/**
22-
* Specify how to create your Metadata from a json input
23-
*/
24-
explicit CaGeDemoMD(const nlohmann::json&, metacg::StrToNodeMapping&) {
25-
assert(false && "This metadata should not be created via json");
26-
}
19+
CaGeDemoMD() = default;
20+
/**
21+
* Specify how to create your Metadata from a json input
22+
*/
23+
explicit CaGeDemoMD(const nlohmann::json&, metacg::StrToNodeMapping&) {
24+
assert(false && "This metadata should not be created via json");
25+
}
2726

28-
explicit CaGeDemoMD(const void* const f) : address(reinterpret_cast<uintptr_t>(f)) {}
29-
explicit CaGeDemoMD(const uintptr_t p) : address(p) {}
27+
explicit CaGeDemoMD(const void* const f) : address(reinterpret_cast<uintptr_t>(f)) {}
28+
explicit CaGeDemoMD(const uintptr_t p) : address(p) {}
3029

31-
/**
32-
* Specify how to serialize your metadata into a json output
33-
* Return an empty json object to signal that this metadata will not be serialized
34-
* @return empty json object
35-
*/
36-
nlohmann::json toJson(metacg::NodeToStrMapping&) const final {
37-
//We just store the address
38-
return {{"Address", reinterpret_cast<uintptr_t>(address)}};
39-
}
30+
/**
31+
* Specify how to serialize your metadata into a json output
32+
* Return an empty json object to signal that this metadata will not be serialized
33+
* @return empty json object
34+
*/
35+
nlohmann::json toJson(metacg::NodeToStrMapping&) const final {
36+
// We just store the address
37+
return {{"Address", reinterpret_cast<uintptr_t>(address)}};
38+
}
4039

41-
/**
42-
* Allows to query the metadata-key from a baseclass-pointer via virtual dispatch
43-
* @return your metadata key
44-
*/
45-
[[nodiscard]] const char* getKey() const final { return key; }
40+
/**
41+
* Allows to query the metadata-key from a baseclass-pointer via virtual dispatch
42+
* @return your metadata key
43+
*/
44+
[[nodiscard]] const char* getKey() const final { return key; }
4645

47-
/**
48-
* If your metadata stores ids of other callgraph-nodes, they might be invalidated
49-
* This can happen if the graph containing your metadata is merged with another graph.
50-
* Your metadata might be copied into the new graph
51-
* In this case you need to remap the stored node-ids to be valid in the new merged graph context
52-
*
53-
* @param g A map how to rename the old node-id to a new node-id, which is valid in the merged graph
54-
*/
55-
void applyMapping(const metacg::GraphMapping& g) final {}
46+
/**
47+
* If your metadata stores ids of other callgraph-nodes, they might be invalidated
48+
* This can happen if the graph containing your metadata is merged with another graph.
49+
* Your metadata might be copied into the new graph
50+
* In this case you need to remap the stored node-ids to be valid in the new merged graph context
51+
*
52+
* @param g A map how to rename the old node-id to a new node-id, which is valid in the merged graph
53+
*/
54+
void applyMapping(const metacg::GraphMapping& g) final {}
5655

57-
/**
58-
* How to merge your metadata with itself
59-
* This can happen if the graph containing your metadata is merged with another graph.
60-
* Update the state of your this metadata object accordingly
61-
* @param toMerge the other Metadata to merge with
62-
* @param mergeAction contains whether the merge will replace the other metadata
63-
* @param g A map how to rename the old node-id to a new node-id, which is valid in the merged graph
64-
*/
65-
void merge(const MetaData& toMerge, std::optional<metacg::MergeAction> mergeAction,
66-
const metacg::GraphMapping& g) final {
67-
if (std::strcmp(toMerge.getKey(), getKey()) != 0) {
68-
metacg::MCGLogger::instance().getErrConsole()->error(
69-
"The MetaData which was tried to merge with ASTNodeMetadata was of a different MetaData type");
70-
abort();
71-
}
72-
assert(false && "This metadata can not be exported and therefore is not mergeable");
73-
// const ASTNodeMetadata* toMergeDerived = static_cast<const ASTNodeMetadata*>(&toMerge);
56+
/**
57+
* How to merge your metadata with itself
58+
* This can happen if the graph containing your metadata is merged with another graph.
59+
* Update the state of your this metadata object accordingly
60+
* @param toMerge the other Metadata to merge with
61+
* @param mergeAction contains whether the merge will replace the other metadata
62+
* @param g A map how to rename the old node-id to a new node-id, which is valid in the merged graph
63+
*/
64+
void merge(const MetaData& toMerge, std::optional<metacg::MergeAction> mergeAction,
65+
const metacg::GraphMapping& g) final {
66+
if (std::strcmp(toMerge.getKey(), getKey()) != 0) {
67+
metacg::MCGLogger::instance().getErrConsole()->error(
68+
"The MetaData which was tried to merge with ASTNodeMetadata was of a different MetaData type");
69+
abort();
7470
}
71+
assert(false && "This metadata can not be exported and therefore is not mergeable");
72+
// const ASTNodeMetadata* toMergeDerived = static_cast<const ASTNodeMetadata*>(&toMerge);
73+
}
7574

76-
/**
77-
* Specify how to clone your metadat
78-
* @return a cloned version of your metadata
79-
*/
80-
[[nodiscard]] std::unique_ptr<MetaData> clone() const final {
81-
return std::make_unique<CaGeDemoMD>();
82-
}
75+
/**
76+
* Specify how to clone your metadat
77+
* @return a cloned version of your metadata
78+
*/
79+
[[nodiscard]] std::unique_ptr<MetaData> clone() const final { return std::make_unique<CaGeDemoMD>(); }
8380

84-
uintptr_t getAdressValue() {
85-
return reinterpret_cast<uintptr_t>(address);
86-
}
81+
uintptr_t getAdressValue() { return reinterpret_cast<uintptr_t>(address); }
8782

88-
private:
89-
uintptr_t address = 0;
83+
private:
84+
uintptr_t address = 0;
9085
};
9186
#endif
Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* File: CaGeDemoPlugin.cpp
2+
* File: CaGeDemoPlugin.cpp
33
* License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at
44
* https://github.com/tudasc/metacg/LICENSE.txt
55
*/
@@ -14,38 +14,35 @@
1414
* To keep this plugin simple we do not go into clang/llvm internals
1515
*/
1616
struct CaGeDemoPlugin final : cage::Plugin {
17-
18-
/**
17+
/**
1918
* Overwrite if you need to modify the graph, e.g. adding nodes, edges or metadata, based on the LLVM Module
2019
* This will be called before any consumers can consume the graph
2120
* For multiple plugins, invocations of this function are executed in the order the plugins were registered
2221
* @param m the full llvm::Module as available to the pass
2322
* @param cg the metacg callgraph to be modified
2423
* @return void
2524
*/
26-
virtual void augmentCallGraph(const llvm::Module& m, metacg::Callgraph& cg) {
27-
//We cant do much with an llvm::Module reference without linking to llvm's libs
28-
//We attach the adress of the module as global metadata to the graph
29-
cg.addMetaData(std::make_unique<CaGeDemoMD>(&m));
30-
}
25+
virtual void augmentCallGraph(const llvm::Module& m, metacg::Callgraph& cg) {
26+
// We cant do much with an llvm::Module reference without linking to llvm's libs
27+
// We attach the adress of the module as global metadata to the graph
28+
cg.addMetaData(std::make_unique<CaGeDemoMD>(&m));
29+
}
3130

32-
/**
33-
* Overwrite this if you only need to read from the graph, e.g. converting to different formats, or graph analysis
34-
* @param cg the metacg callgraph to be read from
35-
*/
36-
void consumeCallGraph(const metacg::Callgraph& cg) final {
37-
//We don't consume the graph
38-
}
31+
/**
32+
* Overwrite this if you only need to read from the graph, e.g. converting to different formats, or graph analysis
33+
* @param cg the metacg callgraph to be read from
34+
*/
35+
void consumeCallGraph(const metacg::Callgraph& cg) final {
36+
// We don't consume the graph
37+
}
3938

40-
/**
41-
* Overwrite this if you want your Plugin to be listed with a name in the debug logs
42-
* @return the logging name of your plugin
43-
*/
44-
[[nodiscard]] virtual std::string getPluginName() const { return "Cage Demo Plugin"; }
39+
/**
40+
* Overwrite this if you want your Plugin to be listed with a name in the debug logs
41+
* @return the logging name of your plugin
42+
*/
43+
[[nodiscard]] virtual std::string getPluginName() const { return "Cage Demo Plugin"; }
4544
};
4645

4746
extern "C" {
48-
cage::Plugin* getPlugin() {
49-
return new CaGeDemoPlugin();
50-
}
47+
cage::Plugin* getPlugin() { return new CaGeDemoPlugin(); }
5148
}

tools/cage/include/cage/interface/CaGePlugin.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ struct Plugin {
4646
[[nodiscard]] virtual std::string getPluginName() const { return "unnamed Plugin"; }
4747
};
4848

49-
//Needs to be implemented so the plugin can be loaded
49+
// Needs to be implemented so the plugin can be loaded
5050
cage::Plugin* getPlugin();
5151

5252
} // namespace cage
5353

54-
5554
#endif // METACG_CAGEPLUGIN_H

0 commit comments

Comments
 (0)