Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • L linux
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Kirill Smelkov
  • linux
  • Repository
  • linux
  • tools
  • perf
  • util
  • c++
  • clang.cpp
Find file BlameHistoryPermalink
  • Arnaldo Carvalho de Melo's avatar
    perf clang: Do not use 'return std::move(something)' · d34cecfb
    Arnaldo Carvalho de Melo authored Feb 04, 2019
    It prevents copy elision, generating this warning when building with
    fedora:rawhide's clang:
    
      clang version 7.0.1 (Fedora 7.0.1-2.fc30)
      Target: x86_64-unknown-linux-gnu
      Thread model: posix
      InstalledDir: /usr/bin
      Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/9
      Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/9
      Selected GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/9
      Candidate multilib: .;@m64
      Candidate multilib: 32;@m32
      Selected multilib: .;@m64
    
      $ make -C tools/perf CC=clang LIBCLANGLLVM=1
      <SNIP>
      util/c++/clang.cpp: In function 'std::unique_ptr<llvm::SmallVectorImpl<char> > perf::getBPFObjectFromModule(llvm::Module*)':
      util/c++/clang.cpp:163:18: error: moving a local object in a return statement prevents copy elision [-Werror=pessimizing-move]
        163 |  return std::move(Buffer);
            |         ~~~~~~~~~^~~~~~~~
      util/c++/clang.cpp:163:18: note: remove 'std::move' call
      cc1plus: all warnings being treated as errors
      <SNIP>
    
    References:
    
      http://www.cplusplus.com/forum/general/186411/#msg908572
      https://en.cppreference.com/w/cpp/language/return#Notes
      https://en.cppreference.com/w/cpp/language/copy_elision
    
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Wang Nan <wangnan0@huawei.com>
    Link: https://lkml.kernel.org/n/tip-lehqf5x5q96l0o8myhb6blz6@git.kernel.org
    
    
    Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    d34cecfb
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7