[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 20 13:21:14 PST 2024


================
@@ -1111,6 +1116,10 @@ void CXXRecordDecl::addedMember(Decl *D) {
     } else if (!T.isCXX98PODType(Context))
       data().PlainOldData = false;
 
+    if (Field->hasAttr<ExplicitInitAttr>() && !Field->hasInClassInitializer()) {
+      setHasUninitializedExplicitInitFields(true);
+    }
----------------
higher-performance wrote:

Oh wow, done -- thanks for the catch, looks like this slipped through. I thought I had a test for this, but it seems like the test didn't catch it because there was _also_ an explicit field that _didn't_ have an in-class initializer, so the flag was set anyway. I modified another one of the tests to account for this too.

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


More information about the cfe-commits mailing list