The getIdAddr() function returns the address of the ID of the abstract attribute
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This seems like too much code duplication.
I think we can have a macro to declare getIdAddr and the getName function.
I am curious what other people think about this.
@kuter Do you mean we can use macro inside the header file? for example, we create such macro and use it inside the declaration of the class, but I still think it is not clean.
#define AA_FUNC_GET_ID(CLASS) \ const char *getIdAddr() const override { return &ID; }
As far as I know we the getIdAddr() function has to be declared for every AbstractAttributes, so we cannot avoid this. However, maybe we can create a macro for the actual definition of the function (like the createForPosition function)
- In header file:
struct AA { const char *getIdAddr() const override;
- in source file
#define AA_FUNC_GET_ID(CLASS) \ const char *CLASS::getIdAddr() { return &ID; }
But I think such getter is short and small, and this way does not seem to reduce the code duplication...
Do you have any other ideas for this? Thanks.
I was think of having a macro inside the head file.
Attributes are going to be decleared outside of the Attributor soon.
so I think we can have a macro like this:
#define ATTRIBUTE_BOILER(CLASS) \ const char *getIdAddr() { return &ID} \ const std::string getName() { return #CLASS;} \ static const char ID;
Attributes are going to be decleared outside of the Attributor soon.
Do you mean that there might be other abstract attributes defined outside the AttributorAttributes.cpp ?
so I think we can have a macro like this:
#define ATTRIBUTE_BOILER(CLASS) \ const char *getIdAddr() { return &ID} \ const std::string getName() { return #CLASS;} \ static const char ID;
Yes this could work, but I am still unsure about it..... I'd also like to hear what others think about this.
As of yesterday, there is an AA outside of AttributorAttributes :). You should rebase.
so I think we can have a macro like this:
#define ATTRIBUTE_BOILER(CLASS) \ const char *getIdAddr() { return &ID} \ const std::string getName() { return #CLASS;} \ static const char ID;Yes this could work, but I am still unsure about it..... I'd also like to hear what others think about this.
I mean it is not that much code. Maybe I'm missing something, but why not just use ID directly?