================
@@ -165,12 +166,29 @@ void EnumInitialValueCheck::registerMatchers(MatchFinder 
*Finder) {
 
 void EnumInitialValueCheck::check(const MatchFinder::MatchResult &Result) {
   if (const auto *Enum = Result.Nodes.getNodeAs<EnumDecl>("inconsistent")) {
-    const DiagnosticBuilder Diag =
-        diag(
-            Enum->getBeginLoc(),
-            "initial values in enum '%0' are not consistent, consider explicit 
"
-            "initialization of all, none or only the first enumerator")
-        << getName(Enum);
+    llvm::SmallVector<StringRef, 4> UninitializedNames;
+    for (const EnumConstantDecl *ECD : Enum->enumerators())
+      if (ECD->getInitExpr() == nullptr && ECD->getDeclName())
+        UninitializedNames.push_back(ECD->getName());
+
+    llvm::SmallString<256> Message;
+    Message = "initial values in enum '%0' are not consistent, "
+              "consider explicit initialization of all, none or "
+              "only the first enumerator";
+    if (!UninitializedNames.empty()) {
+      Message += " (uninitialized enumerators: ";
+      for (size_t I = 0; I < UninitializedNames.size(); ++I) {
+        if (I > 0)
+          Message += (I < UninitializedNames.size() - 1) ? ", " : " and ";
+        Message += "'";
+        Message += UninitializedNames[I];
+        Message += "'";
----------------
gamesh411 wrote:

Updated the implementation, notes are more structured approach, and even the 
code seems cleaner this way.

https://github.com/llvm/llvm-project/pull/176485
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to