llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Jay Foad (jayfoad)

<details>
<summary>Changes</summary>

These backends reported errors by calling SrcMgr.PrintMessage directly,
which does not increment ErrorsPrinted, so clang-tblgen would print an
error but still exit with status 0 and write its output file.

Co-Authored-By: Claude Opus 5.5 (1M context) &lt;noreply@<!-- 
-->anthropic.com&gt;


---
Full diff: https://github.com/llvm/llvm-project/pull/232299.diff


4 Files Affected:

- (added) clang/test/TableGen/html-named-character-references-errors.td (+11) 
- (modified) clang/test/TableGen/redefined-group.td (+3-1) 
- (modified) 
clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp (+1-2) 
- (modified) clang/utils/TableGen/ClangDiagnosticsEmitter.cpp (+4-6) 


``````````diff
diff --git a/clang/test/TableGen/html-named-character-references-errors.td 
b/clang/test/TableGen/html-named-character-references-errors.td
new file mode 100644
index 00000000000000..138f9ffa521c36
--- /dev/null
+++ b/clang/test/TableGen/html-named-character-references-errors.td
@@ -0,0 +1,11 @@
+// RUN: not clang-tblgen -gen-clang-comment-html-named-character-references %s 
-o /dev/null 2>&1 | FileCheck %s
+
+class NCR<string spelling, int codePoint> {
+  string Spelling = spelling;
+  int CodePoint = codePoint;
+}
+
+def : NCR<"valid", 0x41>;
+def : NCR<"invalid", 0x110000>;
+// CHECK: html-named-character-references-errors.td:[[@LINE-1]]:1: error: 
invalid code point
+// CHECK: 1 errors.
diff --git a/clang/test/TableGen/redefined-group.td 
b/clang/test/TableGen/redefined-group.td
index 558c6775ef4bf4..093fbd6c398a3d 100644
--- a/clang/test/TableGen/redefined-group.td
+++ b/clang/test/TableGen/redefined-group.td
@@ -1,4 +1,4 @@
-// RUN: clang-tblgen -gen-clang-diag-groups -I%S %s -o /dev/null 2>&1 | 
FileCheck %s
+// RUN: not clang-tblgen -gen-clang-diag-groups -I%S %s -o /dev/null 2>&1 | 
FileCheck %s
 include "DiagnosticBase.inc"
 
 def NamedGroup : DiagGroup<"a">;
@@ -41,3 +41,5 @@ def InGroupF4 : Warning<"">, InGroup<DiagGroup<"f">>;
 // CHECK: redefined-group.td:[[@LINE-7]]:5: note: also implicitly defined here
 // CHECK: redefined-group.td:[[@LINE-6]]:5: note: also implicitly defined here
 // CHECK: redefined-group.td:[[@LINE-4]]:5: note: also implicitly defined here
+
+// CHECK: 6 errors.
diff --git 
a/clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp 
b/clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp
index e5eec5e7ca8d46..e0445929530d44 100644
--- a/clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp
+++ b/clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp
@@ -56,8 +56,7 @@ void clang::EmitClangCommentHTMLNamedCharacterReferences(
     CLiteral.clear();
     CLiteral.append("return ");
     if (!translateCodePointToUTF8(CodePoint, CLiteral)) {
-      SrcMgr.PrintMessage(Tag->getLoc().front(), SourceMgr::DK_Error,
-                          Twine("invalid code point"));
+      PrintError(Tag->getLoc().front(), "invalid code point");
       continue;
     }
     CLiteral.append(";");
diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp 
b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
index 2fe7dc64fbdc6d..dfd9463a435a86 100644
--- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -196,9 +196,8 @@ static void groupDiagnostics(ArrayRef<const Record *> Diags,
 
       SMLoc Loc = Def->getLoc().front();
       if (First) {
-        SrcMgr.PrintMessage(Loc, SourceMgr::DK_Error,
-                            Twine("group '") + Group.first +
-                                "' is defined more than once");
+        PrintError(Loc, Twine("group '") + Group.first +
+                            "' is defined more than once");
         First = false;
       } else {
         SrcMgr.PrintMessage(Loc, SourceMgr::DK_Note, "also defined here");
@@ -211,9 +210,8 @@ static void groupDiagnostics(ArrayRef<const Record *> Diags,
 
       SMLoc Loc = Diag->getLoc().front();
       if (First) {
-        SrcMgr.PrintMessage(Loc, SourceMgr::DK_Error,
-                            Twine("group '") + Group.first +
-                                "' is implicitly defined more than once");
+        PrintError(Loc, Twine("group '") + Group.first +
+                            "' is implicitly defined more than once");
         First = false;
       } else {
         SrcMgr.PrintMessage(Loc, SourceMgr::DK_Note,

``````````

</details>


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

Reply via email to