28#include "llvm/ADT/ImmutableMap.h"
29#include "llvm/ADT/STLExtras.h"
30#include "llvm/Support/TimeProfiler.h"
31#include "llvm/Support/raw_ostream.h"
53 llvm::PointerIntPair<const MemRegion *, 2> P;
58 explicit BindingKey(
const SubRegion *r,
const SubRegion *Base, Kind k)
59 : P(r, k | Symbolic), Data(reinterpret_cast<
uintptr_t>(
Base)) {
60 assert(r && Base &&
"Must have known regions.");
61 assert(getConcreteOffsetRegion() == Base &&
"Failed to store base region");
65 explicit BindingKey(
const MemRegion *r,
uint64_t offset, Kind k)
66 : P(r, k), Data(offset) {
67 assert(r &&
"Must have known regions.");
68 assert(getOffset() == offset &&
"Failed to store offset");
75 bool isDirect()
const {
return P.getInt() & Direct; }
76 bool isDefault()
const {
return !isDirect(); }
77 bool hasSymbolicOffset()
const {
return P.getInt() & Symbolic; }
79 const MemRegion *getRegion()
const {
return P.getPointer(); }
81 assert(!hasSymbolicOffset());
85 const SubRegion *getConcreteOffsetRegion()
const {
86 assert(hasSymbolicOffset());
87 return reinterpret_cast<const SubRegion *
>(
static_cast<uintptr_t>(Data));
90 const MemRegion *getBaseRegion()
const {
91 if (hasSymbolicOffset())
92 return getConcreteOffsetRegion()->getBaseRegion();
93 return getRegion()->getBaseRegion();
96 void Profile(llvm::FoldingSetNodeID& ID)
const {
97 ID.AddPointer(P.getOpaqueValue());
101 static BindingKey
Make(
const MemRegion *R, Kind k);
104 if (P.getOpaqueValue() <
X.P.getOpaqueValue())
106 if (P.getOpaqueValue() >
X.P.getOpaqueValue())
108 return Data <
X.Data;
112 return P.getOpaqueValue() ==
X.P.getOpaqueValue() &&
116 LLVM_DUMP_METHOD
void dump()
const;
119std::string locDescr(
Loc L) {
121 llvm::raw_string_ostream
OS(S);
127BindingKey BindingKey::Make(
const MemRegion *R, Kind k) {
128 const RegionOffset &RO =
R->getAsOffset();
136static inline raw_ostream &
operator<<(raw_ostream &Out, BindingKey K) {
137 Out <<
"\"kind\": \"" << (K.isDirect() ?
"Direct" :
"Default")
138 <<
"\", \"offset\": ";
140 if (!K.hasSymbolicOffset())
141 Out << K.getOffset();
150#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
151void BindingKey::dump()
const { llvm::errs() << *
this; }
162typedef llvm::ImmutableMap<const MemRegion *, ClusterBindings>
166class RegionBindingsRef :
public llvm::ImmutableMapRef<const MemRegion *,
168 ClusterBindings::Factory *CBFactory;
182 typedef llvm::ImmutableMapRef<const MemRegion *, ClusterBindings>
185 RegionBindingsRef(ClusterBindings::Factory &CBFactory,
186 const RegionBindings::TreeTy *
T,
187 RegionBindings::TreeTy::Factory *F,
bool IsMainAnalysis)
188 : RegionBindingsRef(ParentTy(
T, F), CBFactory, IsMainAnalysis) {}
190 RegionBindingsRef(
const ParentTy &P, ClusterBindings::Factory &CBFactory,
192 : ParentTy(P), CBFactory(&CBFactory), IsMainAnalysis(IsMainAnalysis) {}
194 RegionBindingsRef removeCluster(
const MemRegion *BaseRegion)
const {
195 return RegionBindingsRef(ParentTy::remove(BaseRegion), *CBFactory,
199 template <
typename PredFn>
200 RegionBindingsRef filterClusters(PredFn Pred)
const {
201 return RegionBindingsRef(ParentTy::filter(Pred), *CBFactory,
205 RegionBindingsRef addBinding(BindingKey K,
SVal V)
const;
207 RegionBindingsRef addBinding(
const MemRegion *R,
208 BindingKey::Kind k,
SVal V)
const;
210 const SVal *lookup(BindingKey K)
const;
211 const SVal *lookup(
const MemRegion *R, BindingKey::Kind k)
const;
214 RegionBindingsRef removeBinding(BindingKey K);
216 RegionBindingsRef removeBinding(
const MemRegion *R,
219 RegionBindingsRef removeBinding(
const MemRegion *R) {
220 return removeBinding(R, BindingKey::Direct).
221 removeBinding(R, BindingKey::Default);
224 std::optional<SVal> getDirectBinding(
const MemRegion *R)
const;
228 std::optional<SVal> getDefaultBinding(
const MemRegion *R)
const;
231 Store asStore()
const {
232 llvm::PointerIntPair<Store, 1, bool> Ptr = {
233 asImmutableMap().getRootWithoutRetain(), IsMainAnalysis};
234 return reinterpret_cast<Store>(Ptr.getOpaqueValue());
237 bool isMainAnalysis()
const {
238 return IsMainAnalysis;
241 void printJson(raw_ostream &Out,
const char *NL =
"\n",
242 unsigned int Space = 0,
bool IsDot =
false)
const {
243 using namespace llvm;
244 DenseMap<const MemRegion *, std::string> StringifyCache;
245 auto ToString = [&StringifyCache](
const MemRegion *R) {
246 auto [Place, Inserted] = StringifyCache.try_emplace(R);
248 return Place->second;
250 raw_string_ostream
OS(Res);
257 std::pair<const MemRegion *, ImmutableMap<BindingKey, SVal>>;
258 using Binding = std::pair<BindingKey, SVal>;
260 const auto MemSpaceBeforeRegionName = [&ToString](
const Cluster *L,
266 return ToString(L->first) < ToString(R->first);
269 const auto SymbolicBeforeOffset = [&ToString](
const BindingKey &L,
270 const BindingKey &R) {
271 if (L.hasSymbolicOffset() && !R.hasSymbolicOffset())
273 if (!L.hasSymbolicOffset() && R.hasSymbolicOffset())
275 if (L.hasSymbolicOffset() && R.hasSymbolicOffset())
276 return ToString(L.getRegion()) < ToString(R.getRegion());
277 return L.getOffset() < R.getOffset();
280 const auto DefaultBindingBeforeDirectBindings =
281 [&SymbolicBeforeOffset](
const Binding *LPtr,
const Binding *RPtr) {
282 const BindingKey &L = LPtr->first;
283 const BindingKey &R = RPtr->first;
284 if (L.isDefault() && !R.isDefault())
286 if (!L.isDefault() && R.isDefault())
288 assert(L.isDefault() == R.isDefault());
289 return SymbolicBeforeOffset(L, R);
292 const auto AddrOf = [](
const auto &Item) {
return &Item; };
294 std::vector<const Cluster *> SortedClusters;
295 SortedClusters.reserve(std::distance(begin(), end()));
296 append_range(SortedClusters, map_range(*
this, AddrOf));
297 llvm::sort(SortedClusters, MemSpaceBeforeRegionName);
299 for (
auto [Idx,
C] : llvm::enumerate(SortedClusters)) {
302 <<
"{ \"cluster\": \"" << BaseRegion <<
"\", \"pointer\": \""
303 << (
const void *)BaseRegion <<
"\", \"items\": [" << NL;
305 std::vector<const Binding *> SortedBindings;
307 append_range(SortedBindings, map_range(
Bindings, AddrOf));
308 llvm::sort(SortedBindings, DefaultBindingBeforeDirectBindings);
311 for (
auto [Idx, B] : llvm::enumerate(SortedBindings)) {
312 const auto &[Key,
Value] = *B;
313 Indent(Out, Space, IsDot) <<
"{ " << Key <<
", \"value\": ";
314 Value.printJson(Out,
true);
316 if (Idx != SortedBindings.size() - 1)
321 Indent(Out, Space, IsDot) <<
"]}";
322 if (Idx != SortedClusters.size() - 1)
328 LLVM_DUMP_METHOD
void dump()
const { printJson(llvm::errs()); }
332 commitBindingsToCluster(
const MemRegion *BaseRegion,
343 std::optional<unsigned> BindingsLeft)
344 : RegionBindingsRef(
Base),
345 EscapedValuesDuringBind(&EscapedValuesDuringBind),
346 BindingsLeft(BindingsLeft) {}
349 return BindingsLeft.has_value() && BindingsLeft.value() == 0;
353 EscapedValuesDuringBind->push_back(
V);
360 for (
SVal V : llvm::make_range(Begin, End))
367 data_type_ref BindingKeyAndValue)
const {
369 BaseRegion, BindingKeyAndValue),
370 *EscapedValuesDuringBind, BindingsLeft};
375 RegionBindingsRef::removeCluster(BaseRegion), *EscapedValuesDuringBind,
380 std::optional<unsigned> NewBindingsLeft = BindingsLeft;
381 if (NewBindingsLeft.has_value()) {
382 assert(NewBindingsLeft.value() != 0);
383 NewBindingsLeft.value() -= 1;
387 if (NewBindingsLeft.value() == 0) {
389 K = BindingKey::Make(K.getRegion(), BindingKey::Default);
395 *EscapedValuesDuringBind, NewBindingsLeft};
405 std::optional<unsigned> BindingsLeft;
412RegionBindingsRef::getDirectBinding(
const MemRegion *R)
const {
413 const SVal *
V = lookup(R, BindingKey::Direct);
414 return V ? std::optional<SVal>(*
V) : std::nullopt;
418RegionBindingsRef::getDefaultBinding(
const MemRegion *R)
const {
419 const SVal *
V = lookup(R, BindingKey::Default);
420 return V ? std::optional<SVal>(*
V) : std::nullopt;
423RegionBindingsRef RegionBindingsRef::commitBindingsToCluster(
425 return RegionBindingsRef(ParentTy::add(BaseRegion,
Bindings), *CBFactory,
429RegionBindingsRef RegionBindingsRef::addBinding(BindingKey K, SVal
V)
const {
430 const MemRegion *
Base = K.getBaseRegion();
434 (ExistingCluster ? *ExistingCluster : CBFactory->getEmptyMap());
436 return commitBindingsToCluster(Base,
Bindings);
439RegionBindingsRef RegionBindingsRef::addBinding(
const MemRegion *R,
442 return addBinding(BindingKey::Make(R, k),
V);
445const SVal *RegionBindingsRef::lookup(BindingKey K)
const {
449 return Cluster->lookup(K);
452const SVal *RegionBindingsRef::lookup(
const MemRegion *R,
453 BindingKey::Kind k)
const {
454 return lookup(BindingKey::Make(R, k));
457RegionBindingsRef RegionBindingsRef::removeBinding(BindingKey K) {
458 const MemRegion *
Base = K.getBaseRegion();
464 if (NewCluster.isEmpty())
465 return removeCluster(Base);
466 return commitBindingsToCluster(Base, NewCluster);
469RegionBindingsRef RegionBindingsRef::removeBinding(
const MemRegion *R,
471 return removeBinding(BindingKey::Make(R, k));
479class InvalidateRegionsWorker;
481class RegionStoreManager final :
public StoreManager {
483 RegionBindings::Factory RBFactory;
484 mutable ClusterBindings::Factory CBFactory;
486 typedef std::vector<SVal> SValListTy;
488 typedef llvm::DenseMap<
const LazyCompoundValData *,
489 SValListTy> LazyBindingsMapTy;
490 LazyBindingsMapTy LazyBindingsMap;
500 const unsigned SmallStructLimit;
510 const unsigned SmallArrayLimit;
516 const std::optional<unsigned> RegionStoreMaxBindingFanOutPlusOne;
520 void populateWorkList(InvalidateRegionsWorker &W,
521 ArrayRef<SVal> Values,
522 InvalidatedRegions *TopLevelRegions);
524 const AnalyzerOptions &getOptions() {
525 return StateMgr.getOwningEngine().getAnalysisManager().options;
529 RegionStoreManager(ProgramStateManager &mgr)
530 : StoreManager(mgr), RBFactory(mgr.getAllocator()),
531 CBFactory(mgr.getAllocator()),
532 SmallStructLimit(getOptions().RegionStoreSmallStructLimit),
533 SmallArrayLimit(getOptions().RegionStoreSmallArrayLimit),
534 RegionStoreMaxBindingFanOutPlusOne([&]() -> std::optional<
unsigned> {
535 unsigned FanOut = getOptions().RegionStoreMaxBindingFanOut;
536 assert(FanOut != std::numeric_limits<unsigned>::max());
545 LimitedRegionBindingsRef
555 SVal ArrayToPointer(Loc
Array, QualType ElementTy)
override;
559 StoreRef getInitialStore(
const StackFrame *SF)
override {
560 bool IsMainAnalysis =
false;
561 if (
const auto *FD = dyn_cast<FunctionDecl>(SF->
getDecl()))
562 IsMainAnalysis = FD->isMain() && !Ctx.getLangOpts().CPlusPlus;
563 return StoreRef(RegionBindingsRef(RegionBindingsRef::ParentTy(
564 RBFactory.getEmptyMap(), RBFactory),
565 CBFactory, IsMainAnalysis)
575 unsigned Count,
const StackFrame *SF,
577 InvalidatedRegions *Invalidated);
579 StoreRef invalidateRegions(
Store store, ArrayRef<SVal> Values,
581 const StackFrame *SF,
const CallEvent *
Call,
583 RegionAndSymbolInvalidationTraits &ITraits,
584 InvalidatedRegions *Invalidated,
585 InvalidatedRegions *InvalidatedTopLevel)
override;
587 bool scanReachableSymbols(
Store S,
const MemRegion *R,
588 ScanReachableSymbols &Callbacks)
override;
590 LimitedRegionBindingsRef
594 const ElementRegion *R);
595 std::optional<SVal> getConstantValFromInitializer(
const FieldRegion *R,
596 bool IsMainAnalysis);
598 getSValFromInitListExpr(
const InitListExpr *ILE,
599 const SmallVector<uint64_t, 2> &ConcreteOffsets,
601 SVal getSValFromStringLiteral(
const StringLiteral *SL,
uint64_t Offset,
605 BindResult
Bind(
Store store, Loc LV, SVal
V)
override {
606 llvm::SmallVector<SVal, 0> EscapedValuesDuringBind;
607 LimitedRegionBindingsRef BoundedBindings =
608 getRegionBindings(store, EscapedValuesDuringBind);
609 return BindResult{StoreRef(bind(BoundedBindings, LV,
V).asStore(), *
this),
610 std::move(EscapedValuesDuringBind)};
618 BindResult BindDefaultInitial(
Store store,
const MemRegion *R,
620 RegionBindingsRef B = getRegionBindings(store);
623 assert(!(B.getDefaultBinding(R) || B.getDirectBinding(R)) &&
624 "Double initialization!");
625 B = B.addBinding(BindingKey::Make(R, BindingKey::Default),
V);
627 StoreRef(B.asImmutableMap().getRootWithoutRetain(), *
this), {}};
632 BindResult BindDefaultZero(
Store store,
const MemRegion *R)
override {
642 if (
const auto *BR = dyn_cast<CXXBaseObjectRegion>(R))
643 if (BR->getDecl()->isEmpty())
644 return BindResult{StoreRef(store, *
this), {}};
646 llvm::SmallVector<SVal, 0> EscapedValuesDuringBind;
647 LimitedRegionBindingsRef B =
648 getRegionBindings(store, EscapedValuesDuringBind);
649 SVal
V = svalBuilder.makeZeroVal(Ctx.CharTy);
651 B = B.
addBinding(BindingKey::Make(R, BindingKey::Default),
V);
653 StoreRef(B.asImmutableMap().getRootWithoutRetain(), *
this),
654 std::move(EscapedValuesDuringBind)};
667 std::optional<LimitedRegionBindingsRef>
669 const RecordDecl *RD, nonloc::LazyCompoundVal LCV);
673 const TypedValueRegion *R, SVal
V);
677 const TypedValueRegion *R, SVal
V);
679 std::optional<LimitedRegionBindingsRef>
681 const ArrayType *AT, nonloc::LazyCompoundVal LCV);
684 const TypedValueRegion *R, SVal
V);
689 const TypedRegion *R, SVal DefaultVal);
694 StoreRef killBinding(
Store ST, Loc L)
override;
696 void incrementReferenceCount(
Store store)
override {
697 if (RegionBindings::TreeTy *
T = getRegionBindingsTree(store))
704 void decrementReferenceCount(
Store store)
override {
705 if (RegionBindings::TreeTy *
T = getRegionBindingsTree(store))
709 bool includedInBindings(
Store store,
const MemRegion *region)
const override;
724 SVal getBinding(
Store S, Loc L, QualType
T)
override {
725 return getBinding(getRegionBindings(S), L,
T);
728 std::optional<SVal> getDefaultBinding(
Store S,
const MemRegion *R)
override {
729 RegionBindingsRef B = getRegionBindings(S);
733 return B.getDefaultBinding(
R->getBaseRegion());
746 SVal getBindingForLazySymbol(
const TypedValueRegion *R);
749 const TypedValueRegion *R,
752 SVal getLazyBinding(
const SubRegion *LazyBindingRegion,
753 RegionBindingsRef LazyBinding);
771 const MemRegion *superR,
772 const TypedValueRegion *R, QualType Ty);
778 std::pair<Store, const SubRegion *>
780 const SubRegion *originalRegion);
792 const SValListTy &getInterestingValues(nonloc::LazyCompoundVal LCV);
800 StoreRef removeDeadBindings(
Store store,
const StackFrame *SF,
801 SymbolReaper &SymReaper)
override;
807 RegionBindingsRef getRegionBindings(
Store store)
const {
808 llvm::PointerIntPair<Store, 1, bool>
Ptr;
809 Ptr.setFromOpaqueValue(
const_cast<void *
>(store));
811 static_cast<const RegionBindings::TreeTy *
>(
Ptr.getPointer()),
812 RBFactory.getTreeFactory(),
Ptr.getInt()};
815 static RegionBindings::TreeTy *getRegionBindingsTree(
Store store) {
816 llvm::PointerIntPair<Store, 1, bool>
Ptr;
817 Ptr.setFromOpaqueValue(
const_cast<void *
>(store));
818 return static_cast<RegionBindings::TreeTy *
>(
819 const_cast<void *
>(
Ptr.getPointer()));
822 LimitedRegionBindingsRef
823 getRegionBindings(
Store store,
824 SmallVectorImpl<SVal> &EscapedValuesDuringBind)
const {
825 return LimitedRegionBindingsRef(
826 getRegionBindings(store), EscapedValuesDuringBind,
827 RegionStoreMaxBindingFanOutPlusOne);
830 void printJson(raw_ostream &Out,
Store S,
const char *NL =
"\n",
831 unsigned int Space = 0,
bool IsDot =
false)
const override;
833 void iterBindings(
Store store, BindingsHandler& f)
override {
834 RegionBindingsRef B = getRegionBindings(store);
835 for (
const auto &[Region, Cluster] : B) {
836 for (
const auto &[Key,
Value] : Cluster) {
839 if (
const SubRegion *R = dyn_cast<SubRegion>(Key.getRegion())) {
841 if (!f.HandleBinding(*
this, store, R,
Value))
855std::unique_ptr<StoreManager>
857 return std::make_unique<RegionStoreManager>(StMgr);
867enum GlobalsFilterKind {
876template <
typename DERIVED>
877class ClusterAnalysis {
879 typedef llvm::DenseMap<const MemRegion *, const ClusterBindings *> ClusterMap;
880 typedef const MemRegion * WorkListElement;
887 RegionStoreManager &RM;
902 bool includeEntireMemorySpace(
const MemRegion *Base) {
907 ClusterAnalysis(RegionStoreManager &rm, ProgramStateManager &StateMgr,
909 : RM(rm), Ctx(StateMgr.getContext()),
910 svalBuilder(StateMgr.getSValBuilder()), B(std::move(b)) {}
912 RegionBindingsRef getRegionBindings()
const {
return B; }
916 void GenerateClusters() {
918 for (RegionBindingsRef::iterator RI = B.begin(), RE = B.end();
920 const MemRegion *
Base = RI.getKey();
923 assert(!Cluster.isEmpty() &&
"Empty clusters should be removed");
924 static_cast<DERIVED*
>(
this)->VisitAddedToCluster(Base, Cluster);
928 if (
static_cast<DERIVED*
>(
this)->includeEntireMemorySpace(Base))
929 AddToWorkList(WorkListElement(Base), &Cluster);
934 if (
C && !Visited.insert(
C).second)
940 bool AddToWorkList(
const MemRegion *R) {
941 return static_cast<DERIVED*
>(
this)->AddToWorkList(R);
945 while (!WL.empty()) {
946 WorkListElement E = WL.pop_back_val();
947 const MemRegion *BaseR = E;
949 static_cast<DERIVED*
>(
this)->VisitCluster(BaseR, getCluster(BaseR));
953 void VisitAddedToCluster(
const MemRegion *baseR,
const ClusterBindings &
C) {}
958 static_cast<DERIVED*
>(
this)->VisitCluster(BaseR,
C);
967bool RegionStoreManager::scanReachableSymbols(
Store S,
const MemRegion *R,
968 ScanReachableSymbols &Callbacks) {
969 assert(R ==
R->getBaseRegion() &&
"Should only be called for base regions");
970 RegionBindingsRef B = getRegionBindings(S);
976 for (ClusterBindings::iterator RI = Cluster->begin(), RE = Cluster->end();
978 if (!Callbacks.
scan(RI.getData()))
992 assert(K.hasSymbolicOffset() &&
"Not implemented for concrete offset keys");
998 if (
const FieldRegion *FR = dyn_cast<FieldRegion>(R))
1000 Fields.push_back(FR->getDecl());
1007 assert(K.hasSymbolicOffset() &&
"Not implemented for concrete offset keys");
1015 ptrdiff_t Delta = FieldsInBindingKey.size() - Fields.size();
1017 return std::equal(FieldsInBindingKey.begin() + Delta,
1018 FieldsInBindingKey.end(),
1021 return std::equal(FieldsInBindingKey.begin(), FieldsInBindingKey.end(),
1022 Fields.begin() - Delta);
1037 const SubRegion *Top, BindingKey TopKey,
1038 bool IncludeAllDefaultBindings) {
1040 if (TopKey.hasSymbolicOffset()) {
1042 Top = TopKey.getConcreteOffsetRegion();
1043 TopKey = BindingKey::Make(Top, BindingKey::Default);
1049 if (std::optional<nonloc::ConcreteInt> ExtentCI =
1051 const llvm::APSInt &ExtentInt = ExtentCI->getValue();
1052 assert(ExtentInt.isNonNegative() || ExtentInt.isUnsigned());
1055 }
else if (
const FieldRegion *FR = dyn_cast<FieldRegion>(Top)) {
1056 if (FR->getDecl()->isBitField())
1057 Length = FR->getDecl()->getBitWidthValue();
1060 for (
const auto &StoreEntry : Cluster) {
1061 BindingKey NextKey = StoreEntry.first;
1062 if (NextKey.getRegion() == TopKey.getRegion()) {
1068 if (NextKey.getOffset() > TopKey.getOffset() &&
1069 NextKey.getOffset() - TopKey.getOffset() < Length) {
1074 }
else if (NextKey.getOffset() == TopKey.getOffset()) {
1081 if (IncludeAllDefaultBindings || NextKey.isDirect())
1085 }
else if (NextKey.hasSymbolicOffset()) {
1091 if (IncludeAllDefaultBindings || NextKey.isDirect())
1094 }
else if (
const SubRegion *BaseSR = dyn_cast<SubRegion>(
Base)) {
1097 if (BaseSR->isSubRegionOf(Top))
1108 const SubRegion *Top,
bool IncludeAllDefaultBindings) {
1110 BindingKey::Make(Top, BindingKey::Default),
1111 IncludeAllDefaultBindings);
1114LimitedRegionBindingsRef
1116 const SubRegion *Top) {
1117 BindingKey TopKey = BindingKey::Make(Top, BindingKey::Default);
1118 const MemRegion *ClusterHead = TopKey.getBaseRegion();
1120 if (Top == ClusterHead) {
1129 if (TopKey.hasSymbolicOffset()) {
1130 const SubRegion *Concrete = TopKey.getConcreteOffsetRegion();
1131 return B.
addBinding(Concrete, BindingKey::Default, UnknownVal());
1136 SmallVector<BindingPair, 32>
Bindings;
1141 for (BindingKey Key : llvm::make_first_range(
Bindings))
1148 if (TopKey.hasSymbolicOffset()) {
1149 const SubRegion *Concrete = TopKey.getConcreteOffsetRegion();
1150 Result =
Result.add(BindingKey::Make(Concrete, BindingKey::Default),
1160class InvalidateRegionsWorker :
public ClusterAnalysis<InvalidateRegionsWorker>
1164 const StackFrame *SF;
1166 RegionAndSymbolInvalidationTraits &ITraits;
1168 GlobalsFilterKind GlobalsFilter;
1170 InvalidateRegionsWorker(RegionStoreManager &rm, ProgramStateManager &stateMgr,
1172 unsigned count,
const StackFrame *SF,
1174 RegionAndSymbolInvalidationTraits &ITraitsIn,
1176 GlobalsFilterKind GFK)
1177 : ClusterAnalysis<InvalidateRegionsWorker>(rm, stateMgr, b), Elem(elem),
1178 Count(count), SF(SF), IS(
is), ITraits(ITraitsIn), Regions(r),
1179 GlobalsFilter(GFK) {}
1182 void VisitBinding(SVal
V);
1184 using ClusterAnalysis::AddToWorkList;
1186 bool AddToWorkList(
const MemRegion *R);
1190 bool includeEntireMemorySpace(
const MemRegion *Base);
1194 bool isInitiallyIncludedGlobalRegion(
const MemRegion *R);
1198bool InvalidateRegionsWorker::AddToWorkList(
const MemRegion *R) {
1199 bool doNotInvalidateSuperRegion = ITraits.
hasTrait(
1201 const MemRegion *BaseR = doNotInvalidateSuperRegion ?
R :
R->getBaseRegion();
1202 return AddToWorkList(WorkListElement(BaseR), getCluster(BaseR));
1205void InvalidateRegionsWorker::VisitBinding(SVal
V) {
1210 if (
const MemRegion *R =
V.getAsRegion()) {
1216 if (std::optional<nonloc::LazyCompoundVal> LCS =
1217 V.getAs<nonloc::LazyCompoundVal>()) {
1221 for (SVal
V : RM.getInterestingValues(*LCS))
1229void InvalidateRegionsWorker::VisitCluster(
const MemRegion *baseR,
1232 bool PreserveRegionsContents =
1237 for (SVal Val : llvm::make_second_range(*
C))
1241 if (!PreserveRegionsContents)
1245 if (
const auto *TO = dyn_cast<TypedValueRegion>(baseR)) {
1246 if (
const auto *RD = TO->getValueType()->getAsCXXRecordDecl()) {
1251 if (RD->isLambda() && RD->getLambdaCallOperator()->getBody()) {
1252 using namespace ast_matchers;
1254 const char *DeclBind =
"DeclBind";
1256 to(
varDecl(hasStaticStorageDuration()).bind(DeclBind)))));
1258 match(RefToStatic, *RD->getLambdaCallOperator()->getBody(),
1259 RD->getASTContext());
1261 for (BoundNodes &
Match : Matches) {
1262 auto *VD =
Match.getNodeAs<VarDecl>(DeclBind);
1263 const VarRegion *ToInvalidate =
1264 RM.getRegionManager().getVarRegion(VD, SF);
1265 AddToWorkList(ToInvalidate);
1273 if (
const BlockDataRegion *BR = dyn_cast<BlockDataRegion>(baseR)) {
1274 for (
auto Var : BR->referenced_vars()) {
1275 const VarRegion *VR = Var.getCapturedRegion();
1276 const VarDecl *VD = VR->
getDecl();
1286 SVal
V = RM.getBinding(B, loc::MemRegionVal(VR));
1287 if (std::optional<Loc> L =
V.getAs<Loc>()) {
1297 if (
const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(baseR))
1298 IS.insert(SR->getSymbol());
1301 if (PreserveRegionsContents)
1306 Regions->push_back(baseR);
1311 DefinedOrUnknownSVal
V =
1323 if (isInitiallyIncludedGlobalRegion(baseR)) {
1333 DefinedOrUnknownSVal
V =
1340 bool doNotInvalidateSuperRegion = ITraits.
hasTrait(
1344 if (doNotInvalidateSuperRegion) {
1347 std::optional<uint64_t> NumElements;
1350 if (
const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(AT))
1351 NumElements = CAT->getZExtSize();
1353 goto conjure_default;
1354 QualType ElementTy = AT->getElementType();
1362 AddToWorkList(SuperR);
1363 goto conjure_default;
1367 uint64_t UpperOffset = LowerOffset + *NumElements * ElemSize;
1368 bool UpperOverflow = UpperOffset < LowerOffset;
1373 goto conjure_default;
1377 goto conjure_default;
1379 for (
const auto &[BK,
V] : *
C) {
1380 std::optional<uint64_t> ROffset =
1381 BK.hasSymbolicOffset() ? std::optional<uint64_t>() : BK.getOffset();
1386 ((*ROffset >= LowerOffset && *ROffset < UpperOffset) ||
1388 (*ROffset >= LowerOffset || *ROffset < UpperOffset)) ||
1389 (LowerOffset == UpperOffset && *ROffset == LowerOffset))) {
1390 B = B.removeBinding(BK);
1393 const MemRegion *
R =
V.getAsRegion();
1394 if (isa_and_nonnull<SymbolicRegion>(R))
1402 baseR, Elem, SF, AT->getElementType(), Count);
1407 DefinedOrUnknownSVal
V =
1413bool InvalidateRegionsWorker::isInitiallyIncludedGlobalRegion(
1414 const MemRegion *R) {
1415 switch (GlobalsFilter) {
1418 case GFK_SystemOnly:
1424 llvm_unreachable(
"unknown globals filter");
1427bool InvalidateRegionsWorker::includeEntireMemorySpace(
const MemRegion *Base) {
1428 if (isInitiallyIncludedGlobalRegion(Base))
1431 const MemSpaceRegion *MemSpace =
Base->getRawMemorySpace();
1436RegionBindingsRef RegionStoreManager::invalidateGlobalRegion(
1438 const StackFrame *SF, RegionBindingsRef B,
1439 InvalidatedRegions *Invalidated) {
1442 const GlobalsSpaceRegion *GS = MRMgr.getGlobalsRegion(K);
1444 (
const void *)GS, Elem, SF,
1447 B = B.removeBinding(GS)
1448 .addBinding(BindingKey::Make(GS, BindingKey::Default),
V);
1453 Invalidated->push_back(GS);
1458void RegionStoreManager::populateWorkList(InvalidateRegionsWorker &W,
1459 ArrayRef<SVal> Values,
1460 InvalidatedRegions *TopLevelRegions) {
1461 for (SVal
V : Values) {
1462 if (
auto LCS =
V.getAs<nonloc::LazyCompoundVal>()) {
1463 for (SVal S : getInterestingValues(*LCS))
1464 if (
const MemRegion *R = S.getAsRegion())
1470 if (
const MemRegion *R =
V.getAsRegion()) {
1471 if (TopLevelRegions)
1472 TopLevelRegions->push_back(R);
1479StoreRef RegionStoreManager::invalidateRegions(
1482 RegionAndSymbolInvalidationTraits &ITraits,
1483 InvalidatedRegions *TopLevelRegions, InvalidatedRegions *Invalidated) {
1484 GlobalsFilterKind GlobalsFilter;
1486 if (
Call->isInSystemHeader())
1487 GlobalsFilter = GFK_SystemOnly;
1489 GlobalsFilter = GFK_All;
1491 GlobalsFilter = GFK_None;
1494 RegionBindingsRef B = getRegionBindings(store);
1495 InvalidateRegionsWorker W(*
this, StateMgr, B, Elem, Count, SF, IS, ITraits,
1496 Invalidated, GlobalsFilter);
1499 W.GenerateClusters();
1502 populateWorkList(W, Values, TopLevelRegions);
1507 B = W.getRegionBindings();
1513 switch (GlobalsFilter) {
1515 B = invalidateGlobalRegion(MemRegion::GlobalInternalSpaceRegionKind, Elem,
1516 Count, SF, B, Invalidated);
1518 case GFK_SystemOnly:
1519 B = invalidateGlobalRegion(MemRegion::GlobalSystemSpaceRegionKind, Elem,
1520 Count, SF, B, Invalidated);
1526 return StoreRef(B.asStore(), *
this);
1539SVal RegionStoreManager::ArrayToPointer(Loc
Array, QualType
T) {
1544 return UnknownVal();
1546 const SubRegion *
R =
1549 return loc::MemRegionVal(MRMgr.getElementRegion(
T, ZeroIdx, R, Ctx));
1566 if (L.
getAs<loc::ConcreteInt>()) {
1567 return UnknownVal();
1569 if (!L.
getAs<loc::MemRegionVal>()) {
1570 return UnknownVal();
1573 const MemRegion *MR = L.
castAs<loc::MemRegionVal>().getRegion();
1576 return UnknownVal();
1581 if (
const auto *TVR = dyn_cast<TypedValueRegion>(MR))
1582 T = TVR->getValueType();
1583 else if (
const auto *TR = dyn_cast<TypedRegion>(MR))
1585 else if (
const auto *SR = dyn_cast<SymbolicRegion>(MR))
1586 T = SR->getPointeeStaticType();
1588 assert(!
T.isNull() &&
"Unable to auto-detect binding type!");
1589 assert(!
T->
isVoidType() &&
"Attempting to dereference a void pointer!");
1597 QualType RTy =
R->getValueType();
1602 return UnknownVal();
1613 return getBindingForStruct(B, R);
1617 return createLazyBinding(B, R);
1621 return getBindingForArray(B, R);
1623 return UnknownVal();
1628 return UnknownVal();
1630 if (
const FieldRegion* FR = dyn_cast<FieldRegion>(R))
1631 return svalBuilder.
evalCast(getBindingForField(B, FR),
T, QualType{});
1633 if (
const ElementRegion* ER = dyn_cast<ElementRegion>(R)) {
1639 return svalBuilder.
evalCast(getBindingForElement(B, ER),
T, QualType{});
1642 if (
const ObjCIvarRegion *IVR = dyn_cast<ObjCIvarRegion>(R)) {
1649 return svalBuilder.
evalCast(getBindingForObjCIvar(B, IVR),
T, QualType{});
1652 if (
const VarRegion *VR = dyn_cast<VarRegion>(R)) {
1659 return svalBuilder.
evalCast(getBindingForVar(B, VR),
T, QualType{});
1662 const SVal *
V = B.lookup(R, BindingKey::Direct);
1676 return UndefinedVal();
1686 RegionTy = TVR->getValueType();
1689 RegionTy = SR->getSymbol()->getType();
1701static std::optional<nonloc::LazyCompoundVal>
1703 const SubRegion *R,
bool AllowSubregionBindings) {
1704 std::optional<SVal>
V = B.getDefaultBinding(R);
1706 return std::nullopt;
1708 std::optional<nonloc::LazyCompoundVal> LCV =
1711 return std::nullopt;
1716 if (!RegionTy.
isNull() &&
1718 QualType SourceRegionTy = LCV->getRegion()->getValueType();
1720 return std::nullopt;
1723 if (!AllowSubregionBindings) {
1730 return std::nullopt;
1736std::pair<Store, const SubRegion *>
1739 const SubRegion *originalRegion) {
1740 if (originalRegion != R) {
1741 if (std::optional<nonloc::LazyCompoundVal>
V =
1743 return std::make_pair(
V->getStore(),
V->getRegion());
1746 typedef std::pair<Store, const SubRegion *> StoreRegionPair;
1747 StoreRegionPair
Result = StoreRegionPair();
1749 if (
const ElementRegion *ER = dyn_cast<ElementRegion>(R)) {
1754 Result.second = MRMgr.getElementRegionWithSuper(ER,
Result.second);
1756 }
else if (
const FieldRegion *FR = dyn_cast<FieldRegion>(R)) {
1761 Result.second = MRMgr.getFieldRegionWithSuper(FR,
Result.second);
1763 }
else if (
const CXXBaseObjectRegion *BaseReg =
1764 dyn_cast<CXXBaseObjectRegion>(R)) {
1771 Result.second = MRMgr.getCXXBaseObjectRegionWithSuper(BaseReg,
1783static SmallVector<uint64_t, 2>
1785 assert(CAT &&
"ConstantArrayType should not be null");
1790 }
while ((CAT = dyn_cast<ConstantArrayType>(CAT->
getElementType())));
1808static std::pair<SmallVector<SVal, 2>,
const MemRegion *>
1810 assert(ER &&
"ConstantArrayType should not be null");
1814 SValOffsets.push_back(ER->
getIndex());
1816 ER = dyn_cast<ElementRegion>(
Base);
1818 return {SValOffsets,
Base};
1844static std::optional<SVal>
1851 auto ExtentIt = ArrayExtents.begin();
1852 for (
SVal V : llvm::reverse(SrcOffsets)) {
1856 FlatOffset = FlatOffset *
static_cast<int64_t>(*(ExtentIt++)) +
1857 CI->getValue()->getExtValue();
1862 TotalSize *=
static_cast<int64_t>(E);
1864 if (FlatOffset < 0 || FlatOffset >= TotalSize)
1867 DstOffsets.resize(ArrayExtents.size());
1869 for (
int I = DstOffsets.size() - 1; I >= 0; --I) {
1870 DstOffsets[I] = Remaining % ArrayExtents[I];
1871 Remaining /= ArrayExtents[I];
1874 return std::nullopt;
1877std::optional<SVal> RegionStoreManager::getConstantValFromConstArrayInitializer(
1879 assert(R &&
"ElementRegion should not be null");
1882 SmallVector<SVal, 2> SValOffsets;
1883 const MemRegion *
Base;
1885 const VarRegion *VR = dyn_cast<VarRegion>(Base);
1887 return std::nullopt;
1889 assert(!SValOffsets.empty() &&
"getElementRegionOffsets guarantees the "
1890 "offsets vector is not empty.");
1894 const VarDecl *VD = VR->
getDecl();
1896 !
R->getElementType().isConstQualified() &&
1898 return std::nullopt;
1913 return std::nullopt;
1919 return std::nullopt;
1930 if (SValOffsets.size() != Extents.size())
1931 return std::nullopt;
1933 SmallVector<uint64_t, 2> ConcreteOffsets;
1935 SValOffsets, Extents, ConcreteOffsets))
1941 if (
const auto *ILE = dyn_cast<InitListExpr>(
Init))
1942 return getSValFromInitListExpr(ILE, ConcreteOffsets,
R->getElementType());
1947 if (
const auto *SL = dyn_cast<StringLiteral>(
Init))
1948 return getSValFromStringLiteral(SL, ConcreteOffsets.front(),
1949 R->getElementType());
1953 return std::nullopt;
1973std::optional<SVal> RegionStoreManager::getSValFromInitListExpr(
1974 const InitListExpr *ILE,
const SmallVector<uint64_t, 2> &Offsets,
1976 assert(ILE &&
"InitListExpr should not be null");
1985 if (
const auto *SL = dyn_cast<StringLiteral>(ILE->
getInit(0)))
1986 return getSValFromStringLiteral(SL, Offset, ElemT);
1994 const Expr *E = ILE->
getInit(Offset);
1995 const auto *IL = dyn_cast<InitListExpr>(E);
2009 return std::nullopt;
2037SVal RegionStoreManager::getSValFromStringLiteral(
const StringLiteral *SL,
2040 assert(SL &&
"StringLiteral should not be null");
2056 if (
const std::optional<SVal> &ParentValue =
2057 B.getDirectBinding(BaseRegion)) {
2058 if (
SymbolRef ParentValueAsSym = ParentValue->getAsSymbol())
2061 if (ParentValue->isUndef())
2070 return std::nullopt;
2074 const ElementRegion* R) {
2076 if (
const std::optional<SVal> &
V = B.getDirectBinding(R))
2079 const MemRegion* superR =
R->getSuperRegion();
2082 if (
const StringRegion *StrR = dyn_cast<StringRegion>(superR)) {
2088 return UnknownVal();
2089 if (
const auto CI =
R->getIndex().getAs<nonloc::ConcreteInt>()) {
2090 const llvm::APSInt &Idx = CI->getValue();
2092 return UndefinedVal();
2093 const StringLiteral *SL = StrR->getStringLiteral();
2094 return getSValFromStringLiteral(SL, Idx.getZExtValue(),
T);
2097 if (std::optional<SVal>
V = getConstantValFromConstArrayInitializer(B, R))
2103 return UnknownVal();
2111 const RegionRawOffset &O =
R->getAsArrayOffset();
2115 return UnknownVal();
2117 if (
const TypedValueRegion *baseR = dyn_cast<TypedValueRegion>(O.
getRegion()))
2121 return getBindingForFieldOrElementCommon(B, R,
R->getElementType());
2125RegionStoreManager::getConstantValFromInitializer(
const FieldRegion *R,
2126 bool IsMainAnalysis) {
2127 SmallVector<const SubRegion *, 4> Path;
2128 const MemRegion *Cur =
R;
2134 return std::nullopt;
2138 const auto *VR = dyn_cast<VarRegion>(Cur);
2140 return std::nullopt;
2142 const VarDecl *VD = VR->
getDecl();
2143 QualType LeafTy =
R->getDecl()->getType();
2149 return std::nullopt;
2153 return std::nullopt;
2155 const Expr *E =
Init;
2156 for (
const SubRegion *SR : llvm::reverse(Path)) {
2162 const auto *ILE = dyn_cast<InitListExpr>(E);
2164 return std::nullopt;
2166 if (
const auto *FR = dyn_cast<FieldRegion>(SR)) {
2171 if (InitField != FR->getDecl())
2172 return std::nullopt;
2177 unsigned Idx = FR->getDecl()->getFieldIndex();
2179 return std::nullopt;
2185 if (
const auto *ER = dyn_cast<ElementRegion>(SR)) {
2186 auto CI = ER->getIndex().getAs<nonloc::ConcreteInt>();
2188 return std::nullopt;
2189 uint64_t Idx = CI->getValue()->getZExtValue();
2190 if (Idx < ILE->getNumInits())
2195 return std::nullopt;
2199 return std::nullopt;
2206 const FieldRegion* R) {
2209 if (
const std::optional<SVal> &
V = B.getDirectBinding(R))
2213 if (std::optional<SVal>
V =
2214 getConstantValFromInitializer(R, B.isMainAnalysis()))
2217 QualType Ty =
R->getDecl()->getType();
2235 if (
const auto *Base = dyn_cast<TypedValueRegion>(
R->getBaseRegion()))
2239 return getBindingForFieldOrElementCommon(B, R, Ty);
2242std::optional<SVal> RegionStoreManager::getBindingForDerivedDefaultValue(
2244 const TypedValueRegion *R, QualType Ty) {
2246 if (
const std::optional<SVal> &D = B.getDefaultBinding(superR)) {
2262 llvm_unreachable(
"Unknown default value");
2265 return std::nullopt;
2268SVal RegionStoreManager::getLazyBinding(
const SubRegion *LazyBindingRegion,
2269 RegionBindingsRef LazyBinding) {
2271 if (
const ElementRegion *ER = dyn_cast<ElementRegion>(LazyBindingRegion))
2272 Result = getBindingForElement(LazyBinding, ER);
2274 Result = getBindingForField(LazyBinding,
2299 const TypedValueRegion *R,
2306 Store lazyBindingStore =
nullptr;
2307 const SubRegion *lazyBindingRegion =
nullptr;
2308 std::tie(lazyBindingStore, lazyBindingRegion) = findLazyBinding(B, R, R);
2309 if (lazyBindingRegion)
2310 return getLazyBinding(lazyBindingRegion,
2311 getRegionBindings(lazyBindingStore));
2315 bool hasSymbolicIndex =
false;
2331 bool hasPartialLazyBinding =
false;
2333 const SubRegion *SR =
R;
2336 if (std::optional<SVal> D =
2337 getBindingForDerivedDefaultValue(B, Base, R, Ty)) {
2338 if (D->getAs<nonloc::LazyCompoundVal>()) {
2339 hasPartialLazyBinding =
true;
2346 if (
const ElementRegion *ER = dyn_cast<ElementRegion>(Base)) {
2347 NonLoc index = ER->getIndex();
2349 hasSymbolicIndex =
true;
2354 SR = dyn_cast<SubRegion>(Base);
2361 if (
const TypedValueRegion *typedSuperR =
2362 dyn_cast<TypedValueRegion>(
R->getSuperRegion())) {
2363 if (typedSuperR->getValueType()->isVectorType())
2364 return UnknownVal();
2372 if (hasSymbolicIndex)
2373 return UnknownVal();
2379 if (
const std::optional<SVal> &
V = B.getDefaultBinding(R))
2381 return UndefinedVal();
2390 const ObjCIvarRegion* R) {
2392 if (
const std::optional<SVal> &
V = B.getDirectBinding(R))
2395 const MemRegion *superR =
R->getSuperRegion();
2398 if (
const std::optional<SVal> &
V = B.getDefaultBinding(superR)) {
2403 return UnknownVal();
2406 return getBindingForLazySymbol(R);
2410 const VarRegion *R) {
2413 if (std::optional<SVal>
V = B.getDirectBinding(R))
2416 if (std::optional<SVal>
V = B.getDefaultBinding(R))
2420 const VarDecl *VD =
R->getDecl();
2421 const MemSpaceRegion *MS =
R->getRawMemorySpace();
2438 return UnknownVal();
2451 if (B.isMainAnalysis())
2463 if (std::optional<SVal>
V = getBindingForDerivedDefaultValue(B, MS, R,
T)) {
2464 assert(!
V->getAs<nonloc::LazyCompoundVal>());
2471 return UndefinedVal();
2474SVal RegionStoreManager::getBindingForLazySymbol(
const TypedValueRegion *R) {
2479const RegionStoreManager::SValListTy &
2480RegionStoreManager::getInterestingValues(nonloc::LazyCompoundVal LCV) {
2482 LazyBindingsMapTy::iterator I = LazyBindingsMap.find(LCV.
getCVData());
2483 if (I != LazyBindingsMap.end())
2489 const SubRegion *LazyR = LCV.
getRegion();
2490 RegionBindingsRef B = getRegionBindings(LCV.
getStore());
2496 return (LazyBindingsMap[LCV.
getCVData()] = std::move(List));
2498 SmallVector<BindingPair, 32>
Bindings;
2501 for (SVal
V : llvm::make_second_range(
Bindings)) {
2502 if (
V.isUnknownOrUndef() ||
V.isConstant())
2505 if (
auto InnerLCV =
V.getAs<nonloc::LazyCompoundVal>()) {
2506 const SValListTy &InnerList = getInterestingValues(*InnerLCV);
2507 llvm::append_range(List, InnerList);
2513 return (LazyBindingsMap[LCV.
getCVData()] = std::move(List));
2517 const TypedValueRegion *R) {
2518 if (std::optional<nonloc::LazyCompoundVal>
V =
2526 const TypedValueRegion *R) {
2527 const RecordDecl *RD =
2528 R->getValueType()->castAsCanonical<RecordType>()->getDecl();
2530 return UnknownVal();
2536 return createLazyBinding(B, R);
2540 const TypedValueRegion *R) {
2542 "Only constant array types can have compound bindings.");
2544 return createLazyBinding(B, R);
2547bool RegionStoreManager::includedInBindings(
Store store,
2548 const MemRegion *region)
const {
2549 RegionBindingsRef B = getRegionBindings(store);
2553 if (B.lookup(region))
2557 for (RegionBindingsRef::iterator RI = B.begin(), RE = B.end(); RI != RE; ++RI) {
2559 for (ClusterBindings::iterator CI = Cluster.begin(), CE = Cluster.end();
2561 SVal D = CI.getData();
2563 if (
R->getBaseRegion() == region)
2575StoreRef RegionStoreManager::killBinding(
Store ST, Loc L) {
2576 if (std::optional<loc::MemRegionVal> LV = L.
getAs<loc::MemRegionVal>())
2577 if (
const MemRegion* R = LV->getRegion())
2578 return StoreRef(getRegionBindings(ST)
2581 .getRootWithoutRetain(),
2584 return StoreRef(ST, *
this);
2587LimitedRegionBindingsRef
2589 llvm::TimeTraceScope TimeScope(
"RegionStoreManager::bind",
2590 [&L]() {
return locDescr(L); });
2596 auto MemRegVal = L.
getAs<loc::MemRegionVal>();
2600 const MemRegion *
R = MemRegVal->getRegion();
2604 if (
const auto *SymReg = dyn_cast<SymbolicRegion>(R)) {
2605 QualType Ty = SymReg->getPointeeStaticType();
2607 Ty = StateMgr.getContext().CharTy;
2608 R = GetElementZeroRegion(SymReg, Ty);
2612 if (
const TypedValueRegion* TR = dyn_cast<TypedValueRegion>(R)) {
2615 return bindArray(B, TR,
V);
2617 return bindStruct(B, TR,
V);
2619 return bindVector(B, TR,
V);
2621 return bindAggregate(B, TR,
V);
2625 "'this' pointer is not an l-value and is not assignable");
2632 : BindingKey::Direct;
2633 return NewB.addBinding(BindingKey::Make(R, KeyKind),
V);
2636LimitedRegionBindingsRef
2638 const MemRegion *R, QualType
T) {
2674std::optional<LimitedRegionBindingsRef> RegionStoreManager::tryBindSmallArray(
2676 const ArrayType *AT, nonloc::LazyCompoundVal LCV) {
2680 auto CAT = dyn_cast<ConstantArrayType>(AT);
2684 return std::nullopt;
2688 return std::nullopt;
2692 if (ArrSize > SmallArrayLimit)
2693 return std::nullopt;
2695 LimitedRegionBindingsRef NewB = B;
2697 for (
uint64_t i = 0; i < ArrSize; ++i) {
2699 const ElementRegion *SrcER =
2700 MRMgr.getElementRegion(Ty, Idx, LCV.
getRegion(), Ctx);
2701 SVal
V = getBindingForElement(getRegionBindings(LCV.
getStore()), SrcER);
2703 const ElementRegion *DstER = MRMgr.getElementRegion(Ty, Idx, R, Ctx);
2704 NewB = bind(NewB, loc::MemRegionVal(DstER),
V);
2710LimitedRegionBindingsRef
2712 const TypedValueRegion *R, SVal
Init) {
2713 llvm::TimeTraceScope TimeScope(
"RegionStoreManager::bindArray",
2714 [R]() {
return R->getDescriptiveName(); });
2720 std::optional<uint64_t>
Size;
2722 if (
const ConstantArrayType* CAT = dyn_cast<ConstantArrayType>(AT))
2728 if (std::optional<loc::MemRegionVal> MRV =
Init.getAs<loc::MemRegionVal>()) {
2729 SVal
V = getBinding(B.asStore(), *MRV,
R->getValueType());
2730 return bindAggregate(B, R,
V);
2735 if (
Init.isConstant())
2736 return bindAggregate(B, R,
Init);
2738 if (std::optional LCV =
Init.getAs<nonloc::LazyCompoundVal>()) {
2739 if (std::optional NewB = tryBindSmallArray(B, R, AT, *LCV))
2741 return bindAggregate(B, R,
Init);
2752 return bindAggregate(B, R,
Init);
2756 const nonloc::CompoundVal& CV =
Init.castAs<nonloc::CompoundVal>();
2760 LimitedRegionBindingsRef NewB = B;
2762 for (;
Size ? i < *
Size :
true; ++i, ++VI) {
2770 const ElementRegion *ER = MRMgr.getElementRegion(ElementTy, Idx, R, Ctx);
2773 NewB = bindStruct(NewB, ER, *VI);
2775 NewB = bindArray(NewB, ER, *VI);
2777 NewB = bind(NewB, loc::MemRegionVal(ER), *VI);
2783 if (!Size || i < *Size)
2784 NewB = setImplicitDefaultValue(NewB, R, ElementTy);
2789LimitedRegionBindingsRef
2791 const TypedValueRegion *R, SVal
V) {
2792 llvm::TimeTraceScope TimeScope(
"RegionStoreManager::bindVector",
2793 [R]() {
return R->getDescriptiveName(); });
2797 QualType
T =
R->getValueType();
2798 const VectorType *VT =
T->
castAs<VectorType>();
2802 return bindAggregate(B, R,
V);
2808 return bindAggregate(B, R, UnknownVal());
2812 nonloc::CompoundVal CV =
V.
castAs<nonloc::CompoundVal>();
2815 LimitedRegionBindingsRef NewB = B;
2817 for ( ; index != numElements ; ++index) {
2825 const ElementRegion *ER = MRMgr.getElementRegion(ElemType, Idx, R, Ctx);
2828 NewB = bindArray(NewB, ER, *VI);
2830 NewB = bindStruct(NewB, ER, *VI);
2832 NewB = bind(NewB, loc::MemRegionVal(ER), *VI);
2837std::optional<LimitedRegionBindingsRef> RegionStoreManager::tryBindSmallStruct(
2839 const RecordDecl *RD, nonloc::LazyCompoundVal LCV) {
2845 if (
const CXXRecordDecl *
Class = dyn_cast<CXXRecordDecl>(RD))
2846 if (
Class->getNumBases() != 0 ||
Class->getNumVBases() != 0)
2847 return std::nullopt;
2849 for (
const auto *FD : RD->
fields()) {
2850 if (FD->isUnnamedBitField())
2855 if (Fields.size() == SmallStructLimit)
2856 return std::nullopt;
2858 QualType Ty = FD->getType();
2866 return std::nullopt;
2868 Fields.push_back(FD);
2871 LimitedRegionBindingsRef NewB = B;
2873 for (
const FieldDecl *Field : Fields) {
2874 const FieldRegion *SourceFR = MRMgr.getFieldRegion(Field, LCV.
getRegion());
2875 SVal
V = getBindingForField(getRegionBindings(LCV.
getStore()), SourceFR);
2877 const FieldRegion *DestFR = MRMgr.getFieldRegion(Field, R);
2878 NewB = bind(NewB, loc::MemRegionVal(DestFR),
V);
2884LimitedRegionBindingsRef
2886 const TypedValueRegion *R, SVal
V) {
2887 llvm::TimeTraceScope TimeScope(
"RegionStoreManager::bindStruct",
2888 [R]() {
return R->getDescriptiveName(); });
2892 QualType
T =
R->getValueType();
2900 if (std::optional<nonloc::LazyCompoundVal> LCV =
2901 V.getAs<nonloc::LazyCompoundVal>()) {
2902 if (std::optional NewB = tryBindSmallStruct(B, R, RD, *LCV))
2904 return bindAggregate(B, R,
V);
2907 return bindAggregate(B, R,
V);
2913 return bindAggregate(B, R, UnknownVal());
2931 const nonloc::CompoundVal& CV =
V.
castAs<nonloc::CompoundVal>();
2934 LimitedRegionBindingsRef NewB = B;
2938 if (
const auto *CRD = dyn_cast<CXXRecordDecl>(RD)) {
2946 assert((CRD->isAggregate() || (Ctx.
getLangOpts().ObjC && VI == VE)) &&
2947 "Non-aggregates are constructed with a constructor!");
2949 for (
const auto &B : CRD->bases()) {
2951 assert(!B.isVirtual() &&
"Aggregates cannot have virtual base classes!");
2958 QualType BTy = B.getType();
2962 assert(BRD &&
"Base classes must be C++ classes!");
2964 const CXXBaseObjectRegion *BR =
2965 MRMgr.getCXXBaseObjectRegion(BRD, R,
false);
2967 NewB = bindStruct(NewB, BR, *VI);
2984 if (FI->isUnnamedBitField())
2987 QualType FTy = FI->getType();
2988 const FieldRegion* FR = MRMgr.getFieldRegion(*FI, R);
2991 NewB = bindArray(NewB, FR, *VI);
2993 NewB = bindStruct(NewB, FR, *VI);
2995 NewB = bind(NewB, loc::MemRegionVal(FR), *VI);
3004 NewB = NewB.
addBinding(R, BindingKey::Default,
3011LimitedRegionBindingsRef
3013 const TypedRegion *R, SVal Val) {
3014 llvm::TimeTraceScope TimeScope(
"RegionStoreManager::bindAggregate",
3015 [R]() {
return R->getDescriptiveName(); });
3021 return removeSubRegionBindings(B, R).
addBinding(R, BindingKey::Default, Val);
3029class RemoveDeadBindingsWorker
3030 :
public ClusterAnalysis<RemoveDeadBindingsWorker> {
3031 SmallVector<const SymbolicRegion *, 12> Postponed;
3032 SymbolReaper &SymReaper;
3033 const StackFrame *CurrentSF;
3036 RemoveDeadBindingsWorker(RegionStoreManager &rm,
3037 ProgramStateManager &stateMgr, RegionBindingsRef b,
3038 SymbolReaper &symReaper,
const StackFrame *SF)
3039 : ClusterAnalysis<RemoveDeadBindingsWorker>(rm, stateMgr, b),
3040 SymReaper(symReaper), CurrentSF(SF) {}
3043 void VisitAddedToCluster(
const MemRegion *baseR,
const ClusterBindings &
C);
3045 using ClusterAnalysis<RemoveDeadBindingsWorker>::VisitCluster;
3047 using ClusterAnalysis::AddToWorkList;
3049 bool AddToWorkList(
const MemRegion *R);
3051 bool UpdatePostponed();
3052 void VisitBinding(SVal
V);
3056bool RemoveDeadBindingsWorker::AddToWorkList(
const MemRegion *R) {
3057 const MemRegion *BaseR =
R->getBaseRegion();
3058 return AddToWorkList(WorkListElement(BaseR), getCluster(BaseR));
3061void RemoveDeadBindingsWorker::VisitAddedToCluster(
const MemRegion *baseR,
3064 if (
const VarRegion *VR = dyn_cast<VarRegion>(baseR)) {
3065 if (SymReaper.
isLive(VR))
3066 AddToWorkList(baseR, &
C);
3071 if (
const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(baseR)) {
3072 if (SymReaper.
isLive(SR->getSymbol()))
3073 AddToWorkList(SR, &
C);
3075 Postponed.push_back(SR);
3081 AddToWorkList(baseR, &
C);
3086 if (
const CXXThisRegion *TR = dyn_cast<CXXThisRegion>(baseR)) {
3087 const auto *StackReg =
3089 const StackFrame *RegSF = StackReg->getStackFrame();
3090 if (CurrentSF && (RegSF == CurrentSF || RegSF->
isParentOf(CurrentSF)))
3091 AddToWorkList(TR, &
C);
3095void RemoveDeadBindingsWorker::VisitCluster(
const MemRegion *baseR,
3102 if (
const SymbolicRegion *SymR = dyn_cast<SymbolicRegion>(baseR))
3103 SymReaper.
markLive(SymR->getSymbol());
3105 for (
const auto &[Key, Val] : *
C) {
3113void RemoveDeadBindingsWorker::VisitBinding(SVal
V) {
3116 if (
auto LCS =
V.getAs<nonloc::LazyCompoundVal>()) {
3119 for (SVal
V : RM.getInterestingValues(*LCS)) {
3120 if (
auto DepLCS =
V.getAs<nonloc::LazyCompoundVal>())
3130 if (
const MemRegion *R =
V.getAsRegion()) {
3135 if (
const BlockDataRegion *BR = dyn_cast<BlockDataRegion>(R)) {
3136 for (
auto Var : BR->referenced_vars())
3137 AddToWorkList(Var.getCapturedRegion());
3147bool RemoveDeadBindingsWorker::UpdatePostponed() {
3152 for (
const SymbolicRegion *SR : Postponed) {
3153 if (SymReaper.
isLive(SR->getSymbol())) {
3162StoreRef RegionStoreManager::removeDeadBindings(
Store store,
3163 const StackFrame *SF,
3164 SymbolReaper &SymReaper) {
3165 RegionBindingsRef B = getRegionBindings(store);
3166 RemoveDeadBindingsWorker W(*
this, StateMgr, B, SymReaper, SF);
3167 W.GenerateClusters();
3170 for (
const MemRegion *Reg : SymReaper.
regions()) {
3171 W.AddToWorkList(Reg);
3174 do W.RunWorkList();
while (W.UpdatePostponed());
3180 B = B.filterClusters([&](
const auto &E) {
return W.isVisited(&E.second); });
3182 return StoreRef(B.asStore(), *
this);
3189void RegionStoreManager::printJson(raw_ostream &Out,
Store S,
const char *NL,
3190 unsigned int Space,
bool IsDot)
const {
3191 RegionBindingsRef
Bindings = getRegionBindings(S);
3193 Indent(Out, Space, IsDot) <<
"\"store\": ";
3196 Out <<
"null," << NL;
3200 Out <<
"{ \"pointer\": \"" <<
Bindings.asStore() <<
"\", \"items\": [" << NL;
3201 Bindings.printJson(Out, NL, Space + 1, IsDot);
3202 Indent(Out, Space, IsDot) <<
"]}," << NL;
This file defines AnalysisDeclContext, a class that manages the analysis context data for context sen...
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
Result
Implement __builtin_bit_cast and related operations.
static std::optional< SVal > convertOffsetsFromSvalToUnsigneds(const SmallVector< SVal, 2 > &SrcOffsets, const SmallVector< uint64_t, 2 > ArrayExtents, SmallVector< uint64_t, 2 > &DstOffsets)
llvm::ImmutableMap< const MemRegion *, ClusterBindings > RegionBindings
static std::optional< SVal > getDerivedSymbolForBinding(RegionBindingsConstRef B, const TypedValueRegion *BaseRegion, const TypedValueRegion *SubReg, const ASTContext &Ctx, SValBuilder &SVB)
std::pair< BindingKey, SVal > BindingPair
static bool isCompatibleWithFields(BindingKey K, const FieldVector &Fields)
SmallVector< const FieldDecl *, 8 > FieldVector
llvm::ImmutableMap< BindingKey, SVal > ClusterBindings
static bool isUnionField(const FieldRegion *FR)
const LimitedRegionBindingsRef & LimitedRegionBindingsConstRef
static void getSymbolicOffsetFields(BindingKey K, FieldVector &Fields)
static QualType getUnderlyingType(const SubRegion *R)
llvm::ImmutableMapRef< BindingKey, SVal > ClusterBindingsRef
static SmallVector< uint64_t, 2 > getConstantArrayExtents(const ConstantArrayType *CAT)
This is a helper function for getConstantValFromConstArrayInitializer.
static std::pair< SmallVector< SVal, 2 >, const MemRegion * > getElementRegionOffsetsWithBase(const ElementRegion *ER)
This is a helper function for getConstantValFromConstArrayInitializer.
const RegionBindingsRef & RegionBindingsConstRef
static std::optional< nonloc::LazyCompoundVal > getExistingLazyBinding(SValBuilder &SVB, RegionBindingsConstRef B, const SubRegion *R, bool AllowSubregionBindings)
Checks to see if store B has a lazy binding for region R.
static void collectSubRegionBindings(SmallVectorImpl< BindingPair > &Bindings, SValBuilder &SVB, const ClusterBindings &Cluster, const SubRegion *Top, BindingKey TopKey, bool IncludeAllDefaultBindings)
Collects all bindings in Cluster that may refer to bindings within Top.
llvm::SmallVector< std::pair< const MemRegion *, SVal >, 4 > Bindings
__PTRDIFF_TYPE__ ptrdiff_t
A signed integer type that is the result of subtracting two pointers.
This class represents the same as RegionBindingsRef, but with a limit on the number of bindings that ...
LimitedRegionBindingsRef removeCluster(const MemRegion *BaseRegion) const
LimitedRegionBindingsRef withValuesEscaped(nonloc::CompoundVal::iterator Begin, nonloc::CompoundVal::iterator End) const
LimitedRegionBindingsRef withValuesEscaped(SVal V) const
LimitedRegionBindingsRef(RegionBindingsRef Base, SmallVectorImpl< SVal > &EscapedValuesDuringBind, std::optional< unsigned > BindingsLeft)
bool hasExhaustedBindingLimit() const
LimitedRegionBindingsRef addBinding(BindingKey K, SVal V) const
LimitedRegionBindingsRef addBinding(const MemRegion *R, BindingKey::Kind k, SVal V) const
LimitedRegionBindingsRef addWithoutDecreasingLimit(const MemRegion *BaseRegion, data_type_ref BindingKeyAndValue) const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const ConstantArrayType * getAsConstantArrayType(QualType T) const
static CanQualType getCanonicalType(QualType T)
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
const LangOptions & getLangOpts() const
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
static uint64_t getConstantArrayElementCount(const ConstantArrayType *CA)
Return number of (potentially nested) constant array elements.
static bool hasSameUnqualifiedType(QualType T1, QualType T2)
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
uint64_t getCharWidth() const
Return the size of the character type, in bits.
QualType getElementType() const
Represents the canonical version of C arrays with a specified constant size.
uint64_t getLimitedSize() const
Return the size zero-extended to uint64_t or UINT64_MAX if the value is larger than UINT64_MAX.
uint64_t getZExtSize() const
Return the size zero-extended as a uint64_t.
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
bool isStringLiteralInit() const
Is this an initializer for an array of characters, initialized by a string literal or an @encode?
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
unsigned getNumInits() const
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
const Expr * getInit(unsigned Init) const
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
bool isConstQualified() const
Determine whether this type is const-qualified.
field_iterator field_end() const
field_range fields() const
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
specific_decl_iterator< FieldDecl > field_iterator
field_iterator field_begin() const
bool isParentOf(const StackFrame *SF) const
const Decl * getDecl() const
unsigned getLength() const
uint32_t getCodeUnit(size_t I) const
Return the code unit at the given position.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
bool isFunctionReferenceType() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isConstantArrayType() const
bool isVoidPointerType() const
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isScalarType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type.
RecordDecl * castAsRecordDecl() const
bool isAnyComplexType() const
QualType getCanonicalTypeInternal() const
bool isStructureOrClassType() const
bool isVectorType() const
bool isRecordType() const
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
const Expr * getAnyInitializer() const
Get the initializer for this variable, no matter which declaration it is attached to.
unsigned getNumElements() const
QualType getElementType() const
ElementRegion is used to represent both array elements and casts.
LLVM_ATTRIBUTE_RETURNS_NONNULL const FieldDecl * getDecl() const override
void dumpToStream(raw_ostream &Out) const
static bool isLocType(QualType T)
DefinedOrUnknownSVal getStaticSize(const MemRegion *MR, SValBuilder &SVB) const
MemRegion - The root abstract class for all memory regions.
virtual bool isBoundable() const
RegionOffset getAsOffset() const
Compute the offset within the top level memory object.
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * getBaseRegion() const
@ TK_PreserveContents
Tells that a region's contents is not changed.
@ TK_DoNotInvalidateSuperRegion
@ TK_EntireMemSpace
When applied to a MemSpaceRegion, indicates the entire memory space should be invalidated.
bool hasTrait(SymbolRef Sym, InvalidationKinds IK) const
bool hasSymbolicOffset() const
const MemRegion * getRegion() const
It might return null.
int64_t getOffset() const
const MemRegion * getRegion() const
DefinedOrUnknownSVal makeZeroVal(QualType type)
Construct an SVal representing '0' for the specified type.
NonLoc makeArrayIndex(uint64_t idx)
ASTContext & getContext()
nonloc::ConcreteInt makeIntVal(const IntegerLiteral *integer)
SVal evalCast(SVal V, QualType CastTy, QualType OriginalTy)
Cast a given SVal to another SVal using given QualType's.
DefinedOrUnknownSVal getDerivedRegionValueSymbolVal(SymbolRef parentSymbol, const TypedValueRegion *region)
loc::ConcreteInt makeNullWithType(QualType type)
Create NULL pointer, with proper pointer bit-width for given address space.
std::optional< SVal > getConstantVal(const Expr *E)
Returns the value of E, if it can be determined in a non-path-sensitive manner.
NonLoc makeZeroArrayIndex()
DefinedOrUnknownSVal getRegionValueSymbolVal(const TypedValueRegion *region)
Make a unique symbol for value of region.
NonLoc makeLazyCompoundVal(const StoreRef &store, const TypedValueRegion *region)
DefinedOrUnknownSVal conjureSymbolVal(const void *symbolTag, ConstCFGElementRef elem, const StackFrame *SF, unsigned count)
Create a new symbol with a unique 'name'.
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
bool isZeroConstant() const
bool isUnknownOrUndef() const
SymbolRef getAsSymbol(bool IncludeBaseRegions=false) const
If this SVal wraps a symbol return that SymbolRef.
std::optional< T > getAs() const
Convert to the specified SVal type, returning std::nullopt if this SVal is not of the desired type.
const MemRegion * getAsRegion() const
T castAs() const
Convert to the specified SVal type, asserting that this SVal is of the desired type.
bool scan(nonloc::LazyCompoundVal val)
SmallVector< const MemRegion *, 8 > InvalidatedRegions
SubRegion - A region that subsets another larger region.
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * getSuperRegion() const
bool isSubRegionOf(const MemRegion *R) const override
Check if the region is a subregion of the given region.
MemRegionManager & getMemRegionManager() const override
symbol_range symbols() const
static bool canSymbolicate(QualType T)
void markElementIndicesLive(const MemRegion *region)
void markLazilyCopied(const MemRegion *region)
void markLive(SymbolRef Sym)
Unconditionally marks a symbol as live.
bool isLive(SymbolRef Sym)
llvm::iterator_range< RegionSetTy::const_iterator > regions() const
SymbolicRegion - A special, "non-concrete" region.
TypedValueRegion - An abstract class representing regions having a typed value.
virtual QualType getValueType() const =0
QualType getLocationType() const override
QualType getValueType() const override
const VarDecl * getDecl() const override=0
llvm::ImmutableList< SVal >::iterator iterator
Value representing integer constant.
While nonloc::CompoundVal covers a few simple use cases, nonloc::LazyCompoundVal is a more performant...
LLVM_ATTRIBUTE_RETURNS_NONNULL const LazyCompoundValData * getCVData() const
LLVM_ATTRIBUTE_RETURNS_NONNULL const TypedValueRegion * getRegion() const
This function itself is immaterial.
const void * getStore() const
It might return null.
Defines the clang::TargetInfo interface.
const internal::VariadicDynCastAllOfMatcher< Decl, VarDecl > varDecl
Matches variable declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, DeclRefExpr > declRefExpr
Matches expressions that refer to declarations.
const internal::ArgumentAdaptingMatcherFunc< internal::HasDescendantMatcher > hasDescendant
Matches AST nodes that have descendant AST nodes that match the provided matcher.
SmallVector< BoundNodes, 1 > match(MatcherT Matcher, const NodeT &Node, ASTContext &Context)
Returns the results of matching Matcher on Node.
internal::Matcher< Stmt > StatementMatcher
const internal::VariadicAllOfMatcher< Stmt > stmt
Matches statements.
llvm::DenseSet< SymbolRef > InvalidatedSymbols
const SymExpr * SymbolRef
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
std::unique_ptr< StoreManager > CreateRegionStoreManager(ProgramStateManager &StMgr)
const void * Store
Store - This opaque type encapsulates an immutable mapping from locations to values.
bool InitField(InterpState &S, CodePtr OpPC, uint32_t I)
1) Pops the value from the stack 2) Peeks a pointer from the stack 3) Pushes the value to field I of ...
Top level wrappers for InstallAPI frontend operations.
@ Match
This is not an overload because the signature exactly matches an existing declaration.
bool isa(CodeGen::Address addr)
CFGBlock::ConstCFGElementRef ConstCFGElementRef
@ Bind
'bind' clause, allowed on routine constructs.
bool operator==(const CallGraphNode::CallRecord &LHS, const CallGraphNode::CallRecord &RHS)
bool operator<(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
raw_ostream & Indent(raw_ostream &Out, const unsigned int Space, bool IsDot)
const FunctionProtoType * T
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)
Insertion operator for diagnostics.
U cast(CodeGen::Address addr)
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Diagnostic wrappers for TextAPI types for error reporting.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t uint64_t __builtin_riscv_ssha_i32 __builtin_riscv_sshl_u32 unsigned
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t int64_t
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t uint64_t __builtin_riscv_ssha_i32 __builtin_riscv_sshl_u32 uint64_t