[cfe-commits] [PATCH] Improve diagnostic for -Wmissing-noreturn

Chandler Carruth chandlerc at google.com
Wed Aug 31 02:03:12 PDT 2011

Thanks for the test case updates that helps me.

+        if (ReturnsVoid && !HasNoReturn &&
CD.diag_NeverFallThroughOrReturn) {
+          if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+            assert(CD.diag_NeverFallThroughOrReturn ==
+                   diag::warn_suggest_noreturn_function);

As a consequence, I don't really think we need the assertions here. The test
cases would actually assert if an improper diagnostic went in, I think my
initial confusion was merely due to a lack of test cases for me to look at
and understand how this worked. =D

+            S.Diag(Compound->getLBracLoc(),
+                   CD.diag_NeverFallThroughOrReturn) <<
+          } else {
+            assert(CD.diag_NeverFallThroughOrReturn ==
+                   diag::warn_suggest_noreturn_block);

Same here. Essentially, it undermines the abstraction I think this code
wants to derive from the CD.diag_... field.

+            S.Diag(Compound->getLBracLoc(),
+                   CD.diag_NeverFallThroughOrReturn);
+          }
+        }

Regarding just using "<< FD;" above:

On Mon, Aug 29, 2011 at 3:49 PM, Joerg Sonnenberger <joerg at britannica.bec.de
> wrote:

> It doesn't, not exactly sure why. I'm using getNameAsString() now.

I'm confused as well. It should work! ;]

I patched this in and dug into it. It seems the operator overload just
didn't work for pointers to const objects. I've fixed that, and updated the
Diagnostic code to use pointers to const objects as well (and be cleaner

I've committed your patch with the above changes (and some style tweaks)
along with the bug fixes to the diagnostic builder code in r138854. Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110831/e79ea654/attachment.html>

More information about the cfe-commits mailing list