[PATCH] D43871: [modules] No longer include stdlib.h from mm_malloc.h.

Raphael Isemann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 28 06:26:20 PST 2018


teemperor created this revision.
teemperor added reviewers: rsmith, v.g.vassilev, chandlerc.

The GNU C library includes headers from the `_Builtin_intrinsics` module. As the `_Builtin_intrinsics` module via
the `mm_malloc.h` header also includes the `stdlib.h` header from libc, we get a cyclic dependency with
`-fmodules` enabled. The best way to solve this is seems to be removing the `stdlib.h` include from `mm_malloc.h`
and make the redeclarations in there work without the include.

This patch is doing this in two steps:

1. It reverts some of the changes done in r119958 which re-added the include to `mm_malloc.h` and removed the forward declarations.

2. It expands the workaround in Sema::CheckEquivalentExceptionSpec to also work in the case where we first declare a function with a missing empty exception specification and then redeclare it with an empty exception specification.

The second part is necessary because the current workaround only works in the case where the redeclaration
is missing an empty exception specification and the `#include <stdlib.h>` before our redeclaration ensured that
we always have our declarations in this expected order.

I compiled a few projects with this patch (curl, ncnn, opencv, openjpeg, scummvm, sqlite, zlib), and it doesn't
seem to break any compilation there.


Repository:
  rC Clang

https://reviews.llvm.org/D43871

Files:
  lib/Headers/mm_malloc.h
  lib/Sema/SemaExceptionSpec.cpp
  test/CXX/except/except.spec/libc-empty-except-sys/libc-empty-except.h
  test/CXX/except/except.spec/libc-empty-except.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43871.136288.patch
Type: text/x-patch
Size: 8631 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180228/da08aa86/attachment-0001.bin>


More information about the cfe-commits mailing list