Skip to content

Commit

Permalink
[clang][dataflow][NFC] Eliminate unnecessary helper stripReference().
Browse files Browse the repository at this point in the history
`QualType::getNonReferenceType()` does the same thing.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D149744
  • Loading branch information
martinboehme committed May 4, 2023
1 parent d9b92c4 commit c849843
Showing 1 changed file with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,6 @@ BoolValue *getHasValue(Environment &Env, Value *OptionalVal) {
return nullptr;
}

/// If `Type` is a reference type, returns the type of its pointee. Otherwise,
/// returns `Type` itself.
QualType stripReference(QualType Type) {
return Type->isReferenceType() ? Type->getPointeeType() : Type;
}

/// Returns true if and only if `Type` is an optional type.
bool isOptionalType(QualType Type) {
if (!Type->isRecordType())
Expand Down Expand Up @@ -339,7 +333,7 @@ StorageLocation *maybeInitializeOptionalValueMember(QualType Q,
return &ValueLoc;
}

auto Ty = stripReference(Q);
auto Ty = Q.getNonReferenceType();
auto *ValueVal = Env.createValue(Ty);
if (ValueVal == nullptr)
return nullptr;
Expand Down Expand Up @@ -493,11 +487,13 @@ BoolValue &valueOrConversionHasValue(const FunctionDecl &F, const Expr &E,
assert(F.getTemplateSpecializationArgs() != nullptr);
assert(F.getTemplateSpecializationArgs()->size() > 0);

const int TemplateParamOptionalWrappersCount = countOptionalWrappers(
*MatchRes.Context,
stripReference(F.getTemplateSpecializationArgs()->get(0).getAsType()));
const int ArgTypeOptionalWrappersCount =
countOptionalWrappers(*MatchRes.Context, stripReference(E.getType()));
const int TemplateParamOptionalWrappersCount =
countOptionalWrappers(*MatchRes.Context, F.getTemplateSpecializationArgs()
->get(0)
.getAsType()
.getNonReferenceType());
const int ArgTypeOptionalWrappersCount = countOptionalWrappers(
*MatchRes.Context, E.getType().getNonReferenceType());

// Check if this is a constructor/assignment call for `optional<T>` with
// argument of type `U` such that `T` is constructible from `U`.
Expand Down

0 comments on commit c849843

Please sign in to comment.