Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

Commit

Permalink
clang/lib/Analysis/LifetimeTypeCategory.cpp: Only infer implicit Owne…
Browse files Browse the repository at this point in the history
…r/Pointer when DerefType can be deduced
  • Loading branch information
mgehre committed Aug 21, 2019
1 parent 8be2abf commit 0d59356
Showing 1 changed file with 31 additions and 25 deletions.
56 changes: 31 additions & 25 deletions clang/lib/Analysis/LifetimeTypeCategory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,31 +227,37 @@ static TypeClassification classifyTypeCategoryImpl(const Type *T) {
return {TypeCategory::Pointer, Pointee};
}

if (auto Cat = classifyStd(T))
return {*Cat, Pointee};

// Every type that satisfies the standard Container requirements.
if (satisfiesContainerRequirements(R))
return {TypeCategory::Owner, Pointee};

// Every type that provides unary * or -> and has a user-provided destructor.
// (Example: unique_ptr.)
if (hasDerefOperations(R) && !R->hasTrivialDestructor())
return {TypeCategory::Owner, Pointee};

// Every type that satisfies the Ranges TS Range concept.
if (satisfiesRangeConcept(R))
return {TypeCategory::Pointer, Pointee};

// Every type that satisfies the standard Iterator requirements. (Example:
// regex_iterator.), see https://en.cppreference.com/w/cpp/named_req/Iterator
if (satisfiesIteratorRequirements(R))
return {TypeCategory::Pointer, Pointee};

// Every type that provides unary * or -> and does not have a user-provided
// destructor. (Example: span.)
if (hasDerefOperations(R) && R->hasTrivialDestructor())
return {TypeCategory::Pointer, Pointee};
// Do not attempt to infer implicit Pointer/Owner if we cannot deduce
// the DerefType.
if (!Pointee.isNull()) {

if (auto Cat = classifyStd(T))
return {*Cat, Pointee};

// Every type that satisfies the standard Container requirements.
if (satisfiesContainerRequirements(R))
return {TypeCategory::Owner, Pointee};

// Every type that provides unary * or -> and has a user-provided
// destructor. (Example: unique_ptr.)
if (hasDerefOperations(R) && !R->hasTrivialDestructor())
return {TypeCategory::Owner, Pointee};

// Every type that satisfies the Ranges TS Range concept.
if (satisfiesRangeConcept(R))
return {TypeCategory::Pointer, Pointee};

// Every type that satisfies the standard Iterator requirements. (Example:
// regex_iterator.), see
// https://en.cppreference.com/w/cpp/named_req/Iterator
if (satisfiesIteratorRequirements(R))
return {TypeCategory::Pointer, Pointee};

// Every type that provides unary * or -> and does not have a user-provided
// destructor. (Example: span.)
if (hasDerefOperations(R) && R->hasTrivialDestructor())
return {TypeCategory::Pointer, Pointee};
}

// Every closure type of a lambda that captures by reference.
if (R->isLambda()) {
Expand Down

0 comments on commit 0d59356

Please sign in to comment.