qiongsiwu wrote: > I'd prefer if we didn't duplicate all the existing logic. Would it be > possible to fit CompilerInstanceWithContext into the current tool/worker > APIs? I'm thinking that maybe getModuleDependencies() and other top-level > APIs could accept a flag that would control whether > CompilerInstanceWithContext should be carried between API invocations, or > whether it should be created anew each time.
Ah thanks for the suggestion! The new APIs (initialization, by name query, and finalization) are intentional for two reasons: 1. How this works is significantly different from the existing APIs. I intend to make it as obvious as possible that states are cached between the calls. `CompilerInstanceWithContext::computeDependencies` only takes a name as its input, and this further implies that the cwd/commandline are inherited and stored. I feel that tweaking existing APIs may be confusing to the user. 2. I find it difficult to implement with a flag added to the existing API to control if a `CompilerInstanceWithContext` should be used. What if the user is calling the querying function multiple times with different `CWD`/`Commandline` combinations but set the flag to use `CompilerInstanceWithContext`? I think in those cases we may need to implement a list of `CompilerInstanceWithContext` to make sure we are always picking up the correct instance. I think that is manageable, but that will add more complexity to this patch. One thing I plan to do later is to replace `DependencyScanningAction` with `CompilerInstanceWithContext` to perform all scanning, so we can consolidate the implementation from the back. https://github.com/llvm/llvm-project/pull/160207 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
