mirror of
https://github.com/intel/llvm.git
synced 2026-01-15 04:17:17 +08:00
[clang][Lifetimes] Fix false positive warning from BUG 49342
Differential Revision: https://reviews.llvm.org/D97605
This commit is contained in:
@@ -7521,6 +7521,8 @@ static bool pathOnlyInitializesGslPointer(IndirectLocalPath &Path) {
|
||||
continue;
|
||||
if (It->Kind == IndirectLocalPathEntry::AddressOf)
|
||||
continue;
|
||||
if (It->Kind == IndirectLocalPathEntry::LifetimeBoundCall)
|
||||
continue;
|
||||
return It->Kind == IndirectLocalPathEntry::GslPointerInit ||
|
||||
It->Kind == IndirectLocalPathEntry::GslReferenceInit;
|
||||
}
|
||||
|
||||
@@ -171,12 +171,22 @@ struct basic_string_view {
|
||||
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<int>::iterator noFalsePositiveWithVectorOfPointers() {
|
||||
std::vector<std::vector<int>::iterator> iters;
|
||||
return iters.at(0);
|
||||
}
|
||||
|
||||
void testForBug49342()
|
||||
{
|
||||
auto it = std::iter<char>{} - 2; // Used to be false positive.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user