jansvoboda11 added a comment.

Hi @rsmith, this commit makes it possible for `HeaderInfo::LookupFile()` to be 
called with different `RequestingModule` within single `CompilerInstance`. This 
is problematic, since some modules may see headers other modules can't (due to 
`[no_undeclared_includes]`). This can permanently mess up contents of the 
lookup cache (`HeaderSearch::LookupFileCache`) that uses only the lookup name 
as the key. You can see the minimal reproducer below. On our side, we can work 
around this by using `-fno-modules-validate-textual-header-includes`, but I 
think this will need to be fixed before that options goes away.

  // RUN: rm -rf %t
  // RUN: split-file %s %t
  
  //--- include/module.modulemap
  module A [no_undeclared_includes] { textual header "A.h" }
  module B { header "B.h" }
  //--- include/A.h
  #if __has_include(<B.h>)
  #error Even textual headers within module A now inherit 
[no_undeclared_includes] \
         and thus do not have that include.
  #endif
  //--- include/B.h
  
  //--- tu.c
  #if !__has_include(<B.h>)
  #error Main TU does have that include.
  #endif
  
  #include "A.h"
  
  #if !__has_include(<B.h>)
  #error Main TU still has that include.
  // We hit the above because the unsuccessful __has_include check in A.h taints
  // lookup cache (HeaderSearch::LookupFileCache) of this CompilerInstance.
  #endif
  
  // RUN: %clang_cc1 -I %t/include -fmodules -fimplicit-module-maps \
  // RUN:   -fmodules-cache-path=%t/cache -fsyntax-only %t/tu.c


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132779/new/

https://reviews.llvm.org/D132779

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D132779: ... Jan Svoboda via Phabricator via cfe-commits

Reply via email to