[PATCH] D77168: Add a flag to debug automatic variable initialization

JF Bastien via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 4 08:12:14 PDT 2020


jfb added a comment.

Can you add a test for the diagnostic firing after the correct number of initializations? This should include a few types of auto-init, including VLAs.



================
Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:489
+  "-ftrivial-auto-var-init-stop-after=* has been enabled to limit the number of times ftrivial-auto-var-init=zero/pattern gets applied.">,
+  InGroup<DiagGroup<"trivial-auto-var-init-stop-after">>;
+
----------------
I don't think this is sufficiently clear: automatic variable initialization is now disabled because ftrivial-auto-var-init-stop-after has reached its limit.


================
Comment at: clang/lib/CodeGen/CGDecl.cpp:1684
+      if (CGM.stopAutoInit())
+        return;
+      if (trivialAutoVarInit == LangOptions::TrivialAutoVarInitKind::Zero)
----------------
I'd rather repeat this than fallthrought and repeat the condition in if/else.


================
Comment at: clang/lib/CodeGen/CodeGenModule.h:1390
+      if (NumAutoVarInit >= StopAfter)
+        return true;
+      ++NumAutoVarInit;
----------------
The first time this returns true is when the diagnostic should be emitted.


================
Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3092
+          Args.getLastArg(options::OPT_ftrivial_auto_var_init_stop_after)) {
+    D.Diag(diag::warn_drv_trivial_auto_var_init_stop_after_enabled);
+    A->claim();
----------------
Not here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77168





More information about the cfe-commits mailing list