29#include "llvm/ADT/DenseMap.h"
30#include "llvm/ADT/DenseSet.h"
31#include "llvm/ADT/MapVector.h"
32#include "llvm/ADT/STLExtras.h"
33#include "llvm/ADT/ScopeExit.h"
34#include "llvm/ADT/SetVector.h"
35#include "llvm/ADT/SmallVector.h"
36#include "llvm/Support/ErrorHandling.h"
43#define DEBUG_TYPE "dataflow"
50class SimpleBoolModel final :
public Environment::BoolModel {
54 static bool classof(
const BoolModel *M) {
58 std::unique_ptr<BoolModel> clone()
const override {
59 return std::make_unique<SimpleBoolModel>(*
this);
62 void onFork()
override {}
64 void assume(
const Formula &F)
override {
67 unsigned PrevSize = AtomToVal.size();
73 assumeFormula(
true, F);
77 if (std::optional<bool> Val = getLiteralValue(F)) {
79 HasContradiction =
true;
100 AssumedFormulas.insert(&F);
103 if (AtomToVal.size() == PrevSize)
114 for (
const Formula *Pending : AssumedFormulas) {
115 unsigned Before = AtomToVal.size();
116 assumeFormula(
true, *Pending);
117 if (HasContradiction)
119 if (
auto V = getLiteralValue(*Pending);
V.has_value() && *
V ==
false) {
120 HasContradiction =
true;
123 if (AtomToVal.size() > Before)
129 bool proves(
const Formula &F)
const override {
130 if (HasContradiction)
132 auto V = getLiteralValue(F);
133 return V.value_or(
false);
136 bool allows(
const Formula &F)
const override {
137 if (HasContradiction)
139 auto V = getLiteralValue(F);
142 return V.value_or(
true);
145 BoolValue &joinBoolValues(BoolValue &Val1,
const BoolModel &Model1,
146 BoolValue &Val2,
const BoolModel &Model2,
147 Environment &JoinedEnv)
override {
150 if (S1.HasContradiction)
152 if (S2.HasContradiction)
154 if (
auto V1 = S1.getLiteralValue(Val1.formula());
155 V1.has_value() && V1 == S2.getLiteralValue(Val2.formula()))
156 return JoinedEnv.getBoolLiteralValue(*V1);
157 return JoinedEnv.makeAtomicBoolValue();
160 void join(
const BoolModel &ModelA,
const BoolModel &ModelB)
override {
164 AssumedFormulas.clear();
165 HasContradiction =
false;
167 if (SA.HasContradiction && SB.HasContradiction) {
168 HasContradiction =
true;
169 }
else if (SA.HasContradiction) {
170 AtomToVal = SB.AtomToVal;
171 AssumedFormulas = SB.AssumedFormulas;
172 }
else if (SB.HasContradiction) {
173 AtomToVal = SA.AtomToVal;
174 AssumedFormulas = SA.AssumedFormulas;
177 for (
const auto &[A,
V] : SA.AtomToVal) {
178 auto It = SB.AtomToVal.find(A);
179 if (It != SB.AtomToVal.end() &&
V == It->second)
180 AtomToVal.insert({A,
V});
189 for (
const Formula *F : SA.AssumedFormulas) {
190 if (!proves(*F) && (SB.AssumedFormulas.contains(F) || SB.proves(*F)))
191 AssumedFormulas.insert(F);
193 for (
const Formula *F : SB.AssumedFormulas) {
194 if (!proves(*F) && SA.proves(*F))
195 AssumedFormulas.insert(F);
200 LatticeEffect widen(
const BoolModel &PrevModel)
override {
202 SimpleBoolModel Widened;
203 Widened.join(*
this, PrevSimple);
204 LatticeEffect Effect = Widened.isEquivalentTo(PrevSimple)
207 *
this = std::move(Widened);
211 bool isEquivalentTo(
const BoolModel &
Other)
const override {
213 if (HasContradiction != OtherSimple.HasContradiction)
215 if (HasContradiction)
217 return AtomToVal == OtherSimple.AtomToVal &&
218 AssumedFormulas.size() == OtherSimple.AssumedFormulas.size() &&
221 llvm::all_of(AssumedFormulas, [&](
const Formula *F) {
222 return OtherSimple.AssumedFormulas.contains(F);
226 Atom getFlowConditionToken()
const override {
228 "getFlowConditionToken() is only supported in SatBoolModel");
231 void dump(raw_ostream &OS)
const override {
232 OS <<
"SimpleBoolModel:\n";
233 OS <<
" HasContradiction: " << HasContradiction <<
"\n";
234 OS <<
" AtomToVal:\n";
237 llvm::sort(SortedAtomToVal, llvm::less_first());
238 for (
auto [A,
V] : SortedAtomToVal)
239 OS <<
" " << A <<
" = " << (
V ?
"true" :
"false") <<
"\n";
240 OS <<
" AssumedFormulas:\n";
241 for (
const Formula *F : AssumedFormulas)
242 OS <<
" " << *F <<
"\n";
246 std::optional<bool> getAtomValue(
Atom A)
const {
247 auto It = AtomToVal.find(A);
248 if (It == AtomToVal.end())
253 std::optional<bool> getLiteralValue(
const Formula &F)
const {
256 return getAtomValue(F.getAtom());
261 assert(Operands.size() == 1);
262 if (std::optional<bool>
V = getLiteralValue(*Operands[0]))
268 assert(Operands.size() == 2);
269 auto &LHS = *Operands[0];
270 auto &RHS = *Operands[1];
271 if (std::optional<bool> Left = getLiteralValue(LHS))
272 return !*Left ? Left : getLiteralValue(RHS);
273 if (std::optional<bool> Right = getLiteralValue(RHS);
274 Right.has_value() && *Right ==
false)
280 assert(Operands.size() == 2);
281 auto &LHS = *Operands[0];
282 auto &RHS = *Operands[1];
283 if (std::optional<bool> Left = getLiteralValue(LHS))
284 return *Left ? Left : getLiteralValue(RHS);
285 if (std::optional<bool> Right = getLiteralValue(RHS);
286 Right.has_value() && *Right ==
true)
292 assert(Operands.size() == 2);
293 auto &LHS = *Operands[0];
294 auto &RHS = *Operands[1];
295 if (std::optional<bool> Left = getLiteralValue(LHS))
296 return !*Left ?
true : getLiteralValue(RHS);
297 if (std::optional<bool> Right = getLiteralValue(RHS);
298 Right.has_value() && *Right ==
true)
304 assert(Operands.size() == 2);
305 auto &LHS = *Operands[0];
306 auto &RHS = *Operands[1];
317 if ((LHS.kind() ==
Formula::Not && LHS.operands()[0] == &RHS) ||
318 (RHS.kind() ==
Formula::Not && RHS.operands()[0] == &LHS))
320 auto V_L = getLiteralValue(LHS);
321 if (!V_L.has_value())
323 auto V_R = getLiteralValue(RHS);
324 if (!V_R.has_value())
329 llvm_unreachable(
"fully covered switch");
342 void assumeFormula(
bool AssumedVal,
const Formula &F) {
343 if (HasContradiction)
350 auto [It, Inserted] = AtomToVal.try_emplace(F.getAtom(), AssumedVal);
351 if (!Inserted && It->second != AssumedVal)
352 HasContradiction =
true;
356 if (F.literal() != AssumedVal)
357 HasContradiction =
true;
363 assert(Operands.size() == 1);
364 assumeFormula(!AssumedVal, *Operands[0]);
373 assert(Operands.size() == 2);
374 auto &LHS = *Operands[0];
375 auto &RHS = *Operands[1];
376 if (AssumedVal ==
true) {
377 assumeFormula(
true, LHS);
378 assumeFormula(
true, RHS);
380 if (
auto V = getLiteralValue(LHS);
V.has_value() && *
V ==
true)
381 assumeFormula(
false, RHS);
382 else if (
auto V = getLiteralValue(RHS);
V.has_value() && *
V ==
true)
383 assumeFormula(
false, LHS);
394 assert(Operands.size() == 2);
395 auto &LHS = *Operands[0];
396 auto &RHS = *Operands[1];
397 if (AssumedVal ==
false) {
398 assumeFormula(
false, LHS);
399 assumeFormula(
false, RHS);
401 if (
auto V = getLiteralValue(LHS);
V.has_value() && *
V ==
false)
402 assumeFormula(
true, RHS);
403 else if (
auto V = getLiteralValue(RHS);
V.has_value() && *
V ==
false)
404 assumeFormula(
true, LHS);
417 assert(Operands.size() == 2);
418 auto &LHS = *Operands[0];
419 auto &RHS = *Operands[1];
420 if (AssumedVal ==
false) {
421 assumeFormula(
true, LHS);
422 assumeFormula(
false, RHS);
424 if (
auto V = getLiteralValue(LHS);
V.has_value() && *
V ==
true)
425 assumeFormula(
true, RHS);
426 else if (
auto V = getLiteralValue(RHS);
V.has_value() && *
V ==
false)
427 assumeFormula(
false, LHS);
436 assert(Operands.size() == 2);
437 auto &LHS = *Operands[0];
438 auto &RHS = *Operands[1];
439 if (
auto V = getLiteralValue(LHS)) {
440 assumeFormula(AssumedVal == *
V, RHS);
441 }
else if (
auto V = getLiteralValue(RHS)) {
442 assumeFormula(AssumedVal == *
V, LHS);
449 llvm::DenseMap<Atom, bool> AtomToVal;
451 bool HasContradiction =
false;
454class SatBoolModel final :
public Environment::BoolModel {
456 SatBoolModel(DataflowAnalysisContext &DACtx,
Atom FlowConditionToken)
458 FlowConditionToken(FlowConditionToken) {}
460 explicit SatBoolModel(DataflowAnalysisContext &DACtx)
461 : SatBoolModel(DACtx, DACtx.arena().makeFlowConditionToken()) {}
463 static bool classof(
const BoolModel *M) {
467 std::unique_ptr<BoolModel> clone()
const override {
468 return std::make_unique<SatBoolModel>(*
this);
471 void onFork()
override {
472 FlowConditionToken = DACtx.forkFlowCondition(FlowConditionToken);
475 void assume(
const Formula &F)
override {
476 DACtx.addFlowConditionConstraint(FlowConditionToken, F);
479 bool proves(
const Formula &F)
const override {
480 return DACtx.flowConditionImplies(FlowConditionToken, F);
483 bool allows(
const Formula &F)
const override {
484 return DACtx.flowConditionAllows(FlowConditionToken, F);
487 BoolValue &joinBoolValues(BoolValue &Val1,
const BoolModel &Model1,
488 BoolValue &Val2,
const BoolModel &Model2,
489 Environment &JoinedEnv)
override {
492 auto &A = JoinedEnv.arena();
493 auto &JoinedVal = A.makeAtomRef(A.makeAtom());
495 A.makeOr(A.makeAnd(A.makeAtomRef(Sat1.getFlowConditionToken()),
496 A.makeEquals(JoinedVal, Val1.formula())),
497 A.makeAnd(A.makeAtomRef(Sat2.getFlowConditionToken()),
498 A.makeEquals(JoinedVal, Val2.formula()))));
499 return A.makeBoolValue(JoinedVal);
502 void join(
const BoolModel &ModelA,
const BoolModel &ModelB)
override {
507 FlowConditionToken = DACtx.joinFlowConditions(SatA.FlowConditionToken,
508 SatB.FlowConditionToken);
511 LatticeEffect widen(
const BoolModel &PrevModel)
override {
516 bool isEquivalentTo(
const BoolModel &
Other)
const override {
521 Atom getFlowConditionToken()
const override {
return FlowConditionToken; }
523 void dump(raw_ostream &OS)
const override {
524 DACtx.dumpFlowCondition(FlowConditionToken, OS);
528 DataflowAnalysisContext &DACtx;
529 Atom FlowConditionToken;
542 const llvm::DenseMap<const ValueDecl *, StorageLocation *> &DeclToLoc1,
543 const llvm::DenseMap<const ValueDecl *, StorageLocation *> &DeclToLoc2) {
544 llvm::DenseMap<const ValueDecl *, StorageLocation *>
Result;
545 for (
auto &Entry : DeclToLoc1) {
546 auto It = DeclToLoc2.find(Entry.first);
547 if (It != DeclToLoc2.end() && Entry.second == It->second)
548 Result.insert({Entry.first, Entry.second});
558template <
typename MapT>
562 for (
const auto &Entry : Map2) {
563 [[maybe_unused]]
auto [It, Inserted] =
Result.insert(Entry);
566 assert(It->second == Entry.second);
580 case Value::Kind::Integer:
581 case Value::Kind::Pointer:
598 switch (Model.compare(
Type, Val1, Env1, Val2, Env2)) {
606 llvm_unreachable(
"All cases covered in switch");
640 Model.join(
Type, Val1, Env1, Val2, Env2, *JoinedVal, JoinedEnv);
665 bool TruePrev = PrevEnv.
proves(PrevBool.formula());
666 bool TrueCur = CurrentEnv.
proves(CurBool.formula());
667 if (TruePrev && TrueCur)
669 if (!TruePrev && !TrueCur &&
680 if (
auto Result = Model.widen(
Type, Prev, PrevEnv, Current, CurrentEnv))
690template <
typename Key>
692 const llvm::MapVector<Key, Value *> &Map2,
696 for (
auto &Entry : Map1) {
698 assert(K !=
nullptr);
700 Value *Val = Entry.second;
701 assert(Val !=
nullptr);
703 auto It = Map2.find(K);
704 if (It == Map2.end())
706 assert(It->second !=
nullptr);
718static llvm::MapVector<const StorageLocation *, Value *>
719joinLocToVal(
const llvm::MapVector<const StorageLocation *, Value *> &LocToVal,
720 const llvm::MapVector<const StorageLocation *, Value *> &LocToVal2,
723 llvm::MapVector<const StorageLocation *, Value *>
Result;
724 for (
auto &Entry : LocToVal) {
726 assert(Loc !=
nullptr);
728 Value *Val = Entry.second;
729 assert(Val !=
nullptr);
731 auto It = LocToVal2.find(Loc);
732 if (It == LocToVal2.end())
734 assert(It->second !=
nullptr);
737 Loc->
getType(), Val, Env1, It->second, Env2, JoinedEnv, Model)) {
738 Result.insert({Loc, JoinedVal});
747template <
typename Key>
748static llvm::MapVector<Key, Value *>
750 const llvm::MapVector<Key, Value *> &PrevMap,
753 llvm::MapVector<Key, Value *> WidenedMap;
754 for (
auto &Entry : CurMap) {
756 assert(K !=
nullptr);
758 Value *Val = Entry.second;
759 assert(Val !=
nullptr);
761 auto PrevIt = PrevMap.find(K);
762 if (PrevIt == PrevMap.end())
764 assert(PrevIt->second !=
nullptr);
767 WidenedMap.insert({K, Val});
772 K->getType(), *PrevIt->second, PrevEnv, *Val, CurEnv, Model);
773 WidenedMap.insert({K, WidenedVal});
786class ResultObjectVisitor :
public AnalysisASTVisitor {
792 explicit ResultObjectVisitor(
793 llvm::DenseMap<const Expr *, RecordStorageLocation *> &ResultObjectMap,
794 RecordStorageLocation *LocForRecordReturnVal,
795 DataflowAnalysisContext &DACtx)
796 : ResultObjectMap(ResultObjectMap),
797 LocForRecordReturnVal(LocForRecordReturnVal), DACtx(DACtx) {}
803 void traverseConstructorInits(
const CXXConstructorDecl *Ctor,
804 RecordStorageLocation *ThisPointeeLoc) {
805 assert(ThisPointeeLoc !=
nullptr);
806 for (
const CXXCtorInitializer *Init : Ctor->inits()) {
807 Expr *InitExpr = Init->getInit();
808 if (
FieldDecl *Field = Init->getMember();
809 Field !=
nullptr && Field->getType()->isRecordType()) {
811 ThisPointeeLoc->getChild(*Field)));
812 }
else if (
Init->getBaseClass()) {
813 PropagateResultObject(InitExpr, ThisPointeeLoc);
818 TraverseStmt(InitExpr);
822 if (
auto *DefaultInit = dyn_cast<CXXDefaultInitExpr>(InitExpr))
827 bool VisitVarDecl(VarDecl *VD)
override {
828 if (VD->getType()->isRecordType() && VD->hasInit())
829 PropagateResultObject(
835 bool VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *MTE)
override {
836 if (MTE->getType()->isRecordType())
837 PropagateResultObject(
843 bool VisitReturnStmt(ReturnStmt *Return)
override {
844 Expr *
RetValue = Return->getRetValue();
847 PropagateResultObject(
RetValue, LocForRecordReturnVal);
851 bool VisitExpr(Expr *E)
override {
857 if (E->isPRValue() && E->getType()->isRecordType() &&
858 !ResultObjectMap.contains(E))
859 PropagateResultObject(
865 PropagateResultObjectToRecordInitList(
const RecordInitListHelper &InitList,
866 RecordStorageLocation *Loc) {
867 for (
auto [Base,
Init] : InitList.base_inits()) {
868 assert(
Base->getType().getCanonicalType() ==
869 Init->getType().getCanonicalType());
874 PropagateResultObject(
Init, Loc);
877 for (
auto [Field,
Init] : InitList.field_inits()) {
880 if (
Field->getType()->isRecordType())
881 PropagateResultObject(
889 void PropagateResultObject(Expr *E, RecordStorageLocation *Loc) {
890 if (!E->isPRValue() || !E->getType()->isRecordType()) {
897 ResultObjectMap[E] = Loc;
916 if (
auto *Op = dyn_cast<BinaryOperator>(E);
917 Op && Op->getOpcode() == BO_Cmp) {
922 if (
auto *InitList = dyn_cast<InitListExpr>(E)) {
923 if (!InitList->isSemanticForm())
925 if (InitList->isTransparent()) {
926 PropagateResultObject(InitList->getInit(0), Loc);
930 PropagateResultObjectToRecordInitList(RecordInitListHelper(InitList),
935 if (
auto *ParenInitList = dyn_cast<CXXParenListInitExpr>(E)) {
936 PropagateResultObjectToRecordInitList(RecordInitListHelper(ParenInitList),
941 if (
auto *Op = dyn_cast<BinaryOperator>(E); Op && Op->isCommaOp()) {
942 PropagateResultObject(Op->getRHS(), Loc);
946 if (
auto *Cond = dyn_cast<AbstractConditionalOperator>(E)) {
947 PropagateResultObject(Cond->getTrueExpr(), Loc);
948 PropagateResultObject(Cond->getFalseExpr(), Loc);
952 if (
auto *SE = dyn_cast<StmtExpr>(E)) {
953 PropagateResultObject(
cast<Expr>(SE->getSubStmt()->body_back()), Loc);
957 if (
auto *DIE = dyn_cast<CXXDefaultInitExpr>(E)) {
958 PropagateResultObject(DIE->getExpr(), Loc);
964 SmallVector<Stmt *, 1>
Children(E->child_begin(), E->child_end());
975 llvm::DenseMap<const Expr *, RecordStorageLocation *> &ResultObjectMap;
976 RecordStorageLocation *LocForRecordReturnVal;
977 DataflowAnalysisContext &DACtx;
983 using BaseVisitor = AnalysisASTVisitor;
986 ThisExprOverridesVisitor(
987 RecordStorageLocation *ThisPointeeLoc,
988 const llvm::DenseMap<const Expr *, RecordStorageLocation *>
990 llvm::DenseMap<const CXXThisExpr *, RecordStorageLocation *>
992 : DefaultThisPointeeLoc(ThisPointeeLoc), ResultObjectMap(ResultObjectMap),
993 ThisExprOverrides(ThisExprOverrides) {
994 ThisLocations.push(DefaultThisPointeeLoc);
997 void traverseConstructorInits(
const CXXConstructorDecl *Ctor) {
998 for (
const CXXCtorInitializer *
Init : Ctor->inits()) {
999 TraverseStmt(
Init->getInit());
1003 bool TraverseInitListExpr(InitListExpr *ILE)
override {
1004 if (!ILE->isSemanticForm() || ILE->isTransparent()) {
1005 BaseVisitor::TraverseInitListExpr(ILE);
1008 bool IsRecordType = ILE->getType()->isRecordType();
1010 auto It = ResultObjectMap.find(ILE);
1011 if (It == ResultObjectMap.end()) {
1012 llvm_unreachable(
"InitListExpr not found in ResultObjectMap");
1015 InitListLocations.push(It->second);
1017 BaseVisitor::TraverseInitListExpr(ILE);
1019 InitListLocations.pop();
1023 bool TraverseCXXParenListInitExpr(CXXParenListInitExpr *PLIE)
override {
1024 auto It = ResultObjectMap.find(PLIE);
1025 if (It == ResultObjectMap.end()) {
1026 llvm_unreachable(
"CXXParenListInitExpr not found in ResultObjectMap");
1029 InitListLocations.push(It->second);
1030 BaseVisitor::TraverseCXXParenListInitExpr(PLIE);
1031 InitListLocations.pop();
1035 bool TraverseCXXDefaultInitExpr(CXXDefaultInitExpr *CDIE)
override {
1036 bool HasInitListLocations = !InitListLocations.empty();
1037 if (HasInitListLocations) {
1038 auto *Loc = InitListLocations.top();
1039 ThisLocations.push(Loc);
1041 BaseVisitor::TraverseCXXDefaultInitExpr(CDIE);
1042 if (HasInitListLocations)
1043 ThisLocations.pop();
1047 bool TraverseCXXThisExpr(CXXThisExpr *This)
override {
1048 assert(!ThisLocations.empty());
1049 auto *Loc = ThisLocations.top();
1050 if (Loc != DefaultThisPointeeLoc)
1051 ThisExprOverrides[
This] = Loc;
1056 RecordStorageLocation *DefaultThisPointeeLoc;
1058 std::stack<RecordStorageLocation *> ThisLocations;
1061 std::stack<RecordStorageLocation *> InitListLocations;
1064 const llvm::DenseMap<const Expr *, RecordStorageLocation *> &ResultObjectMap;
1067 llvm::DenseMap<const CXXThisExpr *, RecordStorageLocation *>
1074 Atom FlowConditionToken)
1076 BoolState(
std::make_unique<SatBoolModel>(DACtx, FlowConditionToken)) {
1078 "FlowConditionToken constructor requires BoolModelKind::SAT");
1082 switch (DACtx.getOptions().BoolModel) {
1083 case BoolModelKind::SAT:
1084 BoolState = std::make_unique<SatBoolModel>(DACtx);
1086 case BoolModelKind::Simple:
1087 BoolState = std::make_unique<SimpleBoolModel>();
1093 : DACtx(
Other.DACtx), CallStack(
Other.CallStack),
1094 InitialTargetFunc(
Other.InitialTargetFunc),
1095 InitialTargetStmt(
Other.InitialTargetStmt),
1096 ResultObjectMap(
Other.ResultObjectMap), ReturnVal(
Other.ReturnVal),
1097 ReturnLoc(
Other.ReturnLoc),
1098 LocForRecordReturnVal(
Other.LocForRecordReturnVal),
1099 ThisPointeeLoc(
Other.ThisPointeeLoc),
1100 ThisExprOverrides(
Other.ThisExprOverrides), DeclToLoc(
Other.DeclToLoc),
1101 ExprToLoc(
Other.ExprToLoc), ExprToVal(
Other.ExprToVal),
1102 LocToVal(
Other.LocToVal), BoolState(
Other.BoolState->clone()) {}
1105 if (InitialTargetStmt ==
nullptr)
1108 if (InitialTargetFunc ==
nullptr) {
1111 std::make_shared<PrValueToResultObject>(buildResultObjectMap(
1116 std::make_shared<ThisExprOverridesMap>(buildThisExprOverridesMap(
1124 for (
const auto *ParamDecl : InitialTargetFunc->parameters()) {
1125 assert(ParamDecl !=
nullptr);
1129 if (InitialTargetFunc->getReturnType()->isRecordType())
1133 if (
const auto *MethodDecl = dyn_cast<CXXMethodDecl>(InitialTargetFunc)) {
1134 auto *Parent = MethodDecl->getParent();
1135 assert(Parent !=
nullptr);
1137 if (Parent->isLambda()) {
1138 for (
const auto &
Capture : Parent->captures()) {
1139 if (
Capture.capturesVariable()) {
1143 }
else if (
Capture.capturesThis()) {
1144 if (
auto *Ancestor = InitialTargetFunc->getNonClosureAncestor()) {
1147 SurroundingMethodDecl->getFunctionObjectParameterType();
1150 }
else if (
auto *FieldBeingInitialized =
1151 dyn_cast<FieldDecl>(Parent->getLambdaContextDecl())) {
1159 assert(
false &&
"Unexpected this-capturing lambda context.");
1163 }
else if (MethodDecl->isImplicitObjectMemberFunction()) {
1164 QualType ThisPointeeType = MethodDecl->getFunctionObjectParameterType();
1179 std::make_shared<PrValueToResultObject>(buildResultObjectMap(
1181 LocForRecordReturnVal));
1184 std::make_shared<ThisExprOverridesMap>(buildThisExprOverridesMap(
1192void Environment::initFieldsGlobalsAndFuncs(
const ReferencedDecls &Referenced) {
1195 DACtx->addModeledFields(Referenced.
Fields);
1219 Copy.BoolState->onFork();
1225 return CallStack.size() < MaxDepth && !llvm::is_contained(CallStack, Callee);
1231 if (
const auto *MethodCall = dyn_cast<CXXMemberCallExpr>(
Call)) {
1232 if (
const Expr *Arg = MethodCall->getImplicitObjectArgument()) {
1234 Env.ThisPointeeLoc =
1241 if (
Call->getType()->isRecordType() &&
Call->isPRValue())
1244 Env.pushCallInternal(
Call->getDirectCallee(),
1256 Env.pushCallInternal(
Call->getConstructor(),
1262void Environment::pushCallInternal(
const FunctionDecl *FuncDecl,
1270 CallStack.push_back(FuncDecl);
1278 for (
unsigned ArgIndex = 0; ArgIndex < Args.size(); ++ParamIt, ++ArgIndex) {
1279 assert(ParamIt != FuncDecl->
param_end());
1280 const VarDecl *Param = *ParamIt;
1284 ResultObjectMap = std::make_shared<PrValueToResultObject>(
1286 LocForRecordReturnVal));
1288 std::make_shared<ThisExprOverridesMap>(buildThisExprOverridesMap(
1300 this->LocToVal = std::move(CalleeEnv.LocToVal);
1301 this->BoolState = CalleeEnv.BoolState->clone();
1303 if (
Call->isGLValue()) {
1304 if (CalleeEnv.ReturnLoc !=
nullptr)
1306 }
else if (!
Call->getType()->isVoidType()) {
1307 if (CalleeEnv.ReturnVal !=
nullptr)
1315 this->LocToVal = std::move(CalleeEnv.LocToVal);
1316 this->BoolState = CalleeEnv.BoolState->clone();
1321 assert(DACtx ==
Other.DACtx);
1323 if (ReturnVal !=
Other.ReturnVal)
1326 if (ReturnLoc !=
Other.ReturnLoc)
1329 if (LocForRecordReturnVal !=
Other.LocForRecordReturnVal)
1332 if (ThisPointeeLoc !=
Other.ThisPointeeLoc)
1335 if (DeclToLoc !=
Other.DeclToLoc)
1338 if (ExprToLoc !=
Other.ExprToLoc)
1346 if (!BoolState->isEquivalentTo(*
Other.BoolState))
1354 assert(DACtx == PrevEnv.DACtx);
1355 assert(ReturnVal == PrevEnv.ReturnVal);
1356 assert(ReturnLoc == PrevEnv.ReturnLoc);
1357 assert(LocForRecordReturnVal == PrevEnv.LocForRecordReturnVal);
1358 assert(ThisPointeeLoc == PrevEnv.ThisPointeeLoc);
1359 assert(ThisExprOverrides == PrevEnv.ThisExprOverrides);
1360 assert(CallStack == PrevEnv.CallStack);
1361 assert(ResultObjectMap == PrevEnv.ResultObjectMap);
1362 assert(InitialTargetFunc == PrevEnv.InitialTargetFunc);
1363 assert(InitialTargetStmt == PrevEnv.InitialTargetStmt);
1373 assert(DeclToLoc.size() <= PrevEnv.DeclToLoc.size());
1374 assert(ExprToVal.size() <= PrevEnv.ExprToVal.size());
1375 assert(ExprToLoc.size() <= PrevEnv.ExprToLoc.size());
1384 if (DeclToLoc.size() != PrevEnv.DeclToLoc.size() ||
1385 ExprToLoc.size() != PrevEnv.ExprToLoc.size() ||
1386 ExprToVal.size() != PrevEnv.ExprToVal.size() ||
1387 LocToVal.size() != PrevEnv.LocToVal.size())
1396 assert(EnvA.DACtx == EnvB.DACtx);
1397 assert(EnvA.LocForRecordReturnVal == EnvB.LocForRecordReturnVal);
1398 assert(EnvA.ThisPointeeLoc == EnvB.ThisPointeeLoc);
1399 assert(EnvA.ThisExprOverrides == EnvB.ThisExprOverrides);
1400 assert(EnvA.CallStack == EnvB.CallStack);
1401 assert(EnvA.ResultObjectMap == EnvB.ResultObjectMap);
1402 assert(EnvA.InitialTargetFunc == EnvB.InitialTargetFunc);
1403 assert(EnvA.InitialTargetStmt == EnvB.InitialTargetStmt);
1407 JoinedEnv.CallStack = EnvA.CallStack;
1408 JoinedEnv.ResultObjectMap = EnvA.ResultObjectMap;
1409 JoinedEnv.LocForRecordReturnVal = EnvA.LocForRecordReturnVal;
1410 JoinedEnv.ThisPointeeLoc = EnvA.ThisPointeeLoc;
1411 JoinedEnv.ThisExprOverrides = EnvA.ThisExprOverrides;
1412 JoinedEnv.InitialTargetFunc = EnvA.InitialTargetFunc;
1413 JoinedEnv.InitialTargetStmt = EnvA.InitialTargetStmt;
1417 JoinedEnv.ReturnVal =
nullptr;
1419 JoinedEnv.ReturnVal =
1420 joinValues(
Func->getReturnType(), EnvA.ReturnVal, EnvA, EnvB.ReturnVal,
1421 EnvB, JoinedEnv, Model);
1424 if (EnvA.ReturnLoc == EnvB.ReturnLoc)
1425 JoinedEnv.ReturnLoc = EnvA.ReturnLoc;
1427 JoinedEnv.ReturnLoc =
nullptr;
1431 JoinedEnv.BoolState->join(*EnvA.BoolState, *EnvB.BoolState);
1433 JoinedEnv.LocToVal =
1434 joinLocToVal(EnvA.LocToVal, EnvB.LocToVal, EnvA, EnvB, JoinedEnv, Model);
1437 JoinedEnv.ExprToVal =
joinExprMaps(EnvA.ExprToVal, EnvB.ExprToVal);
1438 JoinedEnv.ExprToLoc =
joinExprMaps(EnvA.ExprToLoc, EnvB.ExprToLoc);
1448 if (Val1 ==
nullptr || Val2 ==
nullptr)
1463 return DACtx->createStorageLocation(
Type);
1470 return DACtx->getStableStorageLocation(D);
1477 return DACtx->getStableStorageLocation(E);
1481 assert(!DeclToLoc.contains(&D));
1488 DeclToLoc[&D] = &Loc;
1492 auto It = DeclToLoc.find(&D);
1493 if (It == DeclToLoc.end())
1510 assert(!ExprToLoc.contains(&CanonE));
1511 ExprToLoc[&CanonE] = &Loc;
1519 return It == ExprToLoc.end() ?
nullptr : &*It->second;
1527 assert(ResultObjectMap !=
nullptr);
1529 assert(Loc !=
nullptr);
1534 DACtx->getStableStorageLocation(RecordPRValue));
1539 return DACtx->getOrCreateNullPointerValue(PointeeType);
1544 llvm::DenseSet<QualType> Visited;
1545 int CreatedValuesCount = 0;
1548 llvm::errs() <<
"Attempting to initialize a huge value of type: " <<
Type
1556 LocToVal[&Loc] = &Val;
1565 ExprToVal[&CanonE] = &Val;
1571 return LocToVal.lookup(&Loc);
1587 return It == ExprToVal.end() ?
nullptr : It->second;
1591 if (It == ExprToLoc.end())
1597 llvm::DenseSet<QualType> Visited;
1598 int CreatedValuesCount = 0;
1599 Value *Val = createValueUnlessSelfReferential(
Type, Visited, 0,
1600 CreatedValuesCount);
1602 llvm::errs() <<
"Attempting to initialize a huge value of type: " <<
Type
1608Value *Environment::createValueUnlessSelfReferential(
1609 QualType Type, llvm::DenseSet<QualType> &Visited,
int Depth,
1610 int &CreatedValuesCount) {
1611 assert(!
Type.isNull());
1621 CreatedValuesCount++;
1629 CreatedValuesCount++;
1633 if (Type->isPointerType()) {
1634 CreatedValuesCount++;
1635 QualType PointeeType = Type->getPointeeType();
1636 StorageLocation &PointeeLoc =
1637 createLocAndMaybeValue(PointeeType, Visited, Depth, CreatedValuesCount);
1646Environment::createLocAndMaybeValue(QualType Ty,
1647 llvm::DenseSet<QualType> &Visited,
1648 int Depth,
int &CreatedValuesCount) {
1649 if (!Visited.insert(Ty.getCanonicalType()).second)
1651 llvm::scope_exit EraseVisited(
1652 [&Visited, Ty] { Visited.erase(Ty.getCanonicalType()); });
1654 Ty = Ty.getNonReferenceType();
1656 if (Ty->isRecordType()) {
1664 if (
Value *Val = createValueUnlessSelfReferential(Ty, Visited, Depth,
1665 CreatedValuesCount))
1673 llvm::DenseSet<QualType> &Visited,
1675 int &CreatedValuesCount) {
1676 auto initField = [&](QualType FieldType, StorageLocation &FieldLoc) {
1677 if (FieldType->isRecordType()) {
1680 Visited, Depth + 1, CreatedValuesCount);
1684 if (!Visited.insert(FieldType.getCanonicalType()).second)
1686 if (
Value *Val = createValueUnlessSelfReferential(
1687 FieldType, Visited, Depth + 1, CreatedValuesCount))
1689 Visited.erase(FieldType.getCanonicalType());
1693 for (
const FieldDecl *Field : DACtx->getModeledFields(
Type)) {
1694 assert(Field !=
nullptr);
1695 QualType FieldType =
Field->getType();
1697 if (FieldType->isReferenceType()) {
1698 Loc.setChild(*Field,
1699 &createLocAndMaybeValue(FieldType, Visited, Depth + 1,
1700 CreatedValuesCount));
1702 StorageLocation *FieldLoc = Loc.getChild(*Field);
1703 assert(FieldLoc !=
nullptr);
1707 for (
const auto &[FieldName, FieldType] : DACtx->getSyntheticFields(
Type)) {
1710 assert(!FieldType->isReferenceType());
1711 initField(FieldType, Loc.getSyntheticField(FieldName));
1717 const Expr *InitExpr) {
1718 if (Ty->isReferenceType()) {
1724 return *InitExprLoc;
1731 return createObjectInternal(D, Ty.getNonReferenceType(),
nullptr);
1734 StorageLocation &Loc =
1737 if (Ty->isRecordType()) {
1738 auto &RecordLoc = cast<RecordStorageLocation>(Loc);
1740 initializeFieldsWithValues(RecordLoc);
1742 Value *Val = nullptr;
1757 Val = getValue(*InitExpr);
1759 Val = createValue(Ty);
1761 setValue(Loc, *Val);
1770 return BoolState->proves(F);
1774 return BoolState->allows(F);
1778 llvm::DenseMap<const StorageLocation *, std::string> LocToName;
1779 if (LocForRecordReturnVal !=
nullptr)
1780 LocToName[LocForRecordReturnVal] =
"(returned record)";
1781 if (ThisPointeeLoc !=
nullptr)
1782 LocToName[ThisPointeeLoc] =
"this";
1784 OS <<
"DeclToLoc:\n";
1785 for (
auto [D, L] : DeclToLoc) {
1786 auto Iter = LocToName.insert({L, D->getNameAsString()}).first;
1787 OS <<
" [" << Iter->second <<
", " << L <<
"]\n";
1789 OS <<
"ExprToLoc:\n";
1790 for (
auto [E, L] : ExprToLoc)
1791 OS <<
" [" << E <<
", " << L <<
"]\n";
1793 OS <<
"ExprToVal:\n";
1794 for (
auto [E,
V] : ExprToVal)
1795 OS <<
" [" << E <<
", " <<
V <<
": " << *
V <<
"]\n";
1797 OS <<
"LocToVal:\n";
1798 for (
auto [L,
V] : LocToVal) {
1800 if (
auto Iter = LocToName.find(L); Iter != LocToName.end())
1801 OS <<
" (" << Iter->second <<
")";
1802 OS <<
", " <<
V <<
": " << *
V <<
"]\n";
1806 if (
Func->getReturnType()->isReferenceType()) {
1807 OS <<
"ReturnLoc: " << ReturnLoc;
1808 if (
auto Iter = LocToName.find(ReturnLoc); Iter != LocToName.end())
1809 OS <<
" (" << Iter->second <<
")";
1811 }
else if (
Func->getReturnType()->isRecordType() ||
1813 OS <<
"LocForRecordReturnVal: " << LocForRecordReturnVal <<
"\n";
1814 }
else if (!
Func->getReturnType()->isVoidType()) {
1815 if (ReturnVal ==
nullptr)
1816 OS <<
"ReturnVal: nullptr\n";
1818 OS <<
"ReturnVal: " << *ReturnVal <<
"\n";
1822 OS <<
"ThisPointeeLoc: " << ThisPointeeLoc <<
"\n";
1827 BoolState->dump(OS);
1832Environment::PrValueToResultObject Environment::buildResultObjectMap(
1838 PrValueToResultObject Map = buildResultObjectMap(
1839 DACtx, FuncDecl->
getBody(), ThisPointeeLoc, LocForRecordReturnVal);
1841 ResultObjectVisitor Visitor(Map, LocForRecordReturnVal, *DACtx);
1842 if (
const auto *Ctor = dyn_cast<CXXConstructorDecl>(FuncDecl))
1843 Visitor.traverseConstructorInits(Ctor, ThisPointeeLoc);
1848Environment::PrValueToResultObject Environment::buildResultObjectMap(
1849 DataflowAnalysisContext *DACtx,
Stmt *S,
1850 RecordStorageLocation *ThisPointeeLoc,
1851 RecordStorageLocation *LocForRecordReturnVal) {
1852 PrValueToResultObject Map;
1853 ResultObjectVisitor Visitor(Map, LocForRecordReturnVal, *DACtx);
1854 Visitor.TraverseStmt(S);
1858Environment::ThisExprOverridesMap Environment::buildThisExprOverridesMap(
1859 const FunctionDecl *FuncDecl, RecordStorageLocation *ThisPointeeLoc,
1860 const PrValueToResultObject &ResultObjectMap) {
1861 assert(FuncDecl->doesThisDeclarationHaveABody());
1863 ThisExprOverridesMap Map = buildThisExprOverridesMap(
1864 FuncDecl->getBody(), ThisPointeeLoc, ResultObjectMap);
1866 ThisExprOverridesVisitor Visitor(ThisPointeeLoc, ResultObjectMap, Map);
1867 if (
const auto *Ctor = dyn_cast<CXXConstructorDecl>(FuncDecl)) {
1868 Visitor.traverseConstructorInits(Ctor);
1873Environment::ThisExprOverridesMap Environment::buildThisExprOverridesMap(
1875 const PrValueToResultObject &ResultObjectMap) {
1876 ThisExprOverridesMap Map;
1877 ThisExprOverridesVisitor Visitor(ThisPointeeLoc, ResultObjectMap, Map);
1878 Visitor.TraverseStmt(S);
1885 if (ImplicitObject ==
nullptr)
1892 return cast_or_null<RecordStorageLocation>(
1899 if (
Base ==
nullptr)
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
static void initField(std::byte *Ptr, bool IsConst, bool IsMutable, bool IsVolatile, bool IsActive, bool IsUnionField, bool InUnion, const Descriptor *D, unsigned FieldOffset)
Defines the clang::Expr interface and subclasses for C++ expressions.
static PRESERVE_NONE bool RetValue(InterpState &S)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
C Language Family Type Representation.
Represents a member of a struct/union/class.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CanQualType getCanonicalTagType(const TagDecl *TD) const
Represents a call to a C++ constructor.
Represents a call to a member function that may be written either with member call syntax (e....
Expr * getImplicitObjectArgument() const
Retrieve the implicit object argument for the member call.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
DeclContext * getParent()
getParent - Returns the containing DeclContext.
ASTContext & getASTContext() const LLVM_READONLY
This represents one expression.
Represents a function declaration or definition.
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
param_iterator param_end()
param_iterator param_begin()
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
FunctionDecl * getDefinition()
Get the definition for this declaration.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
A (possibly-)qualified type.
Represents a struct/union/class.
Stmt - This represents one statement.
The base class of the type hierarchy.
bool isBooleanType() const
bool isPointerType() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
bool isReferenceType() const
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
bool isRecordType() const
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
Specialization of RecursiveASTVisitor that visits those nodes that are relevant to the dataflow analy...
const Formula & makeNot(const Formula &Val)
Returns a formula for the negation of Val.
std::enable_if_t< std::is_base_of< StorageLocation, T >::value, T & > create(Args &&...args)
Creates a T (some subclass of StorageLocation), forwarding args to the constructor,...
Owns objects that encompass the state of a program and stores context that is used during dataflow an...
Supplements Environment with non-standard comparison and join operations.
Holds the state of the program (store and heap) at a given program point.
bool allows(const Formula &) const
Returns true if the formula may be true when this point is reached.
LatticeEffect widen(const Environment &PrevEnv, Environment::ValueModel &Model)
Widens the environment point-wise, using PrevEnv as needed to inform the approximation.
PointerValue & getOrCreateNullPointerValue(QualType PointeeType)
Returns a pointer value that represents a null pointer.
RecordStorageLocation * getThisPointeeStorageLocation() const
Returns the storage location assigned to the this pointee in the environment or null if the this poin...
Environment pushCall(const CallExpr *Call) const
Creates and returns an environment to use for an inline analysis of the callee.
StorageLocation * getStorageLocation(const ValueDecl &D) const
Returns the storage location assigned to D in the environment, or null if D isn't assigned a storage ...
LLVM_DUMP_METHOD void dump() const
BoolValue & makeTopBoolValue() const
Returns a unique instance of boolean Top.
void initializeFieldsWithValues(RecordStorageLocation &Loc, QualType Type)
Initializes the fields (including synthetic fields) of Loc with values, unless values of the field ty...
StorageLocation & createStorageLocation(QualType Type)
Creates a storage location appropriate for Type.
Environment fork() const
Returns a new environment that is a copy of this one.
void popCall(const CallExpr *Call, const Environment &CalleeEnv)
Moves gathered information back into this from a CalleeEnv created via pushCall.
bool equivalentTo(const Environment &Other, Environment::ValueModel &Model) const
Returns true if and only if the environment is equivalent to Other, i.e the two environments:
BoolValue & makeAtomicBoolValue() const
Returns an atomic boolean value.
bool proves(const Formula &) const
Returns true if the formula is always true when this point is reached.
Value * getValue(const StorageLocation &Loc) const
Returns the value assigned to Loc in the environment or null if Loc isn't assigned a value in the env...
const FunctionDecl * getCurrentFunc() const
Returns the function currently being analyzed, or null if the code being analyzed isn't part of a fun...
BoolValue & getBoolLiteralValue(bool Value) const
Returns a symbolic boolean value that models a boolean literal equal to Value
StorageLocation & createObject(QualType Ty, const Expr *InitExpr=nullptr)
Creates an object (i.e.
void assume(const Formula &)
Record a fact that must be true if this point in the program is reached.
BoolValue & joinBoolValues(BoolValue &Val1, const Environment &Env1, BoolValue &Val2, const Environment &Env2)
Joins two distinct boolean values Val1 (from Env1) and Val2 (from Env2) into this environment.
Environment(DataflowAnalysisContext &DACtx, Atom FlowConditionToken)
Creates an environment that uses DACtx to store objects that encompass the state of a program.
static Value * joinValues(QualType Ty, Value *Val1, const Environment &Env1, Value *Val2, const Environment &Env2, Environment &JoinedEnv, Environment::ValueModel &Model)
Returns a value that approximates both Val1 and Val2, or null if no such value can be produced.
void setStorageLocation(const ValueDecl &D, StorageLocation &Loc)
Assigns Loc as the storage location of D in the environment.
void removeDecl(const ValueDecl &D)
Removes the location assigned to D in the environment (if any).
RecordStorageLocation & getResultObjectLocation(const Expr &RecordPRValue) const
Returns the location of the result object for a record-type prvalue.
ExprJoinBehavior
How to treat expression state (ExprToLoc and ExprToVal) in a join.
static Environment join(const Environment &EnvA, const Environment &EnvB, Environment::ValueModel &Model, ExprJoinBehavior ExprBehavior)
Joins two environments by taking the intersection of storage locations and values that are stored in ...
Value * createValue(QualType Type)
Creates a value appropriate for Type, if Type is supported, otherwise returns null.
void setValue(const StorageLocation &Loc, Value &Val)
Assigns Val as the value of Loc in the environment.
void setThisPointeeStorageLocation(RecordStorageLocation &Loc)
Sets the storage location assigned to the this pointee in the environment.
bool canDescend(unsigned MaxDepth, const FunctionDecl *Callee) const
Returns whether this Environment can be extended to analyze the given Callee (i.e.
std::enable_if_t< std::is_base_of_v< StorageLocation, T >, T * > get(const ValueDecl &D) const
Returns the result of casting getStorageLocation(...) to a subclass of StorageLocation (using cast_or...
void initialize()
Assigns storage locations and values to all parameters, captures, global variables,...
Models a symbolic pointer. Specifically, any value of type T*.
A storage location for a record (struct, class, or union).
Base class for elements of the local variable store and of the heap.
Base class for all values computed by abstract interpretation.
@ Simple
Lightweight model that tracks known truth assignments for atoms (e.g., for each assume()) and unresol...
@ SAT
Full boolean formula tracking backed by a SAT solver.
static bool compareKeyToValueMaps(const llvm::MapVector< Key, Value * > &Map1, const llvm::MapVector< Key, Value * > &Map2, const Environment &Env1, const Environment &Env2, Environment::ValueModel &Model)
Atom
Identifies an atomic boolean variable such as "V1".
static llvm::DenseMap< const ValueDecl *, StorageLocation * > intersectDeclToLoc(const llvm::DenseMap< const ValueDecl *, StorageLocation * > &DeclToLoc1, const llvm::DenseMap< const ValueDecl *, StorageLocation * > &DeclToLoc2)
Returns a map consisting of key-value entries that are present in both maps.
static bool equateUnknownValues(Value::Kind K)
@ Value
value(), operator* or operator->, which require a value.
bool areEquivalentValues(const Value &Val1, const Value &Val2)
An equivalence relation for values.
static llvm::MapVector< Key, Value * > widenKeyToValueMap(const llvm::MapVector< Key, Value * > &CurMap, const llvm::MapVector< Key, Value * > &PrevMap, Environment &CurEnv, const Environment &PrevEnv, Environment::ValueModel &Model, LatticeEffect &Effect)
static constexpr int MaxCompositeValueDepth
static constexpr int MaxCompositeValueSize
ReferencedDecls getReferencedDecls(const FunctionDecl &FD)
Returns declarations that are declared in or referenced from FD.
RecordStorageLocation * getImplicitObjectLocation(const CXXMemberCallExpr &MCE, const Environment &Env)
Returns the storage location for the implicit object of a CXXMemberCallExpr, or null if none is defin...
static WidenResult widenDistinctValues(QualType Type, Value &Prev, const Environment &PrevEnv, Value &Current, Environment &CurrentEnv, Environment::ValueModel &Model)
const Expr & ignoreCFGOmittedNodes(const Expr &E)
Skip past nodes that the CFG does not emit.
static llvm::MapVector< const StorageLocation *, Value * > joinLocToVal(const llvm::MapVector< const StorageLocation *, Value * > &LocToVal, const llvm::MapVector< const StorageLocation *, Value * > &LocToVal2, const Environment &Env1, const Environment &Env2, Environment &JoinedEnv, Environment::ValueModel &Model)
static MapT joinExprMaps(const MapT &Map1, const MapT &Map2)
static bool compareDistinctValues(QualType Type, Value &Val1, const Environment &Env1, Value &Val2, const Environment &Env2, Environment::ValueModel &Model)
RecordStorageLocation * getBaseObjectLocation(const MemberExpr &ME, const Environment &Env)
Returns the storage location for the base object of a MemberExpr, or null if none is defined in the e...
static Value * joinDistinctValues(QualType Type, Value &Val1, const Environment &Env1, Value &Val2, const Environment &Env2, Environment &JoinedEnv, Environment::ValueModel &Model)
Attempts to join distinct values Val1 and Val2 in Env1 and Env2, respectively, of the same type Type.
LatticeEffect
Effect indicating whether a lattice operation resulted in a new value.
bool This(InterpState &S, CodePtr OpPC)
bool DefaultInit(InterpState &S, CodePtr OpPC, const CXXConstructorDecl *Ctor)
Top level wrappers for InstallAPI frontend operations.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
bool isa(CodeGen::Address addr)
static bool classof(const OMPClause *T)
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
@ Result
The result type of a method or function.
const FunctionProtoType * T
U cast(CodeGen::Address addr)
A collection of several types of declarations, all referenced from the same function.
llvm::SetVector< const VarDecl * > Globals
All variables with static storage duration, notably including static member variables and static vari...
FieldSet Fields
Non-static member variables.
llvm::SetVector< const FunctionDecl * > Functions
Free functions and member functions which are referenced (but not necessarily called).
The result of a widen operation.