[clang] [C] Warn on uninitialized const objects (PR #137166)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 24 13:01:48 PDT 2025
================
@@ -6496,6 +6496,17 @@ static bool canPerformArrayCopy(const InitializedEntity &Entity) {
return false;
}
+static const FieldDecl *getConstField(const RecordDecl *RD) {
+ for (const FieldDecl *FD : RD->fields()) {
+ QualType QT = FD->getType();
+ if (QT.isConstQualified())
+ return FD;
+ if (const auto *RD = QT->getAsRecordDecl())
+ return getConstField(RD);
----------------
shafik wrote:
Should we check the return value and if it is `nullptr` continue the outer for?
https://github.com/llvm/llvm-project/pull/137166
More information about the cfe-commits
mailing list