[clang] [clang] Extract `CompilerInstance` creation out of `compileModuleImpl()` (PR #134887)

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 10 15:51:45 PDT 2025


jansvoboda11 wrote:

> Can you not just move the `err_module_rebuild_finalized` diagnostic into `compileModuleImpl`? It has access to everything it needs there.

I didn't want to do it there to avoid unnecessarily creating the `CompilerInstance` when we're about to hit the error. But I tried moving the diagnostic into `compileModuleImpl()` and it nicely allows for collapsing `compileModule()` and `compileModuleImpl()` together, if we're fine with this running for the `#pragma clang module build/endbuild` case too:

```c++
  // We've rebuilt a module. If we're allowed to generate or update the global
  // module index, record that fact in the importing compiler instance.
  if (ImportingInstance.getFrontendOpts().GenerateGlobalModuleIndex) {
    ImportingInstance.setBuildGlobalModuleIndex(true);
  }
```

https://github.com/llvm/llvm-project/pull/134887


More information about the cfe-commits mailing list