Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp =================================================================== --- clang/lib/Analysis/FlowSensitive/Transfer.cpp +++ clang/lib/Analysis/FlowSensitive/Transfer.cpp @@ -732,7 +732,11 @@ Env.setValue(Loc, *Val); if (Type->isStructureOrClassType()) { - for (auto It : llvm::zip(Type->getAsRecordDecl()->fields(), S->inits())) { + std::vector Fields; + llvm::copy_if( + Type->getAsRecordDecl()->fields(), std::back_inserter(Fields), + [](const FieldDecl *Field) { return !Field->isUnnamedBitfield(); }); + for (auto It : llvm::zip(Fields, S->inits())) { const FieldDecl *Field = std::get<0>(It); assert(Field != nullptr); Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp =================================================================== --- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp +++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp @@ -5080,4 +5080,25 @@ {BuiltinOptions{ContextSensitiveOptions{}}}); } +TEST(TransferTest, UnnamedBitfieldInitializer) { + std::string Code = R"( + struct B {}; + struct A { + unsigned a; + unsigned : 4; + unsigned c; + B b; + }; + void target() { + A a = {}; + A test = a; + (void)test.c; + } + )"; + runDataflow( + Code, + [](const llvm::StringMap> &Results, + ASTContext &ASTCtx) {}); +} + } // namespace