[PATCH] D16930: Improve literal operator parameter diagnostics.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 8 12:44:42 PST 2016


rsmith added a comment.

Thanks, this looks good. I think we can make the control flow a little more obvious by moving the `return true;`s right after we emit each diagnostic, and that also lets us remove the `goto`.


================
Comment at: lib/Sema/SemaDeclCXX.cpp:11769
@@ +11768,3 @@
+static bool
+isValidLiteralOperatorTemplateParameterList(Sema &SemaRef,
+                                            FunctionTemplateDecl *TpDecl) {
----------------
If you're going to issue diagnostics from here, it'd be clearer to name this `checkLiteralOperator[...]`.

================
Comment at: lib/Sema/SemaDeclCXX.cpp:11846
@@ +11845,3 @@
+
+    goto FinishedParams;
+
----------------
Drop this `goto`, we fall through to the same place.

================
Comment at: lib/Sema/SemaDeclCXX.cpp:11886
@@ -11847,10 +11885,3 @@
 
-    // Otherwise it must be a pointer to const; let's strip those qualifiers.
-    const PointerType *PT = T->getAs<PointerType>();
-    if (!PT)
-      goto FinishedParams;
-    T = PT->getPointeeType();
-    if (!T.isConstQualified() || T.isVolatileQualified())
-      goto FinishedParams;
-    T = T.getUnqualifiedType();
+    return true;
 
----------------
Move the `return true;` up into the individual cases that bail out, and remove the `goto` from the success cases.


http://reviews.llvm.org/D16930





More information about the cfe-commits mailing list