[PATCH] D12359: New warning -Wnonconst-parameter when a pointer parameter can be const

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 4 11:52:19 PST 2015


aaron.ballman added inline comments.

================
Comment at: lib/Parse/ParseStmt.cpp:376
@@ -375,3 +375,3 @@
 /// \brief Parse an expression statement.
 StmtResult Parser::ParseExprStatement() {
   // If a case keyword is missing, this is where it should be inserted.
----------------
> I don't know what this "serialized AST" is that you are talking about. All I know is the -ast-dump and that flag is only intended as a debugging aid as far as I know. If I just run "clang -cc1 -Wnonconst-parameter somefile.c" then it does not serialize does it? So what flags do I use to serialize etc?

Anything using PCH or modules will use a serialized AST. http://clang.llvm.org/docs/PCHInternals.html

The basic idea is that these serialize the AST to a file to be later read back in with an ASTReader to represent the same semantic state (entirely skipping the parser).

================
Comment at: lib/Parse/ParseStmt.cpp:392
@@ -391,1 +391,3 @@
 
+  // Mark pointers in the expression as nonconstused.
+  Sema::MarkRNonConstUse(Expr.get());
----------------
non-const-used instead?

================
Comment at: lib/Parse/ParseStmt.cpp:960
@@ -956,1 +959,3 @@
       R = ParseStatementOrDeclaration(Stmts, false);
+      if (!R.isInvalid() && R.get()) {
+        if (ReturnStmt *RS = dyn_cast<ReturnStmt>(R.get())) {
----------------
I think you want isUsable() here instead. Or remove the R.get() and use dyn_cast_or_null below.


http://reviews.llvm.org/D12359





More information about the cfe-commits mailing list