[PATCH] D66164: [LifetimeAnalysis] Support std::stack::top() and std::optional::value()

Matthias Gehre via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 13 15:40:05 PDT 2019


mgehre marked 3 inline comments as done.
mgehre added inline comments.


================
Comment at: clang/lib/Sema/SemaInit.cpp:6583
         .Cases("end", "rend", "cend", "crend", true)
-        .Cases("c_str", "data", "get", true)
+        .Cases("c_str", "data", "get", "value", true)
         // Map and set types.
----------------
xazax.hun wrote:
> Oh, this one needs to be updated, as `value` returns a reference not a pointer. 
Yes, I noticed the same.


================
Comment at: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp:172
   T &operator*();
+  T &value();
+};
----------------
xazax.hun wrote:
> mgehre wrote:
> > xazax.hun wrote:
> > > I actually was a bit lazy when I added these tests. Both `value` and `operator*` is overloaded on `&&`. But if you do not feel like adjusting the tests this is fine, I can do it myself later :)
> > I'll change it to use the `&` variant in the test - the `&&` cannot dangle as far as I understand.
> It can!
> 
> Consider the following code:
> 
> ```
> int &&r = *std::optional(5);
> // r dangles here.
> ```
Oh, sure!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66164





More information about the cfe-commits mailing list