[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
Wed Dec 14 14:38:04 PST 2016


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

Here is the Decl dump in the end of `ReadDeclRecord` for each Decl before it fails:

- ParmVarDecl 0x7ffe23053b20 </Users/bruno/Dev/srcs/llvm/tools/clang/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/math.h:1:9> col:12 in libc.math hidden 'int' -- FunctionDecl 0x7ffe23053a48 </Users/bruno/Dev/srcs/llvm/tools/clang/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/math.h:1:1, col:12> col:5 in libc.math hidden abs 'int (int)' `-ParmVarDecl 0x7ffe23053b20 <col:9> col:12 in libc.math hidden 'int' -- TypedefDecl 0x7ffe23053f90 </Users/bruno/Dev/srcs/llvm/build/bin/../lib/clang/4.0.0/include/stddef.h:51:1, col:26> col:26 in libc.stddef hidden ptrdiff_t 'long' `-BuiltinType 0x7ffe2300f9f0 'long' -- TypedefDecl 0x7ffe23054018 </Users/bruno/Dev/srcs/llvm/tools/clang/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/sys/_types/_ptrdiff_t.h:3:1, col:15> col:15 in libc.POSIX.sys.types hidden ptrdiff_t 'int *' `-PointerType 0x7ffe23054070 'int *' imported `-BuiltinType 0x7ffe2300f9d0 'int' While building module 'libc++' imported from /Users/bruno/Dev/srcs/llvm/tools/clang/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stdio.h:4: In file included from <module-includes>:1: In file included from /Users/bruno/Dev/srcs/llvm/tools/clang/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/math.h:7: In file included from /Users/bruno/Dev/srcs/llvm/tools/clang/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/type_traits:4: /Users/bruno/Dev/srcs/llvm/tools/clang/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/cstddef:7:9: error: unknown type name 'ptrdiff_t' typedef ptrdiff_t my_ptrdiff_t; ^

So, both `libc.stddef` and `libc++.stddef`, answer for the builtin `/Users/bruno/Dev/srcs/llvm/build/bin/../lib/clang/4.0.0/include/stddef.h`. `libc++.stddef` is being currently built, that's why the definition isn't there yet. Looks like the right thing is to indeed re-enter `/Users/bruno/Dev/srcs/llvm/build/bin/../lib/clang/4.0.0/include/stddef.h`, so it can be put in `libc++.stddef`.

I've updated the patch to do what you suggested in the first place: track modules per header. Can you comment on the general approach? One consideration though; it's expensive to have the additional SmallVector per each HeaderFileInfo, since most headers (except builtins and textuals) aren't actually expected to have more than one associated Module. Maybe a map from HFIs to associated modules, but I'm not sure where to store it, suggestions? The Decl's loaded from the AST now make more sense (output resuming from the previously failing point):

  TypedefDecl 0x7f81ed0f0840 </Users/bruno/Dev/srcs/llvm/build/bin/../lib/clang/4.0.0/include/stddef.h:62:1, col:23> col:23 in libc.stddef hidden size_t 'unsigned long'
  `-BuiltinType 0x7f81ed0ab890 'unsigned long'
  --
  TypedefDecl 0x7f81ed0f0938 </Users/bruno/Dev/srcs/llvm/build/bin/../lib/clang/4.0.0/include/stddef.h:76:1, col:23> col:23 in libc.stddef hidden rsize_t 'unsigned long'
  `-BuiltinType 0x7f81ed0ab890 'unsigned long'
  --
  TypedefDecl 0x7f81ed076778 </Users/bruno/Dev/srcs/llvm/build/bin/../lib/clang/4.0.0/include/stddef.h:51:1, col:26> col:26 in libc.stddef hidden ptrdiff_t 'long'
  `-BuiltinType 0x7f81ed03a9f0 'long'
  --
  TypedefDecl 0x7f81ed076800 </Users/bruno/Dev/srcs/llvm/tools/clang/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/sys/_types/_ptrdiff_t.h:3:1, col:15> col:15 in libc.POSIX.sys.types hidden ptrdiff_t 'int *'
  `-PointerType 0x7f81ed076850 'int *' imported
    `-BuiltinType 0x7f81ed03a9d0 'int'
  --
  TypedefDecl 0x7f81ed0768b0 prev 0x7f81ed076778 </Users/bruno/Dev/srcs/llvm/build/bin/../lib/clang/4.0.0/include/stddef.h:51:1, col:26> col:26 in libc++.stddef hidden referenced ptrdiff_t 'long'
  `-BuiltinType 0x7f81ed03a9f0 'long'
  --
  TypedefDecl 0x7f81ed0769d0 </Users/bruno/Dev/srcs/llvm/tools/clang/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/cstddef:7:1, col:19> col:19 in libc++.cstddef hidden my_ptrdiff_t 'ptrdiff_t':'long'
  `-TypedefType 0x7f81ed076920 'ptrdiff_t' sugar imported
    |-Typedef 0x7f81ed0768b0 'ptrdiff_t'
    `-BuiltinType 0x7f81ed03a9f0 'long'


https://reviews.llvm.org/D26267

Files:
  include/clang/Lex/HeaderSearch.h
  include/clang/Lex/Preprocessor.h
  lib/Lex/HeaderSearch.cpp
  lib/Serialization/ASTReader.cpp
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/cstddef
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/math.h
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/module.modulemap
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stddef.h
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/type_traits
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/module.modulemap
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stddef.h
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/sys/_types/_ptrdiff_t.h
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/sys/_types/_types.h
  test/Modules/builtin-import.mm

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26267.81478.patch
Type: text/x-patch
Size: 9161 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161214/f86df569/attachment.bin>


More information about the cfe-commits mailing list