[PATCH] D79895: Fix warning about using uninitialized variable as function const reference parameter

Reid Kleckner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 13 13:03:59 PDT 2020


rnk added a comment.

Arthur recently went through the process of refining a diagnostic, so he should be able to help guide you in this if you have more questions.



================
Comment at: clang/lib/Analysis/UninitializedValues.cpp:425
       if ((*I)->getType().isConstQualified())
-        classify((*I), Ignore);
+        classify((*I), Use);
     } else if (isPointerToConst((*I)->getType())) {
----------------
Based on Richard's comment here:
https://bugs.llvm.org/show_bug.cgi?id=45624#c7
... this should be its own classification kind, perhaps `ConstRefUse` or something like that.

This will allow us to put this finding under it's own diagnostic group, maybe named something like -Wuninitialized-const-reference, and then users can enable or disable it separately. It is likely that this new behavior will find many new instances over existing codebases, for example Chromium, that compile with -Wuninitialized enabled. So, if we don't leave a way for users to disable the new warnings (`-Wno-uninitialized-const-ref`), it is harder for them (us) to update the compiler.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79895/new/

https://reviews.llvm.org/D79895





More information about the cfe-commits mailing list