[PATCH] D29804: Fully qualify (preprend ::) calls to math functions from libc

2017-02-09 Thread Mehdi AMINI via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294696: Fully qualify (preprend ::) calls to math functions 
from libc (authored by mehdi_amini).

Changed prior to commit:
  https://reviews.llvm.org/D29804?vs=87933=87939#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29804

Files:
  libcxx/trunk/include/math.h

Index: libcxx/trunk/include/math.h
===
--- libcxx/trunk/include/math.h
+++ libcxx/trunk/include/math.h
@@ -637,58 +637,58 @@
 #if !(defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY
 float
-abs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);}
+abs(float __lcpp_x) _NOEXCEPT {return ::fabsf(__lcpp_x);}
 
 inline _LIBCPP_INLINE_VISIBILITY
 double
-abs(double __lcpp_x) _NOEXCEPT {return fabs(__lcpp_x);}
+abs(double __lcpp_x) _NOEXCEPT {return ::fabs(__lcpp_x);}
 
 inline _LIBCPP_INLINE_VISIBILITY
 long double
-abs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);}
+abs(long double __lcpp_x) _NOEXCEPT {return ::fabsl(__lcpp_x);}
 #endif // !(defined(_AIX) || defined(__sun__))
 
 // acos
 
 #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
-inline _LIBCPP_INLINE_VISIBILITY float   acos(float __lcpp_x) _NOEXCEPT   {return acosf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return acosl(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY float   acos(float __lcpp_x) _NOEXCEPT   {return ::acosf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return ::acosl(__lcpp_x);}
 #endif
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 typename std::enable_if::value, double>::type
-acos(_A1 __lcpp_x) _NOEXCEPT {return acos((double)__lcpp_x);}
+acos(_A1 __lcpp_x) _NOEXCEPT {return ::acos((double)__lcpp_x);}
 
 // asin
 
 #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
-inline _LIBCPP_INLINE_VISIBILITY float   asin(float __lcpp_x) _NOEXCEPT   {return asinf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return asinl(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY float   asin(float __lcpp_x) _NOEXCEPT   {return ::asinf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return ::asinl(__lcpp_x);}
 #endif
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 typename std::enable_if::value, double>::type
-asin(_A1 __lcpp_x) _NOEXCEPT {return asin((double)__lcpp_x);}
+asin(_A1 __lcpp_x) _NOEXCEPT {return ::asin((double)__lcpp_x);}
 
 // atan
 
 #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
-inline _LIBCPP_INLINE_VISIBILITY float   atan(float __lcpp_x) _NOEXCEPT   {return atanf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return atanl(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY float   atan(float __lcpp_x) _NOEXCEPT   {return ::atanf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return ::atanl(__lcpp_x);}
 #endif
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 typename std::enable_if::value, double>::type
-atan(_A1 __lcpp_x) _NOEXCEPT {return atan((double)__lcpp_x);}
+atan(_A1 __lcpp_x) _NOEXCEPT {return ::atan((double)__lcpp_x);}
 
 // atan2
 
 #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
-inline _LIBCPP_INLINE_VISIBILITY float   atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return atan2f(__lcpp_y, __lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return atan2l(__lcpp_y, __lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY float   atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return ::atan2f(__lcpp_y, __lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return ::atan2l(__lcpp_y, __lcpp_x);}
 #endif
 
 template 
@@ -704,86 +704,86 @@
 typedef typename std::__promote<_A1, _A2>::type __result_type;
 static_assert((!(std::is_same<_A1, __result_type>::value &&
  std::is_same<_A2, __result_type>::value)), "");
-return atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x);
+return ::atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x);
 }
 
 // ceil
 
 #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
-inline _LIBCPP_INLINE_VISIBILITY float   ceil(float __lcpp_x) _NOEXCEPT   {return ceilf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ceill(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY float   ceil(float __lcpp_x) _NOEXCEPT   {return ::ceilf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) 

[PATCH] D29804: Fully qualify (preprend ::) calls to math functions from libc

2017-02-09 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

This LGTM. Although IDK how far we should go to tolerate collisions with 
imported namespace names, especially since `libc` can't (since they can't add 
the ::qualifier).

I've wrote tests for this change here 
. However I 
don't think they can be applied, since libc implementations
may not tolerate them.


https://reviews.llvm.org/D29804



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29804: Fully qualify (preprend ::) calls to math functions from libc

2017-02-09 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini created this revision.

This can cause a compile failure in cases like:

double log(double);
namespace foo {

  namespace log {}

}
using namespace foo;
void bar(int i) {

  log((double)i);

}


https://reviews.llvm.org/D29804

Files:
  libcxx/include/math.h

Index: libcxx/include/math.h
===
--- libcxx/include/math.h
+++ libcxx/include/math.h
@@ -637,58 +637,58 @@
 #if !(defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY
 float
-abs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);}
+abs(float __lcpp_x) _NOEXCEPT {return ::fabsf(__lcpp_x);}
 
 inline _LIBCPP_INLINE_VISIBILITY
 double
-abs(double __lcpp_x) _NOEXCEPT {return fabs(__lcpp_x);}
+abs(double __lcpp_x) _NOEXCEPT {return ::fabs(__lcpp_x);}
 
 inline _LIBCPP_INLINE_VISIBILITY
 long double
-abs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);}
+abs(long double __lcpp_x) _NOEXCEPT {return ::fabsl(__lcpp_x);}
 #endif // !(defined(_AIX) || defined(__sun__))
 
 // acos
 
 #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
-inline _LIBCPP_INLINE_VISIBILITY float   acos(float __lcpp_x) _NOEXCEPT   {return acosf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return acosl(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY float   acos(float __lcpp_x) _NOEXCEPT   {return ::acosf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return ::acosl(__lcpp_x);}
 #endif
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 typename std::enable_if::value, double>::type
-acos(_A1 __lcpp_x) _NOEXCEPT {return acos((double)__lcpp_x);}
+acos(_A1 __lcpp_x) _NOEXCEPT {return ::acos((double)__lcpp_x);}
 
 // asin
 
 #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
-inline _LIBCPP_INLINE_VISIBILITY float   asin(float __lcpp_x) _NOEXCEPT   {return asinf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return asinl(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY float   asin(float __lcpp_x) _NOEXCEPT   {return ::asinf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return ::asinl(__lcpp_x);}
 #endif
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 typename std::enable_if::value, double>::type
-asin(_A1 __lcpp_x) _NOEXCEPT {return asin((double)__lcpp_x);}
+asin(_A1 __lcpp_x) _NOEXCEPT {return ::asin((double)__lcpp_x);}
 
 // atan
 
 #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
-inline _LIBCPP_INLINE_VISIBILITY float   atan(float __lcpp_x) _NOEXCEPT   {return atanf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return atanl(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY float   atan(float __lcpp_x) _NOEXCEPT   {return ::atanf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return ::atanl(__lcpp_x);}
 #endif
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 typename std::enable_if::value, double>::type
-atan(_A1 __lcpp_x) _NOEXCEPT {return atan((double)__lcpp_x);}
+atan(_A1 __lcpp_x) _NOEXCEPT {return ::atan((double)__lcpp_x);}
 
 // atan2
 
 #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
-inline _LIBCPP_INLINE_VISIBILITY float   atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return atan2f(__lcpp_y, __lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return atan2l(__lcpp_y, __lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY float   atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return ::atan2f(__lcpp_y, __lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return ::atan2l(__lcpp_y, __lcpp_x);}
 #endif
 
 template 
@@ -704,86 +704,86 @@
 typedef typename std::__promote<_A1, _A2>::type __result_type;
 static_assert((!(std::is_same<_A1, __result_type>::value &&
  std::is_same<_A2, __result_type>::value)), "");
-return atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x);
+return ::atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x);
 }
 
 // ceil
 
 #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
-inline _LIBCPP_INLINE_VISIBILITY float   ceil(float __lcpp_x) _NOEXCEPT   {return ceilf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ceill(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY float   ceil(float __lcpp_x) _NOEXCEPT   {return ::ceilf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ::ceill(__lcpp_x);}
 #endif
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 typename