[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
Thu Nov 12 22:16:45 PST 2026


================
@@ -2006,15 +2006,30 @@ ExprResult Sema::BuildExpressionTrait(ExpressionTrait ET, SourceLocation KWLoc,
       ExpressionTraitExpr(KWLoc, ET, Queried, Value, RParen, Context.BoolTy);
 }
 
+// std::is_trivially_copy_constructible<T> is
+// __is_trivially_constructible(T, const T &). It is not in the generated table
+// because the std trait takes only T. Callers tell it apart from the builtin
+// by the std name recorded in ExtractedTypeTraitInfo.
+static constexpr StringRef TriviallyCopyConstructibleName =
+    "is_trivially_copy_constructible";
+
 static std::optional<TypeTrait> StdNameToTypeTrait(StringRef Name) {
+  if (Name == TriviallyCopyConstructibleName)
+    return TT_IsTriviallyConstructible;
   return llvm::StringSwitch<std::optional<TypeTrait>>(Name)
 #define EMIT_STD_NAME_CASES
 #include "clang/Basic/BuiltinTraits.inc"
       .Default(std::nullopt);
 }
 
-using ExtractedTypeTraitInfo =
-    std::optional<std::pair<TypeTrait, llvm::SmallVector<QualType, 1>>>;
+struct TypeTraitInfo {
+  TypeTrait Trait;
+  llvm::SmallVector<QualType, 1> Args;
+  // The std:: name (without "_v") if the trait was spelled as a library trait,
+  // empty if it was spelled as a builtin.
----------------
pesdarshan wrote:

for the builtin path what should `StdName` hold? Should `__is_trivially_constructible(T, const T&)` report `is_trivially_copy_constructible` so the case needs only one check?

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


More information about the cfe-commits mailing list