Hello Gabor,
thank you for your proposal. In our approach, we introduced ASTContext::getXTUDefinition() method to allow clients import functions they need. Did you follow the same way or added something else on top?
> - In case a function is defined in a header, do not emit the body.
There may be issues with this approach. Code:
1.cpp
#include "1.h"
1.h
void f() {...}
2.cpp
void f();
...
f();
needs a header-located function to be imported for analysis of 2.cpp.
Also, in general, somebody may need to search for non-function stuff: for types or variables, for example. CSA may need to search for a global variable initializer, too (we didn't implement it currently). It is a more common task. But we need to start with something.
Hi!
Hello Gabor,
thank you for your proposal. In our approach, we introduced
ASTContext::getXTUDefinition() method to allow clients import functions
they need. Did you follow the same way or added something else on top?
I used that implementation.
> - In case a function is defined in a header, do not emit the body.
There may be issues with this approach. Code:
1.cpp
#include "1.h"
1.h
void f() {...}
2.cpp
void f();
...
f();
needs a header-located function to be imported for analysis of 2.cpp.
You are right. This method would not work for those scenarios. But losing
some definition might worth it to make this solution feasible. Another
possible solution would be to try to come up with a protocol to only export
the definition of such functions once (so only for one translation unit).
A better solution would be possible with modularized builds
<http://clang.llvm.org/docs/Modules.html>: then each header's AST would be
serialized exactly once instead of being copied in each translation unit.
That requires a serious pre-work to make the analyzed code compatible with
modules, but it seems to be the most perspective long-term approach.