[PATCH] Module use declarations (II)

Daniel Jasper djasper at google.com
Thu Aug 29 07:31:16 PDT 2013


Hi rsmith, doug.gregor, chandlerc,

I have picked up this patch form Lawrence (http://llvm-reviews.chandlerc.com/D1063) and only did minor changes. Hopefully, I can pick up the original spot in the review queue ;-).

>From the original change description (updated as appropriate):
This patch adds a check that ensures that modules only use modules they have so declared.

USER INTERFACE

Add a statement on intended module use to the module.map grammar. This statement is modeled on the existing export statement.

    use wildcard-module-id

This enforcement is off by default, but may be turned on with the new option -fmodules-decluse.

When enforcing the module semantics, we also need to consider a source file part of a module. This is achieved with a compiler option -fmodule-source-for=<module-id>.

The compiler at present only applies restrictions to the module directly being built. To add indirect checks, use the option -fmodules-indirect-check. This indirect flag is also applied to private header use.

IMPLEMENTATION

The module checking is done from within Preprocessor::LookupFile, and the code there has been refactored.

The -fmodule-source-for=<module-id> value is stored in ModuleMap::SourceModule.

The type ExportDecl in Module has been generalized to WildModuleRef, likewise UnresolvedExportDecl to UnresolvedWildModuleRef. There has been refactoring to avoid duplicate code in using these types.

MISSING

This patch is missing serialization of 'use' declarations, for which I need some feedback. See the FIXME comments.

The error messages from module compilations are suppressed, which makes diagnosing issues tough.

http://llvm-reviews.chandlerc.com/D1546

Files:
  docs/Modules.rst
  include/clang/Basic/DiagnosticLexKinds.td
  include/clang/Basic/LangOptions.def
  include/clang/Basic/LangOptions.h
  include/clang/Basic/Module.h
  include/clang/Driver/Options.td
  include/clang/Lex/ModuleMap.h
  include/clang/Lex/Preprocessor.h
  lib/Basic/Module.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Lex/HeaderSearch.cpp
  lib/Lex/ModuleMap.cpp
  lib/Lex/PPDirectives.cpp
  lib/Sema/Sema.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/Modules/Inputs/declare-use/a.h
  test/Modules/Inputs/declare-use/b.h
  test/Modules/Inputs/declare-use/c.h
  test/Modules/Inputs/declare-use/d.h
  test/Modules/Inputs/declare-use/e.h
  test/Modules/Inputs/declare-use/f.h
  test/Modules/Inputs/declare-use/g.h
  test/Modules/Inputs/declare-use/g1.h
  test/Modules/Inputs/declare-use/h.h
  test/Modules/Inputs/declare-use/h1.h
  test/Modules/Inputs/declare-use/module.map
  test/Modules/declare-use1.cpp
  test/Modules/declare-use2.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1546.1.patch
Type: text/x-patch
Size: 37690 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130829/a41b5b51/attachment.bin>


More information about the cfe-commits mailing list