[PATCH] D125402: [clang][diag] warn if function returns class type by-const-value

2022-06-14 Thread Namgoo Lee via Phabricator via cfe-commits
nlee updated this revision to Diff 437011. nlee added a comment. Warn if: - It is an assignment expression AND - RHS is a function call expression AND - The function returns by-const-value of a class or struct type AND - The class or struct has non-trivial move assignment operator Removed `defau

[PATCH] D125402: [clang][diag] warn if function returns class type by-const-value

2022-06-12 Thread Namgoo Lee via Phabricator via cfe-commits
nlee added inline comments. Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:6632 + "const qualifying the return value prevents move semantics">, + InGroup, DefaultIgnore; +def note_pessimizing_return_by_const : Note< aaron.ballman wrote: > Given th

[PATCH] D125402: [clang][diag] warn if function returns class type by-const-value

2022-06-08 Thread Namgoo Lee via Phabricator via cfe-commits
nlee updated this revision to Diff 435113. nlee added a comment. Updated diff to pass clang-format test. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D125402/new/ https://reviews.llvm.org/D125402 Files: clang/include/clang/Basic/DiagnosticGroups.td clang/include/clang/Basic/Diagnos

[PATCH] D125402: [clang][diag] warn if function returns class type by-const-value

2022-06-07 Thread Namgoo Lee via Phabricator via cfe-commits
nlee updated this revision to Diff 434842. nlee added a comment. After some investigation, I think it is not always explicit that removing `const` makes any improvements when we are "constructing." For example, in this case , the two codes which differ in the re

[PATCH] D125402: [clang][diag] warn if function returns class type by-const-value

2022-05-17 Thread Namgoo Lee via Phabricator via cfe-commits
nlee added a comment. Thank you for your reviews, and sorry for the mess in my last comment. I'm new to clang/Phabricator and trying to get used to it :) Comment at: clang/lib/Sema/SemaType.cpp:5203 + T.isConstQualified() && + T->isStructureOrClassType()) { +

[PATCH] D125402: [clang][diag] warn if function returns class type by-const-value

2022-05-16 Thread Namgoo Lee via Phabricator via cfe-commits
nlee added a comment. In D125402#3508845 , @aaron.ballman wrote: > Thank you for working on this new diagnostic! We don't typically add new > diagnostics that are off by default unless they're for pedantic diagnostics > or are reasonably expected to be

[PATCH] D125402: [clang][diag] warn if function returns class type by-const-value

2022-05-11 Thread Namgoo Lee via Phabricator via cfe-commits
nlee created this revision. nlee added a reviewer: lattner. Herald added a project: All. nlee requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Returning class or struct by value with const qualifier should be avoided since it prevents move