Demangle.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright 2018-present Facebook, Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include <folly/detail/Demangle.h>
  17. // Do not include <libiberty.h> (binutils) and <string.h> (glibc) in the same
  18. // translation unit since they contain conflicting declarations for the symbol
  19. // `basename`.
  20. //
  21. // So we extract the inclusion of `<demangle.h>` which includes `<libiberty.h>`
  22. // to here, isolating it.
  23. #if FOLLY_DETAIL_HAVE_DEMANGLE_H
  24. #include <demangle.h>
  25. #endif
  26. namespace folly {
  27. namespace detail {
  28. int cplus_demangle_v3_callback_wrapper(
  29. char const* const mangled,
  30. void (*const cbref)(char const*, std::size_t, void*),
  31. void* const opaque) {
  32. #if FOLLY_DETAIL_HAVE_DEMANGLE_H
  33. auto const options = DMGL_PARAMS | DMGL_ANSI | DMGL_TYPES;
  34. return cplus_demangle_v3_callback(mangled, options, cbref, opaque);
  35. #else
  36. return 0;
  37. #endif
  38. }
  39. } // namespace detail
  40. } // namespace folly