r298013 - [Headers] Reapply: Add #include_next for tgmath.h on Darwin
Bruno Cardoso Lopes via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 16 16:19:00 PDT 2017
Author: bruno
Date: Thu Mar 16 18:19:00 2017
New Revision: 298013
URL: http://llvm.org/viewvc/llvm-project?rev=298013&view=rev
Log:
[Headers] Reapply: Add #include_next for tgmath.h on Darwin
Reapply r289181 but rename the include guard to avoid
conflict with the one from Darwin.
Allow darwin to provide additional definitions and implementation
specifc values for tgmath.h on Apple platforms.
rdar://problem/19019845
Added:
cfe/trunk/test/Headers/Inputs/usr/include/math.h
cfe/trunk/test/Headers/Inputs/usr/include/tgmath.h
cfe/trunk/test/Headers/tgmath-darwin.c
Modified:
cfe/trunk/lib/Headers/tgmath.h
Modified: cfe/trunk/lib/Headers/tgmath.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/tgmath.h?rev=298013&r1=298012&r2=298013&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/tgmath.h (original)
+++ cfe/trunk/lib/Headers/tgmath.h Thu Mar 16 18:19:00 2017
@@ -22,12 +22,21 @@
*
\*===----------------------------------------------------------------------===*/
-#ifndef __TGMATH_H
-#define __TGMATH_H
+#ifndef __CLANG_TGMATH_H
+#define __CLANG_TGMATH_H
/* C99 7.22 Type-generic math <tgmath.h>. */
#include <math.h>
+/*
+ * Allow additional definitions and implementation-defined values on Apple
+ * platforms. This is done after #include <math.h> to avoid depcycle conflicts
+ * between libcxx and darwin in C++ modules builds.
+ */
+#if defined(__APPLE__) && __STDC_HOSTED__ && __has_include_next(<tgmath.h>)
+# include_next <tgmath.h>
+#else
+
/* C++ handles type genericity with overloading in math.h. */
#ifndef __cplusplus
#include <complex.h>
@@ -1371,4 +1380,5 @@ static long double
#undef _TG_ATTRS
#endif /* __cplusplus */
-#endif /* __TGMATH_H */
+#endif /* __has_include_next */
+#endif /* __CLANG_TGMATH_H */
Added: cfe/trunk/test/Headers/Inputs/usr/include/math.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/Inputs/usr/include/math.h?rev=298013&view=auto
==============================================================================
--- cfe/trunk/test/Headers/Inputs/usr/include/math.h (added)
+++ cfe/trunk/test/Headers/Inputs/usr/include/math.h Thu Mar 16 18:19:00 2017
@@ -0,0 +1 @@
+// math.h
Added: cfe/trunk/test/Headers/Inputs/usr/include/tgmath.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/Inputs/usr/include/tgmath.h?rev=298013&view=auto
==============================================================================
--- cfe/trunk/test/Headers/Inputs/usr/include/tgmath.h (added)
+++ cfe/trunk/test/Headers/Inputs/usr/include/tgmath.h Thu Mar 16 18:19:00 2017
@@ -0,0 +1,4 @@
+#ifndef SYS_TGMATH_H
+#define SYS_TGMATH_H
+
+#endif /* SYS_TGMATH_H */
Added: cfe/trunk/test/Headers/tgmath-darwin.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/tgmath-darwin.c?rev=298013&view=auto
==============================================================================
--- cfe/trunk/test/Headers/tgmath-darwin.c (added)
+++ cfe/trunk/test/Headers/tgmath-darwin.c Thu Mar 16 18:19:00 2017
@@ -0,0 +1,12 @@
+// REQUIRES: system-darwin
+// RUN: %clang -target x86_64-apple-darwin10 -fsyntax-only -std=c11 -isysroot %S/Inputs %s
+#include <tgmath.h>
+
+// Test the #include_next of tgmath.h works on Darwin.
+#ifndef SYS_TGMATH_H
+ #error "SYS_TGMATH_H not defined"
+#endif
+
+#ifndef __CLANG_TGMATH_H
+ #error "__CLANG_TGMATH_H not defined"
+#endif
More information about the cfe-commits
mailing list