[clang] [C2y] Correctly handle incomplete types in generic selections (PR #141596)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue May 27 07:45:53 PDT 2025


================
@@ -1874,9 +1874,11 @@ ExprResult Sema::CreateGenericSelectionExpr(
 
         if (D != 0) {
           Diag(Types[i]->getTypeLoc().getBeginLoc(), D)
-            << Types[i]->getTypeLoc().getSourceRange()
-            << Types[i]->getType();
-          TypeErrorFound = true;
+              << Types[i]->getTypeLoc().getSourceRange() << Types[i]->getType();
+          if (getDiagnostics().getDiagnosticLevel(
----------------
erichkeane wrote:

Right, I think I'm being unclear.  I'm not criticizing the functionality here, just the interface in which we're using it.  IF the action we care about is always/often "is this an error", then that is the question we should allow ourselves to ask.

So something like:
`getDiagnostics().willEmitError(SemaDiagnosticsBuilder&)` (or, `(S.Diag(...)<<...).isErrorDiag(getDiagnostics())`.

Again, sorta noodling on a 'if we do this more often, we should come up with a more natural interface'.

https://github.com/llvm/llvm-project/pull/141596


More information about the cfe-commits mailing list