[PATCH] D18849: [modules] Avoid module relocation error when building modules from VFS

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 11 21:32:02 PDT 2016


bruno updated this revision to Diff 53363.
bruno added a comment.

Hi Richard & Ben,

Thanks for the review!

I've attached a new patch and changed the approach: made findUsableModuleForHeader receive a FileName
instead of FileEntry.  Answering the questions below:

FileManager::getFile returns the same filepath when a file is first requested and found. However,
for cached searches it returns the real path to the file. In the scenario of the testcase, the leak
happens when HeaderSearch::getFileAndSuggestModule calls getFileMgr().getFile for bar.h, prior to
calling findUsableModuleForHeader. Since bar.h is already cached, the real path is passed to findUsableModuleForHeader,
which triggers down the road the module redefinition error.

>From what I understand from http://lists.llvm.org/pipermail/cfe-dev/2014-July/038273.html, changing
the behavior of the cached result has side-effects and demands a non trivial change, am I assuming
the right thing?


http://reviews.llvm.org/D18849

Files:
  include/clang/Lex/HeaderSearch.h
  lib/Basic/FileManager.cpp
  lib/Lex/HeaderSearch.cpp
  test/Modules/Inputs/crash-recovery/Users/bar/a.h
  test/Modules/Inputs/crash-recovery/Users/bar/bar.h
  test/Modules/Inputs/crash-recovery/Users/bar/module.modulemap
  test/Modules/Inputs/crash-recovery/Users/foo/foo.h
  test/Modules/Inputs/crash-recovery/Users/foo/module.modulemap
  test/Modules/crash-vfs-module-redefinition.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18849.53363.patch
Type: text/x-patch
Size: 6725 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160412/88c7b593/attachment.bin>


More information about the cfe-commits mailing list