<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/64916>64916</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            RecursiveASTVisitor (RAV) fails to visit the initializer of a bitfield
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          smcpeak
      </td>
    </tr>
</table>

<pre>
    For this example:

```
struct S {
 int x : 8 = 123;
};
```

`RecursiveASTVisitor` will visit the `8` but not the `123`.

This is observed when using Clang+LLVM-16.0.0 and when using a trunk source build from 2023-07-14.

The following diff is sufficient to fix the bug in my testing:

```
--- clang/AST/RecursiveASTVisitor.h.orig
+++ clang/AST/RecursiveASTVisitor.h
@@ -2124,7 +2124,7 @@
 TRY_TO(TraverseDeclaratorHelper(D));
   if (D->isBitField())
 TRY_TO(TraverseStmt(D->getBitWidth()));
-  else if (D->hasInClassInitializer())
+  if (D->hasInClassInitializer())
 TRY_TO(TraverseStmt(D->getInClassInitializer()));
 })

```

although I would think an automated test should be added as well.

I believe the problem was introduced in commit 6b8e3c02ca44f, when the possibility of initialized bitfields was added, but the logic in `RecursiveASTVisitor` was not updated.

(To be clear, I'm not volunteering to fix this issue, I'm just reporting it.)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVEtv6zYT_TX0ZiBDohRZXmgRx5_xBbhFgcRI0VXBx0iaG0o0-LCT_vqCimMnxb1pCxC2-DgzZx5nhPfUT4gtu9mwm-1CxDBY1_pRHVA8L6TVr-3OOggDecAXMR4MsvKW5VuWv__W-XnNWx9cVAEega02bydAU4AXYOUtNMDKLRS8ZOX5kq221-_Pli6HD6ii83TE28f9E3kK1rE6hxMZA8e0hzAgsDpv0rGMASZ7OUvO6nz50eQ-BUMerPTojqjhNOAE0dPUw50RU8_45tu3p1-yol7myxzE9OmJ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