[PATCH] D26267: [Modules] Include builtins with #include instead of #import for ObjC

Bruno Cardoso Lopes via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 2 10:08:41 PST 2016


bruno added a comment.

> The right thing to do would be to track the set of headers whose #import / #include-with-#pragma-once is
>  visible, and only skip inclusions if there is a *visible* #import / #include-with-#pragma-once of that header.

This makes sense, but the situation is a bit more weird with the builtins: at the time clang skips entering /Users/bruno/Dev/srcs/llvm/debug/bin/../lib/clang/4.0.0/include/stddef.h because there's already a #import associated with  it, clang tries to get the module, in this case it finds "libc++.stddef", but `makeModuleVisible` does not export the contents
of /Users/bruno/Dev/srcs/llvm/debug/bin/../lib/clang/4.0.0/include/stddef.h:

  // If we don't need to enter the file, stop now.
  if (!ShouldEnter) {
    // If this is a module import, make it visible if needed.
    if (auto *M = SuggestedModule.getModule()) {
      makeModuleVisible(M, HashLoc);
      ...
    }
    return;
  }
  
  (lldb) p M->dump()
  module stddef   [system] {
    header "/Users/bruno/Dev/srcs/llvm/debug/bin/../lib/clang/4.0.0/include/stddef.h"
    textual header "stddef.h"
    export *
  }

Is this what it's supposed to happen with a (textual) builtin header? It seems to me that since the first #import was done after collecting the headers to build the module, the content should already been present/available in the AST for the module.


https://reviews.llvm.org/D26267





More information about the cfe-commits mailing list