[PATCH] D115740: [clang][dataflow] Add simplistic constant-propagation analysis.

Gábor Horváth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 15 09:35:41 PST 2021


xazax.hun added a comment.

This demo looks cool. While I know this is a demo, I think it misses some important features, namely invalidating the value when we take the address of a variable or pass it to a function by non-const reference. 
I'm fine with not supporting those cases, but I'd love to see a comment about that.  Just in case someone wants to use this analysis as a basis for something in production :)



================
Comment at: clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp:99
+
+static constexpr char kVar[] = "var";
+static constexpr char kInit[] = "init";
----------------
Do we need an actual array? I think this would copy `"var"` into a global array. Alternatively, using `static constexpr char* kVar= "var"`, we would just refer to the string in the read only memory. (Or maybe both would behave the same because compiler optimizations?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115740



More information about the cfe-commits mailing list