Skip to content

Feat/plugin interface touchup#138

Open
TimHeldmann wants to merge 22 commits intotudasc:develfrom
TimHeldmann:feat/pluginInterfaceTouchup
Open

Feat/plugin interface touchup#138
TimHeldmann wants to merge 22 commits intotudasc:develfrom
TimHeldmann:feat/pluginInterfaceTouchup

Conversation

@TimHeldmann
Copy link
Copy Markdown
Member

This PR adds two Demoplugins, one for CaGe and one for CGC2.
They are also added to the CI, to test whether we can correctly link and run plugins in CaGe and CGC2.
To add the Demoplugins the PR adds an interface library to link against, as well as changin the CMake files to install the necessary header files.

It lastly moved the existing FileInfoMetadata+Collector combo, which served as a demo plugin for CGC2 to the graphlib core-metadata.
This is because legacy CGC outputs FileInfoMD by default.

Looking forward to your feedback.

@TimHeldmann TimHeldmann force-pushed the feat/pluginInterfaceTouchup branch from 5e4783f to 781bd01 Compare March 27, 2026 13:26
Copy link
Copy Markdown
Member

@pearzt pearzt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only did a rough sweep over your changes, but everything looks sensible to me.

abort();
}
assert(false && "This metadata can not be exported and therefore is not mergeable");
// const ASTNodeMetadata* toMergeDerived = static_cast<const ASTNodeMetadata*>(&toMerge);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: This looks like a leftover.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

Copy link
Copy Markdown
Member

@jplehr jplehr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is basically two changes smushed into one PR together with more formatting NFC changes.

I would appreciate better separation in the future and left some comments.

Comment on lines +9 to +10
#include "metacg/Callgraph.h"
#include "metacg/LoggerUtil.h"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated NFC change?
(we can keep it in, but I think it is unrelated)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is unrelated and should have probably be part of: #136.

I agree to keep it.

abort();
}
assert(false && "This metadata can not be exported and therefore is not mergeable");
// const ASTNodeMetadata* toMergeDerived = static_cast<const ASTNodeMetadata*>(&toMerge);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug leftover? remove

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

}

/**
* Specify how to clone your metadat
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Specify how to clone your metadat
* Specify how to clone your metadata

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

* https://github.com/tudasc/metacg/LICENSE.txt
*/
#include "../interface/CaGePlugin.h"
#include "cage/interface/CaGePlugin.h"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated NFC change
see above

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, same as above

*
* @param g A map how to rename the old node-id to a new node-id, which is valid in the merged graph
*/
void applyMapping(const metacg::GraphMapping& g) final {}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mark g as [[maybe_unused]] or remove it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can not add param documentation to an unnamed parameter.
I therefore will mark it as [[maybe_unused]].

}

/**
* Specify how to clone your metadat
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Specify how to clone your metadat
* Specify how to clone your metadata

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

/**
* Returns mangled names for all named decls, including Ctor/Dtor.
*/
static std::vector<std::string> getMangledName(clang::NamedDecl const* const nd) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the same logic that we use in the old cgcollector? I assume that there is no easy way to share code between such components, right?
If we wanted to do that we would require another shared lib that provides such things.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is the same logic used in cgc1.
There is currently no way (except linking the cgc2 against the cgc1's lib), to share this logic.
I am initially against having cgc1 and cgc2 share parts of their code in a shared library.
But I am open to reasons and to discuss if there is a need for smth. like a "ASTUtilitys.so", but this should be a different PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, this is a matter of understanding the situation. Certainly for future PR.


#include "metacg/metadata/MetaData.h"
#include <SharedDefs.h>
#include <cgcollector2/SharedDefs.h>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include <cgcollector2/SharedDefs.h>
#include "cgcollector2/SharedDefs.h"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

mightCall.reserve(mightCall.size()+toMergeDerived->mightCall.size());
for(const auto& elem : toMergeDerived->mightCall){
if(std::find(mightCall.begin(), mightCall.end(), elem)!=mightCall.end()){
// This might be faster when using
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all of this is unrelated formatting NFC only, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, looks like it.
I think I can take this whole file out of the PR.
It probably got included during reformatting.
The above change is also NFC.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be great!

Comment on lines +134 to +135
metacg::MCGLogger::instance().getErrConsole()->error("cannot locate the library at {}!", pluginPath);
metacg::MCGLogger::instance().getErrConsole()->error("Reason: {}", err);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we first construct a single string and then pass that to the error function to avoid splitting the info in log files when multiple processes run?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants