diff options
Diffstat (limited to 'clang/lib')
5 files changed, 27 insertions, 40 deletions
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp index 57169ba..5a49ef1 100644 --- a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp +++ b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp @@ -59,10 +59,9 @@ StorageLocation &DataflowAnalysisContext::createStorageLocation(QualType Type) { : getReferencedFields(Type); for (const FieldDecl *Field : Fields) FieldLocs.insert({Field, &createStorageLocation(Field->getType())}); - return takeOwnership( - std::make_unique<AggregateStorageLocation>(Type, std::move(FieldLocs))); + return create<AggregateStorageLocation>(Type, std::move(FieldLocs)); } - return takeOwnership(std::make_unique<ScalarStorageLocation>(Type)); + return create<ScalarStorageLocation>(Type); } StorageLocation & @@ -90,8 +89,7 @@ DataflowAnalysisContext::getOrCreateNullPointerValue(QualType PointeeType) { auto Res = NullPointerVals.try_emplace(CanonicalPointeeType, nullptr); if (Res.second) { auto &PointeeLoc = createStorageLocation(CanonicalPointeeType); - Res.first->second = - &takeOwnership(std::make_unique<PointerValue>(PointeeLoc)); + Res.first->second = &create<PointerValue>(PointeeLoc); } return *Res.first->second; } @@ -112,8 +110,7 @@ BoolValue &DataflowAnalysisContext::getOrCreateConjunction(BoolValue &LHS, auto Res = ConjunctionVals.try_emplace(makeCanonicalBoolValuePair(LHS, RHS), nullptr); if (Res.second) - Res.first->second = - &takeOwnership(std::make_unique<ConjunctionValue>(LHS, RHS)); + Res.first->second = &create<ConjunctionValue>(LHS, RHS); return *Res.first->second; } @@ -125,15 +122,14 @@ BoolValue &DataflowAnalysisContext::getOrCreateDisjunction(BoolValue &LHS, auto Res = DisjunctionVals.try_emplace(makeCanonicalBoolValuePair(LHS, RHS), nullptr); if (Res.second) - Res.first->second = - &takeOwnership(std::make_unique<DisjunctionValue>(LHS, RHS)); + Res.first->second = &create<DisjunctionValue>(LHS, RHS); return *Res.first->second; } BoolValue &DataflowAnalysisContext::getOrCreateNegation(BoolValue &Val) { auto Res = NegationVals.try_emplace(&Val, nullptr); if (Res.second) - Res.first->second = &takeOwnership(std::make_unique<NegationValue>(Val)); + Res.first->second = &create<NegationValue>(Val); return *Res.first->second; } @@ -144,8 +140,7 @@ BoolValue &DataflowAnalysisContext::getOrCreateImplication(BoolValue &LHS, auto Res = ImplicationVals.try_emplace(std::make_pair(&LHS, &RHS), nullptr); if (Res.second) - Res.first->second = - &takeOwnership(std::make_unique<ImplicationValue>(LHS, RHS)); + Res.first->second = &create<ImplicationValue>(LHS, RHS); return *Res.first->second; } @@ -157,8 +152,7 @@ BoolValue &DataflowAnalysisContext::getOrCreateIff(BoolValue &LHS, auto Res = BiconditionalVals.try_emplace(makeCanonicalBoolValuePair(LHS, RHS), nullptr); if (Res.second) - Res.first->second = - &takeOwnership(std::make_unique<BiconditionalValue>(LHS, RHS)); + Res.first->second = &create<BiconditionalValue>(LHS, RHS); return *Res.first->second; } diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp index fbb8d8a..faeabdc 100644 --- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp +++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp @@ -359,7 +359,7 @@ void Environment::pushCallInternal(const FunctionDecl *FuncDecl, QualType ParamType = Param->getType(); if (ParamType->isReferenceType()) { - auto &Val = takeOwnership(std::make_unique<ReferenceValue>(*ArgLoc)); + auto &Val = create<ReferenceValue>(*ArgLoc); setValue(Loc, Val); } else if (auto *ArgVal = getValue(*ArgLoc)) { setValue(Loc, *ArgVal); @@ -685,7 +685,7 @@ Value *Environment::createValueUnlessSelfReferential( // with integers, and so distinguishing them serves no purpose, but could // prevent convergence. CreatedValuesCount++; - return &takeOwnership(std::make_unique<IntegerValue>()); + return &create<IntegerValue>(); } if (Type->isReferenceType()) { @@ -702,7 +702,7 @@ Value *Environment::createValueUnlessSelfReferential( setValue(PointeeLoc, *PointeeVal); } - return &takeOwnership(std::make_unique<ReferenceValue>(PointeeLoc)); + return &create<ReferenceValue>(PointeeLoc); } if (Type->isPointerType()) { @@ -719,7 +719,7 @@ Value *Environment::createValueUnlessSelfReferential( setValue(PointeeLoc, *PointeeVal); } - return &takeOwnership(std::make_unique<PointerValue>(PointeeLoc)); + return &create<PointerValue>(PointeeLoc); } if (Type->isStructureOrClassType() || Type->isUnionType()) { @@ -739,8 +739,7 @@ Value *Environment::createValueUnlessSelfReferential( Visited.erase(FieldType.getCanonicalType()); } - return &takeOwnership( - std::make_unique<StructValue>(std::move(FieldValues))); + return &create<StructValue>(std::move(FieldValues)); } return nullptr; diff --git a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp index aebe326..a91ec5d 100644 --- a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp +++ b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp @@ -221,9 +221,9 @@ void setHasValue(Value &OptionalVal, BoolValue &HasValueVal) { /// Creates a symbolic value for an `optional` value using `HasValueVal` as the /// symbolic value of its "has_value" property. StructValue &createOptionalValue(Environment &Env, BoolValue &HasValueVal) { - auto OptionalVal = std::make_unique<StructValue>(); - setHasValue(*OptionalVal, HasValueVal); - return Env.takeOwnership(std::move(OptionalVal)); + auto &OptionalVal = Env.create<StructValue>(); + setHasValue(OptionalVal, HasValueVal); + return OptionalVal; } /// Returns the symbolic value that represents the "has_value" property of the @@ -312,8 +312,8 @@ StorageLocation *maybeInitializeOptionalValueMember(QualType Q, return nullptr; auto &ValueLoc = Env.createStorageLocation(Ty); Env.setValue(ValueLoc, *ValueVal); - auto ValueRef = std::make_unique<ReferenceValue>(ValueLoc); - OptionalVal.setProperty("value", Env.takeOwnership(std::move(ValueRef))); + auto &ValueRef = Env.create<ReferenceValue>(ValueLoc); + OptionalVal.setProperty("value", ValueRef); return &ValueLoc; } diff --git a/clang/lib/Analysis/FlowSensitive/Transfer.cpp b/clang/lib/Analysis/FlowSensitive/Transfer.cpp index d255d27..aa8fe90 100644 --- a/clang/lib/Analysis/FlowSensitive/Transfer.cpp +++ b/clang/lib/Analysis/FlowSensitive/Transfer.cpp @@ -237,7 +237,7 @@ public: Env.setStorageLocation(*S, *DeclLoc); } else { auto &Loc = Env.createStorageLocation(*S); - auto &Val = Env.takeOwnership(std::make_unique<ReferenceValue>(*DeclLoc)); + auto &Val = Env.create<ReferenceValue>(*DeclLoc); Env.setStorageLocation(*S, Loc); Env.setValue(Loc, Val); } @@ -276,8 +276,7 @@ public: // FIXME: reuse the ReferenceValue instead of creating a new one. if (auto *InitExprLoc = Env.getStorageLocation(*InitExpr, SkipPast::Reference)) { - auto &Val = - Env.takeOwnership(std::make_unique<ReferenceValue>(*InitExprLoc)); + auto &Val = Env.create<ReferenceValue>(*InitExprLoc); Env.setValue(Loc, Val); } } else if (auto *InitExprVal = Env.getValue(*InitExpr, SkipPast::None)) { @@ -423,8 +422,8 @@ public: auto &Loc = Env.createStorageLocation(*S); Env.setStorageLocation(*S, Loc); - Env.setValue(Loc, Env.takeOwnership(std::make_unique<ReferenceValue>( - SubExprVal->getPointeeLoc()))); + Env.setValue(Loc, + Env.create<ReferenceValue>(SubExprVal->getPointeeLoc())); break; } case UO_AddrOf: { @@ -437,8 +436,7 @@ public: break; auto &PointerLoc = Env.createStorageLocation(*S); - auto &PointerVal = - Env.takeOwnership(std::make_unique<PointerValue>(*PointeeLoc)); + auto &PointerVal = Env.create<PointerValue>(*PointeeLoc); Env.setStorageLocation(*S, PointerLoc); Env.setValue(PointerLoc, PointerVal); break; @@ -468,8 +466,7 @@ public: auto &Loc = Env.createStorageLocation(*S); Env.setStorageLocation(*S, Loc); - Env.setValue(Loc, Env.takeOwnership( - std::make_unique<PointerValue>(*ThisPointeeLoc))); + Env.setValue(Loc, Env.create<PointerValue>(*ThisPointeeLoc)); } void VisitReturnStmt(const ReturnStmt *S) { @@ -523,8 +520,7 @@ public: } else { auto &Loc = Env.createStorageLocation(*S); Env.setStorageLocation(*S, Loc); - Env.setValue(Loc, Env.takeOwnership( - std::make_unique<ReferenceValue>(*VarDeclLoc))); + Env.setValue(Loc, Env.create<ReferenceValue>(*VarDeclLoc)); } return; } @@ -558,8 +554,7 @@ public: } else { auto &Loc = Env.createStorageLocation(*S); Env.setStorageLocation(*S, Loc); - Env.setValue( - Loc, Env.takeOwnership(std::make_unique<ReferenceValue>(MemberLoc))); + Env.setValue(Loc, Env.create<ReferenceValue>(MemberLoc)); } } diff --git a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp index 8e821e5..ad250c4 100644 --- a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp +++ b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp @@ -312,8 +312,7 @@ void builtinTransferInitializer(const CFGInitializer &Elt, if (Member->getType()->isReferenceType()) { auto &MemberLoc = ThisLoc.getChild(*Member); - Env.setValue(MemberLoc, Env.takeOwnership(std::make_unique<ReferenceValue>( - *InitStmtLoc))); + Env.setValue(MemberLoc, Env.create<ReferenceValue>(*InitStmtLoc)); } else { auto &MemberLoc = ThisLoc.getChild(*Member); Env.setValue(MemberLoc, *InitStmtVal); |