;
32 const boolIsDereferenced;
35LocField(
const FieldRegion*FR,
const boolIsDereferenced =
true)
36:
FieldNode(FR), IsDereferenced(IsDereferenced) {}
38 void printNoteMsg(llvm::raw_ostream &Out)
const override{
40Out <<
"uninitialized pointee ";
42Out <<
"uninitialized pointer ";
45 void printPrefix(llvm::raw_ostream &Out)
const override{}
47 void printNode(llvm::raw_ostream &Out)
const override{
52 if(
getDecl()->getType()->isPointerType())
61classNeedsCastLocField final :
public FieldNode{
68 void printNoteMsg(llvm::raw_ostream &Out)
const override{
69Out <<
"uninitialized pointee ";
72 void printPrefix(llvm::raw_ostream &Out)
const override{
74 if(
getDecl()->getType()->isIntegerType())
75Out <<
"reinterpret_cast";
78Out <<
"static_cast";
79Out <<
'<'<< CastBackType.getAsString() <<
">(";
82 void printNode(llvm::raw_ostream &Out)
const override{
86 void printSeparator(llvm::raw_ostream &Out)
const override{ Out <<
"->"; }
90classCyclicLocField final :
public FieldNode{
95 void printNoteMsg(llvm::raw_ostream &Out)
const override{
96Out <<
"object references itself ";
99 void printPrefix(llvm::raw_ostream &Out)
const override{}
101 void printNode(llvm::raw_ostream &Out)
const override{
106llvm_unreachable(
"CyclicLocField objects must be the last node of the " 137boolFindUninitializedFields::isDereferencableUninit(
140 SVal V= State->getSVal(FR);
143isa<nonloc::LocAsInteger>(
V)) &&
144 "This method only checks dereferenceable objects!");
146 if(
V.isUnknown() || isa<loc::ConcreteInt>(
V)) {
147IsAnyFieldInitialized =
true;
152 returnaddFieldToUninits(
153LocalChain.
add(LocField(FR,
false)), FR);
157IsAnyFieldInitialized =
true;
163std::optional<DereferenceInfo> DerefInfo =
dereference(State, FR);
165IsAnyFieldInitialized =
true;
169 if(DerefInfo->IsCyclic)
170 returnaddFieldToUninits(LocalChain.
add(CyclicLocField(FR)), FR);
173 const boolNeedsCastBack = DerefInfo->NeedsCastBack;
180 returnisNonUnionUninit(R, LocalChain.
add(NeedsCastLocField(FR, DynT)));
181 returnisNonUnionUninit(R, LocalChain.
add(LocField(FR)));
185 if(isUnionUninit(R)) {
187 returnaddFieldToUninits(LocalChain.
add(NeedsCastLocField(FR, DynT)),
189 returnaddFieldToUninits(LocalChain.
add(LocField(FR)), R);
191IsAnyFieldInitialized =
true;
197IsAnyFieldInitialized =
true;
202 "At this point FR must either have a primitive dynamic type, or it " 203 "must be a null, undefined, unknown or concrete pointer!");
205 SValPointeeV = State->getSVal(R);
207 if(isPrimitiveUninit(PointeeV)) {
209 returnaddFieldToUninits(LocalChain.
add(NeedsCastLocField(FR, DynT)), R);
210 returnaddFieldToUninits(LocalChain.
add(LocField(FR)), R);
213IsAnyFieldInitialized =
true;
224llvm::SmallSet<const TypedValueRegion *, 5> VisitedRegions;
226 SVal V= State->getSVal(FR);
227assert(
V.getAsRegion() &&
"V must have an underlying region!");
240VisitedRegions.insert(R);
245 while(
const MemRegion*Tmp = State->getSVal(R, DynT).getAsRegion()) {
252 if(!VisitedRegions.insert(R).second)
262 while(isa<CXXBaseObjectRegion>(R)) {
263NeedsCastBack =
true;
264 const auto*SuperR = dyn_cast<TypedValueRegion>(R->
getSuperRegion());
275 while(!
T.isNull()) {
static std::optional< DereferenceInfo > dereference(ProgramStateRef State, const FieldRegion *FR)
Dereferences FR and returns with the pointee's region, and whether it needs to be casted back to it's...
static bool isVoidPointer(QualType T)
Returns whether T can be (transitively) dereferenced to a void pointer type (void*,...
A (possibly-)qualified type.
bool isVoidPointerType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isStructureOrClassType() const
Represents a field chain.
FieldChainInfo add(const FieldNodeT &FN)
Constructs a new FieldChainInfo object with FN appended.
A lightweight polymorphic wrapper around FieldRegion *.
virtual void printSeparator(llvm::raw_ostream &Out) const =0
Print the separator.
virtual void printPrefix(llvm::raw_ostream &Out) const =0
Print any prefixes before the fieldchain. Could contain casts, etc.
virtual void printNoteMsg(llvm::raw_ostream &Out) const =0
If this is the last element of the fieldchain, this method will print the note message associated wit...
const FieldDecl * getDecl() const
virtual void printNode(llvm::raw_ostream &Out) const =0
Print the node. Should contain the name of the field stored in FR.
LLVM_ATTRIBUTE_RETURNS_NONNULL const FieldDecl * getDecl() const override
MemRegion - The root abstract class for all memory regions.
const RegionTy * getAs() const
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * getSuperRegion() const
TypedValueRegion - An abstract class representing regions having a typed value.
QualType getLocationType() const override
std::string getVariableName(const FieldDecl *Field)
Returns with Field's name.
bool isPrimitiveType(const QualType &T)
Returns true if T is a primitive type.
bool isDereferencableType(const QualType &T)
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
DereferenceInfo(const TypedValueRegion *R, bool NCB, bool IC)
const TypedValueRegion * R
bool CheckPointeeInitialization
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4