SVF
SVF copied to clipboard
Enhancement: Introduce an SVF namespace
Especially when using SVF as library, it would be nice if all symbols and preprocessor constants are prefixed with SVF, i.e. to use a namespace SVF for C++ itself and the prefix "SVF_" for preprocessor constansts.
For example, I currently include the SVF with the following lines:
#define VERSION_BKP VERSION
#undef VERSION
#include <Graphs/VFGNode.h>
#include <SVF-FE/PAGBuilder.h>
#include <Util/BasicTypes.h>
#include <WPA/Andersen.h>
#undef VERSION
#define VERSION VERSION_BKP
#undef VERSION_BKP
Good suggestion! Would you be able to help us with adding SVF
as the namespace?
Hi guys, I'd be willing to help you with that. Especially in adding a C++ namespace. Please let me know how you'd like to proceed on this!
Thanks, you could add a namespace called "SVF" for all the classes and methods. It would be good to do the minimum changes to the project.
Hi Yulei, by the way, while adding the namespace I noticed that at lot of cpp files have using namespace SVFUtil
but then either don't require the namespace at all or still call methods through SVFUtil::foo()
. If it's okay with you I would remove all those unnecessary using namespace SVFUtil
to clean up the code a bit. What do you think?
Sounds good to me. Please go ahead and thanks.
Hi again, I just started removing using namespace SVFUtil
and adding SVFUtil::
to functions where necessary, when I realized how many calls to functions from the SVFUtil namespace there actually are. So, to be clear, when I continue with this, there will be a lot of changes.
As an alternative, I thought about keeping using namespace SVFUtil
but then removing the SVFUtil::
everywhere to be consistent. However, after doing this for some files, compiling SVF gave me ambiguous calls to casting functions, e.g., to SVFUtil::dyn_cast()
and llvm::dyn_cast()
. As far as I see, the only option to continue with this alternative would be to remove include/Util/Casting.h
altogether and instead rely on the LLVM casting functions. However, I cannot tell whether there is a reason why these casting functions are re-implemented in SVF?
Do you have any preference on how to proceed?
remove include/Util/Casting.h
would be a good option. Since we have too many dyn_cast
and isa
in SVF, can we remove llvm::
and typedef it here: https://github.com/SVF-tools/SVF/blob/master/include/Util/BasicTypes.h
Not directly this namespace but goes in the same direction, therefore I mention it here. It would be nice if the headers also would be in an SVF directory.
So one has to write:
#include <SVF/Graphs/SVFG.h>
instead of
#include <Graphs/SVFG.h>