Due to redeclarations, the function may have different declarations used in CallExpr and in the definition. However, we need to use a unique declaration for both store and lookup in VisitedCallees. This patch fixes issues with analysis in topological order. A simple test is included.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
test/Analysis/inlining/analysis-order.c | ||
---|---|---|
13 ↗ | (On Diff #42396) | Can you use CHECK-NEXT instead? |
I wonder if we can refactor the code so that it is less error prone..
shouldSkipFunction(D, Visited, VisitedAsTopLevel) works with two sets. I assume that you have not updated Decls coming from VisitedAsTopLevel because they come from the CFG and should already be canonical. In this patch, you make sure the values stored in Visited are canonical inside ExprEngineCallAndReturn.cpp. Unfortunately, now the conversion to canonical form is spread all over, which makes it error prone.
Note also that the conversion into canonical from inside the CallGraph is different than what you have:
if (F && !isa<ObjCMethodDecl>(F)) F = F->getCanonicalDecl();
Here is a copy an paste from the review of the patch that introduced that code that attempts to explain the special handling of ObjC:
"This differs from what we discussed by not using the canonical declaration for ObjCMethodDecls. This is because hasBody and getBody work differently for ObjCMethodDecls than FunctionDecls. Using the canonical declaration breaks the call graph. There isn't a problem with the call graph created for ObjCMethodDecls, so I have left them alone."
I suggest:
- Try to figure out what's special about ObjCMethodDecl and can that be fixed in some other way.
- Move the getCanonicalDecl conversion into HandleDeclsCallGraph() + maybe add a comment saying why the decls inside VisitedAsTopLevel are canonical already. This way most of the code would be in one place. Would that work?
Thank you. I'm not familiar with Objective-C/C++ issues so I missed that. I'll take an another look. BTW, maybe it is better to use definition decl instead of canonical?