Module progress?

Referring to:

When is this ready?

Thank you.

Not yet. There's still a ton of work to do for C++, as well as performance work and a ton of debugging. It will be a while; this feature is, unfortunately, quite complicated.

  - Doug

How can we help?

Modules is a big feature, and there are a few places where one could help. Some ideas:

  • Diagnostics: when we produce diagnostics that point to a source location within a module (e.g., in a note or macro expansion), the “imported from” backtrace only mentions module names (e.g., “std”) rather than submodule names (“std.tgmath”). We should provide better granularity here.

  • Fix-Its: we may know about a module that has not yet been imported, in which case we should provide a Fix-It to import the module if that would cause ill-formed code to work. For example,

Foo bar(); // error: unknown type name ‘Foo’

could turn into; // error: unknown type name ‘Foo’ is available by importing the module ‘MyLib.Foo’

with a Fix-It that adds ‘import MyLib.Foo’ or '#include <MyLib/Foo.h>" in a reasonable place.

  • Track which explicitly-imported modules have not had any of their declarations used, and produce “unused import” warnings at the end of a translation unit. For example:

import std.tgmath;

int main() {

// warn about unused import ‘std.tgmath’.

The same should work for #includes that have automatically be translated into imports.

  • Fix NamespaceAliasDecl so that it is “redeclarable”. In other words, given

namespace filesystem { }
namespace fs = filesystem;
namespace fs = filesystem;

make sure that the two ‘fs’ declarations are properly chained together, like we do for all other redeclarations.

  • Improve the ‘modularize’ tool I hacked up (sources attached), which attempts to find non-modular behavior in a set of header files. This tool is going to be really important when trying to take an existing (probably horrible) set of system headers and figuring out how to tweak them to be modular enough.

  • Doug

Modularize.cpp (12 KB)

Where are the source and tests for the already existing part?

Where are the source and tests for the already existing part?

Everything is in the Clang repository, with tests in the traditional test/Modules subdirectory.

  • Doug

I’ll check it.