[clang] [Clang] Added explanation why is_trivially_copy_constructible evaluated to false (PR #225487)

Darshan N via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 3 02:53:04 PST 2026


================
@@ -2071,11 +2087,13 @@ static ExtractedTypeTraitInfo ExtractTypeTraitFromExpression(const Expr *E) {
     const TemplateDecl *D = Ts->getTemplateName().getAsTemplateDecl();
     if (!D || !D->isInStdNamespace())
       return std::nullopt;
-    Trait = StdNameToTypeTrait(D->getIdentifier()->getName());
+    StringRef Name = D->getIdentifier()->getName();
+    Trait = StdNameToTypeTrait(Name);
     if (!Trait)
       return std::nullopt;
     for (const auto &Arg : Ts->template_arguments())
       Args.push_back(Arg.getAsType());
+    AddCopySourceArg(D->getASTContext(), Name);
----------------
pesdarshan wrote:

If I leave the args as they are the `std::` spellings stop getting the new notes. I tried it with only `T` and the `-std` test fails with 12 expected notes not seen. That's because of how `DiagnoseTypeTraitDetails` works. It only counts `TT_IsTriviallyConstructible` as a copy check when it gets two args, `T` and `const T&`. If it only gets `T` it does nothing. So I add the second arg and the existing check works as is. I didn't want to make the one-arg case count as a copy check, since `__is_trivially_constructible(T)` is valid on its own and means default construction. That one shouldn't get this note. Do you have a different approach in mind? I'm happy to change things. Thanks!

https://github.com/llvm/llvm-project/pull/225487


More information about the cfe-commits mailing list