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())
341 void assumeFormula(
bool AssumedVal,
const Formula &F) {
342 if (HasContradiction)
349 auto [It, Inserted] = AtomToVal.try_emplace(F.getAtom(), AssumedVal);
350 if (!Inserted && It->second != AssumedVal)
351 HasContradiction =
true;
355 if (F.literal() != AssumedVal)
356 HasContradiction =
true;
362 assert(Operands.size() == 1);
363 assumeFormula(!AssumedVal, *Operands[0]);
372 assert(Operands.size() == 2);
373 auto &LHS = *Operands[0];
374 auto &RHS = *Operands[1];
375 if (AssumedVal ==
true) {
376 assumeFormula(
true, LHS);
377 assumeFormula(
true, RHS);
379 if (
auto V = getLiteralValue(LHS);
V.has_value() && *
V ==
true)
380 assumeFormula(
false, RHS);
381 else if (
auto V = getLiteralValue(RHS);
V.has_value() && *
V ==
true)
382 assumeFormula(
false, LHS);
393 assert(Operands.size() == 2);
394 auto &LHS = *Operands[0];
395 auto &RHS = *Operands[1];
396 if (AssumedVal ==
false) {
397 assumeFormula(
false, LHS);
398 assumeFormula(
false, RHS);
400 if (
auto V = getLiteralValue(LHS);
V.has_value() && *
V ==
false)
401 assumeFormula(
true, RHS);
402 else if (
auto V = getLiteralValue(RHS);
V.has_value() && *
V ==
false)
403 assumeFormula(
true, LHS);
416 assert(Operands.size() == 2);
417 auto &LHS = *Operands[0];
418 auto &RHS = *Operands[1];
419 if (AssumedVal ==
false) {
420 assumeFormula(
true, LHS);
421 assumeFormula(
false, RHS);
423 if (
auto V = getLiteralValue(LHS);
V.has_value() && *
V ==
true)
424 assumeFormula(
true, RHS);
425 else if (
auto V = getLiteralValue(RHS);
V.has_value() && *
V ==
false)
426 assumeFormula(
false, LHS);
435 assert(Operands.size() == 2);
436 auto &LHS = *Operands[0];
437 auto &RHS = *Operands[1];
438 if (
auto V = getLiteralValue(LHS)) {
439 assumeFormula(AssumedVal == *
V, RHS);
440 }
else if (
auto V = getLiteralValue(RHS)) {
441 assumeFormula(AssumedVal == *
V, LHS);
448 llvm::DenseMap<Atom, bool> AtomToVal;
450 bool HasContradiction =
false;
453class SatBoolModel final :
public Environment::BoolModel {
455 SatBoolModel(DataflowAnalysisContext &DACtx,
Atom FlowConditionToken)
457 FlowConditionToken(FlowConditionToken) {}
459 explicit SatBoolModel(DataflowAnalysisContext &DACtx)
460 : SatBoolModel(DACtx, DACtx.arena().makeFlowConditionToken()) {}
462 static bool classof(
const BoolModel *M) {
466 std::unique_ptr<BoolModel> clone()
const override {
467 return std::make_unique<SatBoolModel>(*
this);
470 void onFork()
override {
471 FlowConditionToken = DACtx.forkFlowCondition(FlowConditionToken);
474 void assume(
const Formula &F)
override {
475 DACtx.addFlowConditionConstraint(FlowConditionToken, F);
478 bool proves(
const Formula &F)
const override {
479 return DACtx.flowConditionImplies(FlowConditionToken, F);
482 bool allows(
const Formula &F)
const override {
483 return DACtx.flowConditionAllows(FlowConditionToken, F);
486 BoolValue &joinBoolValues(BoolValue &Val1,
const BoolModel &Model1,
487 BoolValue &Val2,
const BoolModel &Model2,
488 Environment &JoinedEnv)
override {
491 auto &A = JoinedEnv.arena();
492 auto &JoinedVal = A.makeAtomRef(A.makeAtom());
494 A.makeOr(A.makeAnd(A.makeAtomRef(Sat1.getFlowConditionToken()),
495 A.makeEquals(JoinedVal, Val1.formula())),
496 A.makeAnd(A.makeAtomRef(Sat2.getFlowConditionToken()),
497 A.makeEquals(JoinedVal, Val2.formula()))));
498 return A.makeBoolValue(JoinedVal);
501 void join(
const BoolModel &ModelA,
const BoolModel &ModelB)
override {
506 FlowConditionToken = DACtx.joinFlowConditions(SatA.FlowConditionToken,
507 SatB.FlowConditionToken);
510 LatticeEffect widen(
const BoolModel &PrevModel)
override {
515 bool isEquivalentTo(
const BoolModel &
Other)
const override {
520 Atom getFlowConditionToken()
const override {
return FlowConditionToken; }
522 void dump(raw_ostream &OS)
const override {
523 DACtx.dumpFlowCondition(FlowConditionToken, OS);
527 DataflowAnalysisContext &DACtx;
528 Atom FlowConditionToken;
541 const llvm::DenseMap<const ValueDecl *, StorageLocation *> &DeclToLoc1,
542 const llvm::DenseMap<const ValueDecl *, StorageLocation *> &DeclToLoc2) {
543 llvm::DenseMap<const ValueDecl *, StorageLocation *>
Result;
544 for (
auto &Entry : DeclToLoc1) {
545 auto It = DeclToLoc2.find(Entry.first);
546 if (It != DeclToLoc2.end() && Entry.second == It->second)
547 Result.insert({Entry.first, Entry.second});
557template <
typename MapT>
561 for (
const auto &Entry : Map2) {
562 [[maybe_unused]]
auto [It, Inserted] =
Result.insert(Entry);
565 assert(It->second == Entry.second);
579 case Value::Kind::Integer:
580 case Value::Kind::Pointer:
597 switch (Model.compare(
Type, Val1, Env1, Val2, Env2)) {
605 llvm_unreachable(
"All cases covered in switch");
639 Model.join(
Type, Val1, Env1, Val2, Env2, *JoinedVal, JoinedEnv);
664 bool TruePrev = PrevEnv.
proves(PrevBool.formula());
665 bool TrueCur = CurrentEnv.
proves(CurBool.formula());
666 if (TruePrev && TrueCur)
668 if (!TruePrev && !TrueCur &&
679 if (
auto Result = Model.widen(
Type, Prev, PrevEnv, Current, CurrentEnv))
689template <
typename Key>
691 const llvm::MapVector<Key, Value *> &Map2,
695 for (
auto &Entry : Map1) {
697 assert(K !=
nullptr);
699 Value *Val = Entry.second;
700 assert(Val !=
nullptr);
702 auto It = Map2.find(K);
703 if (It == Map2.end())
705 assert(It->second !=
nullptr);
717static llvm::MapVector<const StorageLocation *, Value *>
718joinLocToVal(
const llvm::MapVector<const StorageLocation *, Value *> &LocToVal,
719 const llvm::MapVector<const StorageLocation *, Value *> &LocToVal2,
722 llvm::MapVector<const StorageLocation *, Value *>
Result;
723 for (
auto &Entry : LocToVal) {
725 assert(Loc !=
nullptr);
727 Value *Val = Entry.second;
728 assert(Val !=
nullptr);
730 auto It = LocToVal2.find(Loc);
731 if (It == LocToVal2.end())
733 assert(It->second !=
nullptr);
736 Loc->
getType(), Val, Env1, It->second, Env2, JoinedEnv, Model)) {
737 Result.insert({Loc, JoinedVal});
746template <
typename Key>
747static llvm::MapVector<Key, Value *>
749 const llvm::MapVector<Key, Value *> &PrevMap,
752 llvm::MapVector<Key, Value *> WidenedMap;
753 for (
auto &Entry : CurMap) {
755 assert(K !=
nullptr);
757 Value *Val = Entry.second;
758 assert(Val !=
nullptr);
760 auto PrevIt = PrevMap.find(K);
761 if (PrevIt == PrevMap.end())
763 assert(PrevIt->second !=
nullptr);
766 WidenedMap.insert({K, Val});
771 K->getType(), *PrevIt->second, PrevEnv, *Val, CurEnv, Model);
772 WidenedMap.insert({K, WidenedVal});
785class ResultObjectVisitor :
public AnalysisASTVisitor {
791 explicit ResultObjectVisitor(
792 llvm::DenseMap<const Expr *, RecordStorageLocation *> &ResultObjectMap,
793 RecordStorageLocation *LocForRecordReturnVal,
794 DataflowAnalysisContext &DACtx)
795 : ResultObjectMap(ResultObjectMap),
796 LocForRecordReturnVal(LocForRecordReturnVal), DACtx(DACtx) {}
802 void traverseConstructorInits(
const CXXConstructorDecl *Ctor,
803 RecordStorageLocation *ThisPointeeLoc) {
804 assert(ThisPointeeLoc !=
nullptr);
805 for (
const CXXCtorInitializer *Init : Ctor->inits()) {
806 Expr *InitExpr = Init->getInit();
807 if (
FieldDecl *Field = Init->getMember();
808 Field !=
nullptr && Field->getType()->isRecordType()) {
810 ThisPointeeLoc->getChild(*Field)));
811 }
else if (
Init->getBaseClass()) {
812 PropagateResultObject(InitExpr, ThisPointeeLoc);
817 TraverseStmt(InitExpr);
821 if (
auto *DefaultInit = dyn_cast<CXXDefaultInitExpr>(InitExpr))
826 bool VisitVarDecl(VarDecl *VD)
override {
827 if (VD->getType()->isRecordType() && VD->hasInit())
828 PropagateResultObject(
834 bool VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *MTE)
override {
835 if (MTE->getType()->isRecordType())
836 PropagateResultObject(
842 bool VisitReturnStmt(ReturnStmt *Return)
override {
843 Expr *
RetValue = Return->getRetValue();
846 PropagateResultObject(
RetValue, LocForRecordReturnVal);
850 bool VisitExpr(Expr *E)
override {
856 if (E->isPRValue() && E->getType()->isRecordType() &&
857 !ResultObjectMap.contains(E))
858 PropagateResultObject(
864 PropagateResultObjectToRecordInitList(
const RecordInitListHelper &InitList,
865 RecordStorageLocation *Loc) {
866 for (
auto [Base,
Init] : InitList.base_inits()) {
867 assert(
Base->getType().getCanonicalType() ==
868 Init->getType().getCanonicalType());
873 PropagateResultObject(
Init, Loc);
876 for (
auto [Field,
Init] : InitList.field_inits()) {
879 if (
Field->getType()->isRecordType())
880 PropagateResultObject(
888 void PropagateResultObject(Expr *E, RecordStorageLocation *Loc) {
889 if (!E->isPRValue() || !E->getType()->isRecordType()) {
896 ResultObjectMap[E] = Loc;
915 if (
auto *Op = dyn_cast<BinaryOperator>(E);
916 Op && Op->getOpcode() == BO_Cmp) {
921 if (
auto *InitList = dyn_cast<InitListExpr>(E)) {
922 if (!InitList->isSemanticForm())
924 if (InitList->isTransparent()) {
925 PropagateResultObject(InitList->getInit(0), Loc);
929 PropagateResultObjectToRecordInitList(RecordInitListHelper(InitList),
934 if (
auto *ParenInitList = dyn_cast<CXXParenListInitExpr>(E)) {
935 PropagateResultObjectToRecordInitList(RecordInitListHelper(ParenInitList),
940 if (
auto *Op = dyn_cast<BinaryOperator>(E); Op && Op->isCommaOp()) {
941 PropagateResultObject(Op->getRHS(), Loc);
945 if (
auto *Cond = dyn_cast<AbstractConditionalOperator>(E)) {
946 PropagateResultObject(Cond->getTrueExpr(), Loc);
947 PropagateResultObject(Cond->getFalseExpr(), Loc);
951 if (
auto *SE = dyn_cast<StmtExpr>(E)) {
952 PropagateResultObject(
cast<Expr>(SE->getSubStmt()->body_back()), Loc);
956 if (
auto *DIE = dyn_cast<CXXDefaultInitExpr>(E)) {
957 PropagateResultObject(DIE->getExpr(), Loc);
963 SmallVector<Stmt *, 1>
Children(E->child_begin(), E->child_end());
974 llvm::DenseMap<const Expr *, RecordStorageLocation *> &ResultObjectMap;
975 RecordStorageLocation *LocForRecordReturnVal;
976 DataflowAnalysisContext &DACtx;
982 using BaseVisitor = AnalysisASTVisitor;
985 ThisExprOverridesVisitor(
986 RecordStorageLocation *ThisPointeeLoc,
987 const llvm::DenseMap<const Expr *, RecordStorageLocation *>
989 llvm::DenseMap<const CXXThisExpr *, RecordStorageLocation *>
991 : DefaultThisPointeeLoc(ThisPointeeLoc), ResultObjectMap(ResultObjectMap),
992 ThisExprOverrides(ThisExprOverrides) {
993 ThisLocations.push(DefaultThisPointeeLoc);
996 void traverseConstructorInits(
const CXXConstructorDecl *Ctor) {
997 for (
const CXXCtorInitializer *
Init : Ctor->inits()) {
998 TraverseStmt(
Init->getInit());
1002 bool TraverseInitListExpr(InitListExpr *ILE)
override {
1003 if (!ILE->isSemanticForm() || ILE->isTransparent()) {
1004 BaseVisitor::TraverseInitListExpr(ILE);
1007 bool IsRecordType = ILE->getType()->isRecordType();
1009 auto It = ResultObjectMap.find(ILE);
1010 if (It == ResultObjectMap.end()) {
1011 llvm_unreachable(
"InitListExpr not found in ResultObjectMap");
1014 InitListLocations.push(It->second);
1016 BaseVisitor::TraverseInitListExpr(ILE);
1018 InitListLocations.pop();
1022 bool TraverseCXXParenListInitExpr(CXXParenListInitExpr *PLIE)
override {
1023 auto It = ResultObjectMap.find(PLIE);
1024 if (It == ResultObjectMap.end()) {
1025 llvm_unreachable(
"CXXParenListInitExpr not found in ResultObjectMap");
1028 InitListLocations.push(It->second);
1029 BaseVisitor::TraverseCXXParenListInitExpr(PLIE);
1030 InitListLocations.pop();
1034 bool TraverseCXXDefaultInitExpr(CXXDefaultInitExpr *CDIE)
override {
1035 bool HasInitListLocations = !InitListLocations.empty();
1036 if (HasInitListLocations) {
1037 auto *Loc = InitListLocations.top();
1038 ThisLocations.push(Loc);
1040 BaseVisitor::TraverseCXXDefaultInitExpr(CDIE);
1041 if (HasInitListLocations)
1042 ThisLocations.pop();
1046 bool TraverseCXXThisExpr(CXXThisExpr *This)
override {
1047 assert(!ThisLocations.empty());
1048 auto *Loc = ThisLocations.top();
1049 if (Loc != DefaultThisPointeeLoc)
1050 ThisExprOverrides[
This] = Loc;
1055 RecordStorageLocation *DefaultThisPointeeLoc;
1057 std::stack<RecordStorageLocation *> ThisLocations;
1060 std::stack<RecordStorageLocation *> InitListLocations;
1063 const llvm::DenseMap<const Expr *, RecordStorageLocation *> &ResultObjectMap;
1066 llvm::DenseMap<const CXXThisExpr *, RecordStorageLocation *>
1073 Atom FlowConditionToken)
1075 BoolState(
std::make_unique<SatBoolModel>(DACtx, FlowConditionToken)) {
1077 "FlowConditionToken constructor requires BoolModelKind::SAT");
1081 switch (DACtx.getOptions().BoolModel) {
1082 case BoolModelKind::SAT:
1083 BoolState = std::make_unique<SatBoolModel>(DACtx);
1085 case BoolModelKind::Simple:
1086 BoolState = std::make_unique<SimpleBoolModel>();
1092 : DACtx(
Other.DACtx), CallStack(
Other.CallStack),
1093 InitialTargetFunc(
Other.InitialTargetFunc),
1094 InitialTargetStmt(
Other.InitialTargetStmt),
1095 ResultObjectMap(
Other.ResultObjectMap), ReturnVal(
Other.ReturnVal),
1096 ReturnLoc(
Other.ReturnLoc),
1097 LocForRecordReturnVal(
Other.LocForRecordReturnVal),
1098 ThisPointeeLoc(
Other.ThisPointeeLoc),
1099 ThisExprOverrides(
Other.ThisExprOverrides), DeclToLoc(
Other.DeclToLoc),
1100 ExprToLoc(
Other.ExprToLoc), ExprToVal(
Other.ExprToVal),
1101 LocToVal(
Other.LocToVal), BoolState(
Other.BoolState->clone()) {}
1104 if (InitialTargetStmt ==
nullptr)
1107 if (InitialTargetFunc ==
nullptr) {
1110 std::make_shared<PrValueToResultObject>(buildResultObjectMap(
1115 std::make_shared<ThisExprOverridesMap>(buildThisExprOverridesMap(
1123 for (
const auto *ParamDecl : InitialTargetFunc->parameters()) {
1124 assert(ParamDecl !=
nullptr);
1128 if (InitialTargetFunc->getReturnType()->isRecordType())
1132 if (
const auto *MethodDecl = dyn_cast<CXXMethodDecl>(InitialTargetFunc)) {
1133 auto *Parent = MethodDecl->getParent();
1134 assert(Parent !=
nullptr);
1136 if (Parent->isLambda()) {
1137 for (
const auto &
Capture : Parent->captures()) {
1138 if (
Capture.capturesVariable()) {
1142 }
else if (
Capture.capturesThis()) {
1143 if (
auto *Ancestor = InitialTargetFunc->getNonClosureAncestor()) {
1146 SurroundingMethodDecl->getFunctionObjectParameterType();
1149 }
else if (
auto *FieldBeingInitialized =
1150 dyn_cast<FieldDecl>(Parent->getLambdaContextDecl())) {
1158 assert(
false &&
"Unexpected this-capturing lambda context.");
1162 }
else if (MethodDecl->isImplicitObjectMemberFunction()) {
1163 QualType ThisPointeeType = MethodDecl->getFunctionObjectParameterType();
1178 std::make_shared<PrValueToResultObject>(buildResultObjectMap(
1180 LocForRecordReturnVal));
1183 std::make_shared<ThisExprOverridesMap>(buildThisExprOverridesMap(
1191void Environment::initFieldsGlobalsAndFuncs(
const ReferencedDecls &Referenced) {
1194 DACtx->addModeledFields(Referenced.
Fields);
1218 Copy.BoolState->onFork();
1224 return CallStack.size() < MaxDepth && !llvm::is_contained(CallStack, Callee);
1230 if (
const auto *MethodCall = dyn_cast<CXXMemberCallExpr>(
Call)) {
1231 if (
const Expr *Arg = MethodCall->getImplicitObjectArgument()) {
1233 Env.ThisPointeeLoc =
1240 if (
Call->getType()->isRecordType() &&
Call->isPRValue())
1243 Env.pushCallInternal(
Call->getDirectCallee(),
1255 Env.pushCallInternal(
Call->getConstructor(),
1261void Environment::pushCallInternal(
const FunctionDecl *FuncDecl,
1269 CallStack.push_back(FuncDecl);
1277 for (
unsigned ArgIndex = 0; ArgIndex < Args.size(); ++ParamIt, ++ArgIndex) {
1278 assert(ParamIt != FuncDecl->
param_end());
1279 const VarDecl *Param = *ParamIt;
1283 ResultObjectMap = std::make_shared<PrValueToResultObject>(
1285 LocForRecordReturnVal));
1287 std::make_shared<ThisExprOverridesMap>(buildThisExprOverridesMap(
1299 this->LocToVal = std::move(CalleeEnv.LocToVal);
1300 this->BoolState = CalleeEnv.BoolState->clone();
1302 if (
Call->isGLValue()) {
1303 if (CalleeEnv.ReturnLoc !=
nullptr)
1305 }
else if (!
Call->getType()->isVoidType()) {
1306 if (CalleeEnv.ReturnVal !=
nullptr)
1314 this->LocToVal = std::move(CalleeEnv.LocToVal);
1315 this->BoolState = CalleeEnv.BoolState->clone();
1320 assert(DACtx ==
Other.DACtx);
1322 if (ReturnVal !=
Other.ReturnVal)
1325 if (ReturnLoc !=
Other.ReturnLoc)
1328 if (LocForRecordReturnVal !=
Other.LocForRecordReturnVal)
1331 if (ThisPointeeLoc !=
Other.ThisPointeeLoc)
1334 if (DeclToLoc !=
Other.DeclToLoc)
1337 if (ExprToLoc !=
Other.ExprToLoc)
1345 if (!BoolState->isEquivalentTo(*
Other.BoolState))
1353 assert(DACtx == PrevEnv.DACtx);
1354 assert(ReturnVal == PrevEnv.ReturnVal);
1355 assert(ReturnLoc == PrevEnv.ReturnLoc);
1356 assert(LocForRecordReturnVal == PrevEnv.LocForRecordReturnVal);
1357 assert(ThisPointeeLoc == PrevEnv.ThisPointeeLoc);
1358 assert(ThisExprOverrides == PrevEnv.ThisExprOverrides);
1359 assert(CallStack == PrevEnv.CallStack);
1360 assert(ResultObjectMap == PrevEnv.ResultObjectMap);
1361 assert(InitialTargetFunc == PrevEnv.InitialTargetFunc);
1362 assert(InitialTargetStmt == PrevEnv.InitialTargetStmt);
1372 assert(DeclToLoc.size() <= PrevEnv.DeclToLoc.size());
1373 assert(ExprToVal.size() <= PrevEnv.ExprToVal.size());
1374 assert(ExprToLoc.size() <= PrevEnv.ExprToLoc.size());
1383 if (DeclToLoc.size() != PrevEnv.DeclToLoc.size() ||
1384 ExprToLoc.size() != PrevEnv.ExprToLoc.size() ||
1385 ExprToVal.size() != PrevEnv.ExprToVal.size() ||
1386 LocToVal.size() != PrevEnv.LocToVal.size())
1395 assert(EnvA.DACtx == EnvB.DACtx);
1396 assert(EnvA.LocForRecordReturnVal == EnvB.LocForRecordReturnVal);
1397 assert(EnvA.ThisPointeeLoc == EnvB.ThisPointeeLoc);
1398 assert(EnvA.ThisExprOverrides == EnvB.ThisExprOverrides);
1399 assert(EnvA.CallStack == EnvB.CallStack);
1400 assert(EnvA.ResultObjectMap == EnvB.ResultObjectMap);
1401 assert(EnvA.InitialTargetFunc == EnvB.InitialTargetFunc);
1402 assert(EnvA.InitialTargetStmt == EnvB.InitialTargetStmt);
1406 JoinedEnv.CallStack = EnvA.CallStack;
1407 JoinedEnv.ResultObjectMap = EnvA.ResultObjectMap;
1408 JoinedEnv.LocForRecordReturnVal = EnvA.LocForRecordReturnVal;
1409 JoinedEnv.ThisPointeeLoc = EnvA.ThisPointeeLoc;
1410 JoinedEnv.ThisExprOverrides = EnvA.ThisExprOverrides;
1411 JoinedEnv.InitialTargetFunc = EnvA.InitialTargetFunc;
1412 JoinedEnv.InitialTargetStmt = EnvA.InitialTargetStmt;
1416 JoinedEnv.ReturnVal =
nullptr;
1418 JoinedEnv.ReturnVal =
1419 joinValues(
Func->getReturnType(), EnvA.ReturnVal, EnvA, EnvB.ReturnVal,
1420 EnvB, JoinedEnv, Model);
1423 if (EnvA.ReturnLoc == EnvB.ReturnLoc)
1424 JoinedEnv.ReturnLoc = EnvA.ReturnLoc;
1426 JoinedEnv.ReturnLoc =
nullptr;
1430 JoinedEnv.BoolState->join(*EnvA.BoolState, *EnvB.BoolState);
1432 JoinedEnv.LocToVal =
1433 joinLocToVal(EnvA.LocToVal, EnvB.LocToVal, EnvA, EnvB, JoinedEnv, Model);
1436 JoinedEnv.ExprToVal =
joinExprMaps(EnvA.ExprToVal, EnvB.ExprToVal);
1437 JoinedEnv.ExprToLoc =
joinExprMaps(EnvA.ExprToLoc, EnvB.ExprToLoc);
1447 if (Val1 ==
nullptr || Val2 ==
nullptr)
1462 return DACtx->createStorageLocation(
Type);
1469 return DACtx->getStableStorageLocation(D);
1476 return DACtx->getStableStorageLocation(E);
1480 assert(!DeclToLoc.contains(&D));
1487 DeclToLoc[&D] = &Loc;
1491 auto It = DeclToLoc.find(&D);
1492 if (It == DeclToLoc.end())
1509 assert(!ExprToLoc.contains(&CanonE));
1510 ExprToLoc[&CanonE] = &Loc;
1518 return It == ExprToLoc.end() ?
nullptr : &*It->second;
1526 assert(ResultObjectMap !=
nullptr);
1528 assert(Loc !=
nullptr);
1533 DACtx->getStableStorageLocation(RecordPRValue));
1538 return DACtx->getOrCreateNullPointerValue(PointeeType);
1543 llvm::DenseSet<QualType> Visited;
1544 int CreatedValuesCount = 0;
1547 llvm::errs() <<
"Attempting to initialize a huge value of type: " <<
Type
1555 LocToVal[&Loc] = &Val;
1564 ExprToVal[&CanonE] = &Val;
1570 return LocToVal.lookup(&Loc);
1586 return It == ExprToVal.end() ?
nullptr : It->second;
1590 if (It == ExprToLoc.end())
1596 llvm::DenseSet<QualType> Visited;
1597 int CreatedValuesCount = 0;
1598 Value *Val = createValueUnlessSelfReferential(
Type, Visited, 0,
1599 CreatedValuesCount);
1601 llvm::errs() <<
"Attempting to initialize a huge value of type: " <<
Type
1607Value *Environment::createValueUnlessSelfReferential(
1608 QualType Type, llvm::DenseSet<QualType> &Visited,
int Depth,
1609 int &CreatedValuesCount) {
1610 assert(!
Type.isNull());
1620 CreatedValuesCount++;
1628 CreatedValuesCount++;
1632 if (Type->isPointerType()) {
1633 CreatedValuesCount++;
1634 QualType PointeeType = Type->getPointeeType();
1635 StorageLocation &PointeeLoc =
1636 createLocAndMaybeValue(PointeeType, Visited, Depth, CreatedValuesCount);
1645Environment::createLocAndMaybeValue(QualType Ty,
1646 llvm::DenseSet<QualType> &Visited,
1647 int Depth,
int &CreatedValuesCount) {
1648 if (!Visited.insert(Ty.getCanonicalType()).second)
1650 llvm::scope_exit EraseVisited(
1651 [&Visited, Ty] { Visited.erase(Ty.getCanonicalType()); });
1653 Ty = Ty.getNonReferenceType();
1655 if (Ty->isRecordType()) {
1663 if (
Value *Val = createValueUnlessSelfReferential(Ty, Visited, Depth,
1664 CreatedValuesCount))
1672 llvm::DenseSet<QualType> &Visited,
1674 int &CreatedValuesCount) {
1675 auto initField = [&](QualType FieldType, StorageLocation &FieldLoc) {
1676 if (FieldType->isRecordType()) {
1679 Visited, Depth + 1, CreatedValuesCount);
1683 if (!Visited.insert(FieldType.getCanonicalType()).second)
1685 if (
Value *Val = createValueUnlessSelfReferential(
1686 FieldType, Visited, Depth + 1, CreatedValuesCount))
1688 Visited.erase(FieldType.getCanonicalType());
1692 for (
const FieldDecl *Field : DACtx->getModeledFields(
Type)) {
1693 assert(Field !=
nullptr);
1694 QualType FieldType =
Field->getType();
1696 if (FieldType->isReferenceType()) {
1697 Loc.setChild(*Field,
1698 &createLocAndMaybeValue(FieldType, Visited, Depth + 1,
1699 CreatedValuesCount));
1701 StorageLocation *FieldLoc = Loc.getChild(*Field);
1702 assert(FieldLoc !=
nullptr);
1706 for (
const auto &[FieldName, FieldType] : DACtx->getSyntheticFields(
Type)) {
1709 assert(!FieldType->isReferenceType());
1710 initField(FieldType, Loc.getSyntheticField(FieldName));
1716 const Expr *InitExpr) {
1717 if (Ty->isReferenceType()) {
1723 return *InitExprLoc;
1730 return createObjectInternal(D, Ty.getNonReferenceType(),
nullptr);
1733 StorageLocation &Loc =
1736 if (Ty->isRecordType()) {
1737 auto &RecordLoc = cast<RecordStorageLocation>(Loc);
1739 initializeFieldsWithValues(RecordLoc);
1741 Value *Val = nullptr;
1756 Val = getValue(*InitExpr);
1758 Val = createValue(Ty);
1760 setValue(Loc, *Val);
1769 return BoolState->proves(F);
1773 return BoolState->allows(F);
1777 llvm::DenseMap<const StorageLocation *, std::string> LocToName;
1778 if (LocForRecordReturnVal !=
nullptr)
1779 LocToName[LocForRecordReturnVal] =
"(returned record)";
1780 if (ThisPointeeLoc !=
nullptr)
1781 LocToName[ThisPointeeLoc] =
"this";
1783 OS <<
"DeclToLoc:\n";
1784 for (
auto [D, L] : DeclToLoc) {
1785 auto Iter = LocToName.insert({L, D->getNameAsString()}).first;
1786 OS <<
" [" << Iter->second <<
", " << L <<
"]\n";
1788 OS <<
"ExprToLoc:\n";
1789 for (
auto [E, L] : ExprToLoc)
1790 OS <<
" [" << E <<
", " << L <<
"]\n";
1792 OS <<
"ExprToVal:\n";
1793 for (
auto [E,
V] : ExprToVal)
1794 OS <<
" [" << E <<
", " <<
V <<
": " << *
V <<
"]\n";
1796 OS <<
"LocToVal:\n";
1797 for (
auto [L,
V] : LocToVal) {
1799 if (
auto Iter = LocToName.find(L); Iter != LocToName.end())
1800 OS <<
" (" << Iter->second <<
")";
1801 OS <<
", " <<
V <<
": " << *
V <<
"]\n";
1805 if (
Func->getReturnType()->isReferenceType()) {
1806 OS <<
"ReturnLoc: " << ReturnLoc;
1807 if (
auto Iter = LocToName.find(ReturnLoc); Iter != LocToName.end())
1808 OS <<
" (" << Iter->second <<
")";
1810 }
else if (
Func->getReturnType()->isRecordType() ||
1812 OS <<
"LocForRecordReturnVal: " << LocForRecordReturnVal <<
"\n";
1813 }
else if (!
Func->getReturnType()->isVoidType()) {
1814 if (ReturnVal ==
nullptr)
1815 OS <<
"ReturnVal: nullptr\n";
1817 OS <<
"ReturnVal: " << *ReturnVal <<
"\n";
1821 OS <<
"ThisPointeeLoc: " << ThisPointeeLoc <<
"\n";
1826 BoolState->dump(OS);
1831Environment::PrValueToResultObject Environment::buildResultObjectMap(
1837 PrValueToResultObject Map = buildResultObjectMap(
1838 DACtx, FuncDecl->
getBody(), ThisPointeeLoc, LocForRecordReturnVal);
1840 ResultObjectVisitor Visitor(Map, LocForRecordReturnVal, *DACtx);
1841 if (
const auto *Ctor = dyn_cast<CXXConstructorDecl>(FuncDecl))
1842 Visitor.traverseConstructorInits(Ctor, ThisPointeeLoc);
1847Environment::PrValueToResultObject Environment::buildResultObjectMap(
1848 DataflowAnalysisContext *DACtx,
Stmt *S,
1849 RecordStorageLocation *ThisPointeeLoc,
1850 RecordStorageLocation *LocForRecordReturnVal) {
1851 PrValueToResultObject Map;
1852 ResultObjectVisitor Visitor(Map, LocForRecordReturnVal, *DACtx);
1853 Visitor.TraverseStmt(S);
1857Environment::ThisExprOverridesMap Environment::buildThisExprOverridesMap(
1858 const FunctionDecl *FuncDecl, RecordStorageLocation *ThisPointeeLoc,
1859 const PrValueToResultObject &ResultObjectMap) {
1860 assert(FuncDecl->doesThisDeclarationHaveABody());
1862 ThisExprOverridesMap Map = buildThisExprOverridesMap(
1863 FuncDecl->getBody(), ThisPointeeLoc, ResultObjectMap);
1865 ThisExprOverridesVisitor Visitor(ThisPointeeLoc, ResultObjectMap, Map);
1866 if (
const auto *Ctor = dyn_cast<CXXConstructorDecl>(FuncDecl)) {
1867 Visitor.traverseConstructorInits(Ctor);
1872Environment::ThisExprOverridesMap Environment::buildThisExprOverridesMap(
1874 const PrValueToResultObject &ResultObjectMap) {
1875 ThisExprOverridesMap Map;
1876 ThisExprOverridesVisitor Visitor(ThisPointeeLoc, ResultObjectMap, Map);
1877 Visitor.TraverseStmt(S);
1884 if (ImplicitObject ==
nullptr)
1891 return cast_or_null<RecordStorageLocation>(
1898 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)
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)
@ Other
Other implicit parameter.
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.