[PATCH] D97605: [Lifetimes] Fix false positive warning from BUG 49342
Gábor Horváth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 27 08:16:09 PST 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdd6738d93de1: [clang][Lifetimes] Fix false positive warning from BUG 49342 (authored by xazax.hun).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97605/new/
https://reviews.llvm.org/D97605
Files:
clang/lib/Sema/SemaInit.cpp
clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
Index: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
===================================================================
--- clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
+++ clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
@@ -171,12 +171,22 @@
const T *begin() const;
};
+template<class _Mystr> struct iter {
+ iter& operator-=(int);
+
+ iter operator-(int _Off) const {
+ iter _Tmp = *this;
+ return _Tmp -= _Off;
+ }
+};
+
template<typename T>
struct basic_string {
basic_string();
basic_string(const T *);
const T *c_str() const;
operator basic_string_view<T> () const;
+ using const_iterator = iter<T>;
};
@@ -455,3 +465,8 @@
std::vector<std::vector<int>::iterator> iters;
return iters.at(0);
}
+
+void testForBug49342()
+{
+ auto it = std::iter<char>{} - 2; // Used to be false positive.
+}
Index: clang/lib/Sema/SemaInit.cpp
===================================================================
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -7521,6 +7521,8 @@
continue;
if (It->Kind == IndirectLocalPathEntry::AddressOf)
continue;
+ if (It->Kind == IndirectLocalPathEntry::LifetimeBoundCall)
+ continue;
return It->Kind == IndirectLocalPathEntry::GslPointerInit ||
It->Kind == IndirectLocalPathEntry::GslReferenceInit;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97605.326904.patch
Type: text/x-patch
Size: 1358 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210227/c3ee18c9/attachment.bin>
More information about the cfe-commits
mailing list