[clang] [clang] Diagnose config_macros before building modules (PR #83641)

Volodymyr Sapsai via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 4 11:01:50 PST 2024


================
@@ -2006,6 +2021,11 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
   if (auto MaybeModule = MM.getCachedModuleLoad(*Path[0].first)) {
     // Use the cached result, which may be nullptr.
     Module = *MaybeModule;
+    // Config macros are already checked before building a module, but they need
+    // to be checked at each import location in case any of the config macros
+    // have a new value at the current `ImportLoc`.
+    if (Module)
+      checkConfigMacros(getPreprocessor(), Module, ImportLoc);
   } else if (ModuleName == getLangOpts().CurrentModule) {
     // This is the module we're building.
     Module = PP->getHeaderSearchInfo().lookupModule(
----------------
vsapsai wrote:

Do we need to `checkConfigMacros` for a module in this case? It is that we have
```
if
  check
else if
  no check <- comment about this block
else
  check in the called method
```

Don't know the code good enough to tell if it is required or not, just noticed an inconsistency.

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


More information about the cfe-commits mailing list