Go to file
Mike Klein a9609ea8c5 turn on -Wreturn-std-move-in-c++11
This CL has a complicated back story, but it's concrete change is
simple, just turning the warning on and converting a bunch of

    return foo;

to

    return std::move(foo);

These changes are exclusively in places where RVO and NRVO do not apply,
so it should not conflict with warnings like -Wpessimizing-move.

Since C++11, when you return a named local and its type doesn't match
the declared return type exactly, there's an implicit std::move()
wrapped around the value (what I'm making explicit here) so the move
constructor gets an opportunity to take precedence over the copy
constructor.  You can read about this implicit move here under the
section "automatic move from local variables and parameters":
https://en.cppreference.com/w/cpp/language/return#Notes.

This situation comes up for us with smart pointers: a function declares
its return type as std::unique_ptr<Base> or sk_sp<Base>, and we return a
std::unique_ptr<Impl> or sk_sp<Impl>.  Those types don't match exactly,
so RVO and NRVO don't come into play.  They've always been going through
move constructors, and that's not changed here, just made explicit.

There was apparently once a bug in the C++11 standard and compilers
implementing that which made these copy instead of move, and then this
sort of code would do a little unnecessary ref/unref dance for sk_sp,
and would entirely fail to compile for uncopyable std::unique_ptr.
These explicit moves ostensibly will make our code more compatible with
those older compilers.

That compatibility alone is, I think, a terrible reason to land this CL.
Like, actively bad.  But... to balance that out, I think the explicit
std::move()s here actually help remind us that RVO/NRVO are not in play,
and remind us we're going to call the move constructor.  So that C++11
standard bug becomes kind of useful for us, in that Clang added this
warning to catch it, and its fix improves readability.

So really read this all as, "warn about implicit std::move() on return".
In the end I think it's just about readability.  I don't really hold any
hope out that we'll become compatible with those older compilers.

Bug: skia:9909
Change-Id: Id596e9261188b6f10e759906af6c95fe303f6ffe
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/271601
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-02-18 23:55:35 +00:00
animations first cut at a checkbox 2009-10-21 19:41:10 +00:00
bench Make SkStrikeCache::Node be SkStrike. 2020-02-15 16:37:58 +00:00
bin [infra] Fix bin/try 2020-01-14 12:05:56 +00:00
build/fuchsia format GN files 2020-02-10 16:32:46 +00:00
build_overrides Update Dawn backend to ToT. This is about 3 months of changes. 2019-10-15 22:26:38 +00:00
dm fix clang-tidy warnings 2020-02-15 16:32:46 +00:00
docker Revert "fiddle - Don't make warnings into errors." 2020-02-07 21:39:38 +00:00
docs/examples basic, untested BGR 1010102 and 101010x 2020-02-11 21:44:57 +00:00
example Revert "Revert "switch to new filltype for SkPath"" 2019-11-26 17:43:14 +00:00
experimental Remove SkTMin and SkTMax 2020-02-07 18:40:09 +00:00
fuzz Remove SkTMin and SkTMax 2020-02-07 18:40:09 +00:00
gm Revert "allow client to pass null if there are no uniforms" 2020-02-18 21:11:45 +00:00
gn turn on -Wreturn-std-move-in-c++11 2020-02-18 23:55:35 +00:00
include Store ProgramDesc on DDLs alongside the GrProgramInfo 2020-02-18 20:35:55 +00:00
infra [infra] Merge SwiftShader into CPU dimensions logic 2020-02-18 15:34:15 +00:00
modules turn on -Wreturn-std-move-in-c++11 2020-02-18 23:55:35 +00:00
platform_tools Reland "GrGLMakeNativeInterface_{iOS,mac,win}: clean up" 2020-01-08 16:55:43 +00:00
resources Skip degenerate contours in glyphs. 2020-02-13 16:22:42 +00:00
samplecode add skotties to cube demo 2020-02-18 18:31:15 +00:00
site Update Skia build instructions in build.md 2020-02-13 22:39:23 +00:00
specs [img-decode] Start on proposed new spec 2019-05-06 17:39:19 +00:00
src turn on -Wreturn-std-move-in-c++11 2020-02-18 23:55:35 +00:00
tests turn on -Wreturn-std-move-in-c++11 2020-02-18 23:55:35 +00:00
third_party let's try to fix nullptr + k 2020-01-31 19:24:21 +00:00
tools turn on -Wreturn-std-move-in-c++11 2020-02-18 23:55:35 +00:00
.clang-format restore .clang-format 2019-03-21 15:52:32 +00:00
.clang-tidy add google-build-namespaces to clang-tidy checks 2018-12-12 16:33:59 +00:00
.gitignore clean up some .gitignores 2019-05-15 19:55:45 +00:00
.gn Basic standalone GN configs. 2016-07-21 12:25:45 -07:00
AUTHORS Optimize SkSL xor where one argument is constant 2019-12-20 14:50:46 +00:00
BUILD.gn Start adding D3D backend 2020-02-18 20:14:15 +00:00
codereview.settings Make uploading to Gerrit the default for Skia 2016-11-09 19:07:56 +00:00
CONTRIBUTING Fix references to https://sites.google.com/site/skiadocs/. 2015-02-03 13:12:54 -02:00
CQ_COMMITTERS Moved committer list to chrome-infra-auth and deleted it from the repo 2015-09-02 13:37:54 -07:00
DEPS Roll SPIRV-Cross to latest (2020-02-14) 2020-02-18 20:11:15 +00:00
go.mod Update Go Deps 2020-02-16 05:23:49 +00:00
go.sum Update Go Deps 2020-02-16 05:23:49 +00:00
LICENSE LICENSE file: clean up 2019-11-22 21:59:03 +00:00
OWNERS add OWNERS file 2017-12-01 19:50:19 +00:00
PRESUBMIT.py Fix path to GN on Windows when running presubmit hooks 2020-02-18 20:41:16 +00:00
public.bzl Reland: Initial checkin of GM verifier framework 2020-02-06 15:01:31 +00:00
README Fix references to https://sites.google.com/site/skiadocs/. 2015-02-03 13:12:54 -02:00
README.chromium Update README.chromium. 2015-06-11 13:19:24 -07:00
RELEASE_NOTES.txt Support adding attributes to PDF document structure nodes. 2020-02-18 18:14:36 +00:00
whitespace.txt Whitespace test 2019-05-18 13:05:29 +00:00

Skia is a complete 2D graphic library for drawing Text, Geometries, and Images.

See full details, and build instructions, at https://skia.org.