[PATCH 3/8] Pass around CorrectionCandidateCallbacks as unique_ptrs so TypoCorrectionConsumer can keep the callback around as long as needed.

David Blaikie dblaikie at gmail.com
Tue Jun 17 14:44:21 PDT 2014


(things might be easier to review in Phab, but I'm not sure how easy
it is to manage a series of dependent patches is there)

TypoCorrectionConsumer's ctor:

"std::unique_ptr<CorrectionCandidateCallback> &CCC," - looks like
you're actually trying to pass ownership here. Pass the unique_ptr by
value to represent this contract.

CorrectTypo function:

"std::unique_ptr<CorrectionCandidateCallback> &&CCC," - also passing
ownership. Passing rvalue ref is certainly more helpful than passing
by const ref, but passing by value is potentially even better. When
passing by value it's unambiguous that the caller will take ownership
and that the callee's unique_ptr will be null. With an rvalue
reference it's still possible for a caller to not take ownership, or
to put some other value in the unique_ptr that the callee is meant to
use... a bad idea, but possible.

Same for ClassifyName's "CCC" parameter.



2014-06-17 14:14 GMT-07:00 Kaelyn Takata <rikka at google.com>:
> ---
>  include/clang/Parse/Parser.h      |  5 ++--
>  include/clang/Sema/Sema.h         | 27 +++++++++----------
>  include/clang/Sema/SemaInternal.h | 18 ++++++-------
>  lib/Parse/ParseExpr.cpp           | 10 +++----
>  lib/Parse/ParseStmt.cpp           |  6 ++---
>  lib/Parse/ParseTentative.cpp      |  8 +++---
>  lib/Parse/Parser.cpp              |  8 +++---
>  lib/Sema/SemaCXXScopeSpec.cpp     |  9 +++----
>  lib/Sema/SemaDecl.cpp             | 57 +++++++++++++++++++--------------------
>  lib/Sema/SemaDeclCXX.cpp          | 27 ++++++++++---------
>  lib/Sema/SemaDeclObjC.cpp         | 21 +++++++--------
>  lib/Sema/SemaExpr.cpp             | 35 ++++++++++++------------
>  lib/Sema/SemaExprMember.cpp       | 15 +++++------
>  lib/Sema/SemaExprObjC.cpp         | 18 ++++++-------
>  lib/Sema/SemaInit.cpp             |  4 +--
>  lib/Sema/SemaLambda.cpp           |  4 +--
>  lib/Sema/SemaLookup.cpp           | 21 ++++++++-------
>  lib/Sema/SemaOpenMP.cpp           |  7 +++--
>  lib/Sema/SemaOverload.cpp         | 23 +++++++++-------
>  lib/Sema/SemaTemplate.cpp         | 17 ++++++------
>  lib/Sema/SemaTemplateVariadic.cpp |  8 +++---
>  21 files changed, 175 insertions(+), 173 deletions(-)
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>



More information about the cfe-commits mailing list