This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions
ClosedPublic

Authored by gtbercea on May 15 2019, 8:11 AM.

Diff Detail

Repository
rC Clang

Event Timeline

gtbercea created this revision.May 15 2019, 8:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 15 2019, 8:11 AM
Hahnfeld added inline comments.
lib/Headers/__clang_cuda_device_functions.h
1486

If I recall correctly, __cplusplus is not defined in C mode, so both GCC and Clang will issue a warning with -Wundef.

Maybe this can be solved with something similar to:

#ifdef __cplusplus
#define cpp_version __cplusplus
#else
#define cpp_version 0
#endif

(to avoid repetition of #if defined(__cplusplus) && __cplusplus >= 201703L)

Missing defined(__cplusplus) to avoid warnings and we have to resolve the two new includes. Otherwise, this looks good. So, if you "fix" both go ahead and commit, if not, lets discuss.

lib/Headers/__clang_cuda_device_functions.h
1486

I dislike defining the version and advice to repeating #if defined(__cplusplus) && __cplusplus >= 201703L)

lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
24 ↗(On Diff #199613)

I ask this question again and again, do we need them now? Why?

tra added inline comments.May 15 2019, 9:43 AM
lib/Headers/__clang_cuda_device_functions.h
1486

I agree with @jdoerfert.
If that's needed too often, we can move c++-only functions under one global #if defined(__cplusplus).

1584–1591

This is typically dealt with by defining and using a macro which would expand to noexcept or to nothing.
E.g. something like what libcxx does.

This should reduce the number of needed #if.

gtbercea updated this revision to Diff 199651.May 15 2019, 11:46 AM
  • Refactor.
gtbercea marked an inline comment as done.May 15 2019, 11:49 AM
gtbercea added inline comments.
lib/Headers/__clang_cuda_device_functions.h
1486

@tra is this closer to what you want?

tra added a comment.May 15 2019, 12:12 PM

LGTM.

lib/Headers/__clang_cuda_cmath.h
42

I think the change is useful for CUDA, too, but I'm OK keeping it OpenMP-specific for now. I can enable it for CUDA later.

jdoerfert requested changes to this revision.May 15 2019, 12:15 PM
jdoerfert added inline comments.
lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
24 ↗(On Diff #199613)

Why did you add these includes?

This revision now requires changes to proceed.May 15 2019, 12:15 PM
gtbercea updated this revision to Diff 199662.May 15 2019, 12:44 PM
gtbercea marked an inline comment as done.
  • Remove included headers.
jdoerfert accepted this revision.May 15 2019, 12:49 PM
This revision is now accepted and ready to land.May 15 2019, 12:49 PM
This revision was automatically updated to reflect the committed changes.