Skip to content

Commit

Permalink
Improve invalidation scheme. This should fix llvm#53.
Browse files Browse the repository at this point in the history
  • Loading branch information
Xazax-hun committed Aug 28, 2019
1 parent 5eb7821 commit d8497f2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clang/lib/Analysis/LifetimePsetBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,8 @@ class PSetsBuilder : public ConstStmtVisitor<PSetsBuilder, void> {
PSet ArgPS = derefPSet(getPSet(ObjExpr));
for (Variable V : ArgPS.vars())
invalidateVar(
V, 1, InvalidationReason::Modified(ObjExpr->getSourceRange()));
V, V.getOrder(),
InvalidationReason::Modified(ObjExpr->getSourceRange()));
});

// Bind Pointer return value.
Expand Down
13 changes: 13 additions & 0 deletions clang/test/Sema/attr-psets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ struct basic_string_view {

using string_view = basic_string_view<char>;

template <typename T>
struct basic_string {
basic_string(const char*);
basic_string &operator +=(const basic_string& other);
};

template <class T>
struct remove_reference { typedef T type; };
template <class T>
Expand Down Expand Up @@ -956,6 +962,13 @@ void cast(int *p) {
__lifetime_pset(q); // expected-warning {{pset(q) = ((unknown))}}
}

void doNotInvalidateReference(std::vector<std::basic_string<char>> v) {
std::basic_string<char> &r = v[0];
__lifetime_pset_ref(r); // expected-warning {{(*v)}}
r += "aa";
__lifetime_pset_ref(r); // expected-warning {{(*v)}}
}

// Support CXXOperatorCallExpr on non-member function
struct S3;
void operator==(const S3 &A, const S3 &B) { A == B; }
Expand Down

0 comments on commit d8497f2

Please sign in to comment.