diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -6580,7 +6580,7 @@ return llvm::StringSwitch(Callee->getName()) .Cases("begin", "rbegin", "cbegin", "crbegin", true) .Cases("end", "rend", "cend", "crend", true) - .Cases("c_str", "data", "get", true) + .Cases("c_str", "data", "get", "value", true) // Map and set types. .Cases("find", "equal_range", "lower_bound", "upper_bound", true) .Default(false); @@ -6591,7 +6591,7 @@ OO == OverloadedOperatorKind::OO_Star; } return llvm::StringSwitch(Callee->getName()) - .Cases("front", "back", "at", true) + .Cases("front", "back", "at", "top", true) .Default(false); } return false; diff --git a/clang/test/Sema/warn-lifetime-analysis-nocfg.cpp b/clang/test/Sema/warn-lifetime-analysis-nocfg.cpp --- a/clang/test/Sema/warn-lifetime-analysis-nocfg.cpp +++ b/clang/test/Sema/warn-lifetime-analysis-nocfg.cpp @@ -169,6 +169,12 @@ optional(); optional(const T&); T &operator*(); + T &value(); +}; + +template +struct stack { + T &top(); }; } @@ -204,6 +210,8 @@ int &r = *std::optional(); // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}} int &r2 = *std::optional(5); // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}} int &r3 = std::vector().at(3); // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}} + int &r4 = std::optional(5).value(); // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}} + int &r5 = std::stack().top(); // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}} } std::vector getTempVec();