[PATCH] D96942: [CSSPGO][llvm-profgen] Fix gcc Wcast-qual warning (NFC)

Yang Fan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 18 00:32:38 PST 2021


nullptr.cpp created this revision.
Herald added a subscriber: wenlei.
nullptr.cpp requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

GCC warning:

  [3397/3703] Building CXX object tools/llvm-profgen/CMakeFiles/llvm-profgen.dir/llvm-profgen.cpp.o
  In file included from /llvm-project/llvm/include/llvm/ADT/STLExtras.h:19,
                   from /llvm-project/llvm/include/llvm/ADT/StringRef.h:12,
                   from /llvm-project/llvm/include/llvm/ADT/Twine.h:13,
                   from /llvm-project/llvm/tools/llvm-profgen/ErrorHandling.h:12,
                   from /llvm-project/llvm/tools/llvm-profgen/llvm-profgen.cpp:13:
  /llvm-project/llvm/include/llvm/ADT/Optional.h: In instantiation of ‘void llvm::optional_detail::OptionalStorage<T, <anonymous> >::emplace(Args&& ...) [with Args = {const std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, llvm::sampleprof::LineLocation>}; T = const std::pair<std::__cxx11::basic_string<char>, llvm::sampleprof::LineLocation>; bool <anonymous> = false]’:
  /llvm-project/llvm/include/llvm/ADT/Optional.h:79:7:   required from ‘constexpr llvm::optional_detail::OptionalStorage<T, <anonymous> >::OptionalStorage(llvm::optional_detail::OptionalStorage<T, <anonymous> >&&) [with T = const std::pair<std::__cxx11::basic_string<char>, llvm::sampleprof::LineLocation>; bool <anonymous> = false]’
  /llvm-project/llvm/include/llvm/ADT/Optional.h:253:13:   required from here
  /llvm-project/llvm/include/llvm/ADT/Optional.h:113:12: warning: cast from type ‘const std::pair<std::__cxx11::basic_string<char>, llvm::sampleprof::LineLocation>*’ to type ‘void*’ casts away qualifiers [-Wcast-qual]
    113 |     ::new ((void *)std::addressof(value)) T(std::forward<Args>(args)...);
        |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
  [3398/3703] Building CXX object tools/llvm-profgen/CMakeFiles/llvm-profgen.dir/PerfReader.cpp.o
  In file included from /llvm-project/llvm/include/llvm/ADT/STLExtras.h:19,
                   from /llvm-project/llvm/include/llvm/ADT/StringRef.h:12,
                   from /llvm-project/llvm/include/llvm/ADT/Twine.h:13,
                   from /llvm-project/llvm/tools/llvm-profgen/ErrorHandling.h:12,
                   from /llvm-project/llvm/tools/llvm-profgen/PerfReader.h:11,
                   from /llvm-project/llvm/tools/llvm-profgen/PerfReader.cpp:8:
  /llvm-project/llvm/include/llvm/ADT/Optional.h: In instantiation of ‘void llvm::optional_detail::OptionalStorage<T, <anonymous> >::emplace(Args&& ...) [with Args = {const std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, llvm::sampleprof::LineLocation>}; T = const std::pair<std::__cxx11::basic_string<char>, llvm::sampleprof::LineLocation>; bool <anonymous> = false]’:
  /llvm-project/llvm/include/llvm/ADT/Optional.h:79:7:   required from ‘constexpr llvm::optional_detail::OptionalStorage<T, <anonymous> >::OptionalStorage(llvm::optional_detail::OptionalStorage<T, <anonymous> >&&) [with T = const std::pair<std::__cxx11::basic_string<char>, llvm::sampleprof::LineLocation>; bool <anonymous> = false]’
  /llvm-project/llvm/include/llvm/ADT/Optional.h:253:13:   required from here
  /llvm-project/llvm/include/llvm/ADT/Optional.h:113:12: warning: cast from type ‘const std::pair<std::__cxx11::basic_string<char>, llvm::sampleprof::LineLocation>*’ to type ‘void*’ casts away qualifiers [-Wcast-qual]
    113 |     ::new ((void *)std::addressof(value)) T(std::forward<Args>(args)...);
        |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
  [3399/3703] Building CXX object tools/llvm-profgen/CMakeFiles/llvm-profgen.dir/ProfiledBinary.cpp.o
  In file included from /llvm-project/llvm/include/llvm/ADT/STLExtras.h:19,
                   from /llvm-project/llvm/include/llvm/ADT/ArrayRef.h:15,
                   from /llvm-project/llvm/include/llvm/ADT/DenseMapInfo.h:18,
                   from /llvm-project/llvm/include/llvm/ADT/DenseMap.h:16,
                   from /llvm-project/llvm/include/llvm/ADT/DenseSet.h:16,
                   from /llvm-project/llvm/include/llvm/ProfileData/SampleProf.h:17,
                   from /llvm-project/llvm/tools/llvm-profgen/CallContext.h:12,
                   from /llvm-project/llvm/tools/llvm-profgen/ProfiledBinary.h:12,
                   from /llvm-project/llvm/tools/llvm-profgen/ProfiledBinary.cpp:9:
  /llvm-project/llvm/include/llvm/ADT/Optional.h: In instantiation of ‘void llvm::optional_detail::OptionalStorage<T, <anonymous> >::emplace(Args&& ...) [with Args = {const std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, llvm::sampleprof::LineLocation>}; T = const std::pair<std::__cxx11::basic_string<char>, llvm::sampleprof::LineLocation>; bool <anonymous> = false]’:
  /llvm-project/llvm/include/llvm/ADT/Optional.h:79:7:   required from ‘constexpr llvm::optional_detail::OptionalStorage<T, <anonymous> >::OptionalStorage(llvm::optional_detail::OptionalStorage<T, <anonymous> >&&) [with T = const std::pair<std::__cxx11::basic_string<char>, llvm::sampleprof::LineLocation>; bool <anonymous> = false]’
  /llvm-project/llvm/include/llvm/ADT/Optional.h:253:13:   required from here
  /llvm-project/llvm/include/llvm/ADT/Optional.h:113:12: warning: cast from type ‘const std::pair<std::__cxx11::basic_string<char>, llvm::sampleprof::LineLocation>*’ to type ‘void*’ casts away qualifiers [-Wcast-qual]
    113 |     ::new ((void *)std::addressof(value)) T(std::forward<Args>(args)...);
        |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
  [3404/3703] Building CXX object tools/llvm-profgen/CMakeFiles/llvm-profgen.dir/ProfileGenerator.cpp.o
  In file included from /llvm-project/llvm/include/llvm/ADT/STLExtras.h:19,
                   from /llvm-project/llvm/include/llvm/ADT/StringRef.h:12,
                   from /llvm-project/llvm/include/llvm/ADT/Twine.h:13,
                   from /llvm-project/llvm/tools/llvm-profgen/ErrorHandling.h:12,
                   from /llvm-project/llvm/tools/llvm-profgen/ProfileGenerator.h:11,
                   from /llvm-project/llvm/tools/llvm-profgen/ProfileGenerator.cpp:9:
  /llvm-project/llvm/include/llvm/ADT/Optional.h: In instantiation of ‘void llvm::optional_detail::OptionalStorage<T, <anonymous> >::emplace(Args&& ...) [with Args = {const std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, llvm::sampleprof::LineLocation>}; T = const std::pair<std::__cxx11::basic_string<char>, llvm::sampleprof::LineLocation>; bool <anonymous> = false]’:
  /llvm-project/llvm/include/llvm/ADT/Optional.h:79:7:   required from ‘constexpr llvm::optional_detail::OptionalStorage<T, <anonymous> >::OptionalStorage(llvm::optional_detail::OptionalStorage<T, <anonymous> >&&) [with T = const std::pair<std::__cxx11::basic_string<char>, llvm::sampleprof::LineLocation>; bool <anonymous> = false]’
  /llvm-project/llvm/include/llvm/ADT/Optional.h:253:13:   required from here
  /llvm-project/llvm/include/llvm/ADT/Optional.h:113:12: warning: cast from type ‘const std::pair<std::__cxx11::basic_string<char>, llvm::sampleprof::LineLocation>*’ to type ‘void*’ casts away qualifiers [-Wcast-qual]
    113 |     ::new ((void *)std::addressof(value)) T(std::forward<Args>(args)...);
        |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96942

Files:
  llvm/tools/llvm-profgen/ProfiledBinary.h


Index: llvm/tools/llvm-profgen/ProfiledBinary.h
===================================================================
--- llvm/tools/llvm-profgen/ProfiledBinary.h
+++ llvm/tools/llvm-profgen/ProfiledBinary.h
@@ -226,7 +226,7 @@
     return FuncStartAddrMap[Offset];
   }
 
-  Optional<const FrameLocation> getInlineLeafFrameLoc(uint64_t Offset) {
+  Optional<FrameLocation> getInlineLeafFrameLoc(uint64_t Offset) {
     const auto &Stack = getFrameLocationStack(Offset);
     if (Stack.empty())
       return {};


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96942.324552.patch
Type: text/x-patch
Size: 511 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210218/79659dba/attachment.bin>


More information about the llvm-commits mailing list