-
Notifications
You must be signed in to change notification settings - Fork 436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When analyzing the class inheritance relationship, treat the members of the class as the parent class #1539
Comments
Would you be able to dig a bit and locate where the bug is? |
I think it’s because in the process of analyzing class members, all class members that are structures are regarded as their parent classes. For example the above code:
In fact, JitterCorrection is a member variable in AP_GPS_Backend, but svf mistakenly recognized it as the parent class of AP_GPS_Backend. I read some code, and I think maybe it's because of the readInheritanceMetadataFromModule(const Module &M) function in CHGBuilder.cpp, which iterates through all the operands and treats the operands as his parent class.
But I have a little doubt: I queried the entire IR and did not find "_cxx_bases_of". But I have one question: I queried the entire IR and did not find "_cxx_bases_of". Is the "_cxx_bases_of" prefix generated by dynamic analysis during processing? Or does this prefix always exist in the IR file? If it is the former, then I think there is a problem with the way readInheritanceMetadataFromModule is processed. The processing logic of this function should be in the second for loop. When it encounters the first parameter that is not a structure, it will stop connecting the class inheritance graph. If so The latter, then I can't determine the problem. |
CHG should not rely on metadata. We will need to identify the pattern from llvm bc alone. |
I think I found the problem, the function "buildCHG()" will call the function "void CHGBuilder::buildCHGNodes(const Function* F)", and then the function "void CHGBuilder::buildCHGNodes(const Function* F)" will call " connectInheritEdgeViaCall"
This function will find the constructor or destructor of a class. If the constructor (destructor) of the class calls the constructor (destructor) of another class, the class will be treated as a subclass of the other class. |
In fact, the situation where the constructor of one class calls the constructor of another class may be caused by two reasons: 1. The class is a subclass of another class. 2.An instance of another class is a member variable of that class. |
That is a good finding. Could we distinguish these two cases by changing the above code to fix it? |
Unfortunately, in the above code, it should be difficult to distinguish between the two cases.
the correspond IR is:
you could see that the call of two case is same,so I can not distinguish the two case by modifying above code |
Any other way to distinguish them? |
The class definition is like this
The definition of class in IR is:
In the generated class inheritance graph, the edges related to this class are:
The analysis result of SVF is that the parent class of AP_GPS_Backend is JitterCorrection, but in fact JitterCorrection is a member of AP_GPS_Backend.
The version of SVF that I using is svf-3.0,and I use the command "wpa -sfrander -dump-cha "to generate the CHA.
The text was updated successfully, but these errors were encountered: