[clang] [Clang] Added explanation why is_trivially_copy_constructible evaluated to false (PR #225487)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 12 23:29:22 PST 2026
================
@@ -2794,6 +2882,22 @@ void Sema::DiagnoseTypeTraitDetails(const Expr *E) {
case UTT_IsAbstract:
DiagnoseNonAbstractReason(*this, E->getBeginLoc(), Args[0]);
break;
+ case TT_IsTriviallyConstructible:
+ if (StdName == TriviallyCopyConstructibleName) {
+ // std::is_trivially_copy_constructible<T>
+ if (Args.size() == 1)
+ DiagnoseNonTriviallyCopyConstructibleReason(*this, E->getBeginLoc(),
+ Args[0]);
+ } else if (StdName.empty() && Args.size() == 2) {
+ // Builtin: check that the second arg is `cv T &` (copy-construction
+ // shape).
+ if (const auto *LVRef = Args[1]->getAs<LValueReferenceType>()) {
+ if (Context.hasSameUnqualifiedType(Args[0], LVRef->getPointeeType()))
+ DiagnoseNonTriviallyCopyConstructibleReason(*this, E->getBeginLoc(),
+ Args[0]);
+ }
+ }
----------------
zyn0217 wrote:
I think we should only handle the first branch for now, thanks.
https://github.com/llvm/llvm-project/pull/225487
More information about the cfe-commits
mailing list