65#ifndef LLVM_CLANG_STATICANALYZER_UNINITIALIZEDOBJECT_H
66#define LLVM_CLANG_STATICANALYZER_UNINITIALIZEDOBJECT_H
104 void Profile(llvm::FoldingSetNodeID &ID)
const { ID.AddPointer(
this); }
114 return FR == OtherFR;
120 return FR->getDecl();
139 virtual void printNode(llvm::raw_ostream &Out)
const = 0;
145 virtual bool isBase()
const {
return false; }
160class FieldChainInfo {
165 FieldChain::Factory &ChainFactory;
169 : FieldChainInfo(F) {
179 template <
class FieldNodeT> FieldChainInfo
add(
const FieldNodeT &FN);
183 template <
class FieldNodeT> FieldChainInfo
replaceHead(
const FieldNodeT &FN);
186 bool isEmpty()
const {
return Chain.isEmpty(); }
202 bool IsAnyFieldInitialized =
false;
204 FieldChainInfo::FieldChain::Factory ChainFactory;
227 std::pair<ProgramStateRef, const UninitFieldMap &>
getResults() {
228 return {State, UninitFields};
302 bool isPrimitiveUninit(
SVal V);
325 return T->isBuiltinType() ||
T->isEnumeralType() ||
326 T->isFunctionType() ||
T->isAtomicType() ||
327 T->isVectorType() ||
T->isScalarType();
331 return T->isAnyPointerType() ||
T->isReferenceType();
336template <
class FieldNodeT>
339 "Can't add a field that is already a part of the "
340 "fieldchain! Is this a cyclic reference?");
342 FieldChainInfo NewChain = *
this;
343 NewChain.Chain = ChainFactory.add(FN, Chain);
347template <
class FieldNodeT>
349 FieldChainInfo NewChain(ChainFactory, Chain.getTail());
350 return NewChain.
add(FN);
Represents a member of a struct/union/class.
A (possibly-)qualified type.
Represents a field chain.
bool contains(const FieldRegion *FR) const
llvm::ImmutableList< const FieldNode & > FieldChain
FieldChainInfo(FieldChain::Factory &F)
const FieldNode & getHead() const
const FieldRegion * getUninitRegion() const
FieldChainInfo replaceHead(const FieldNodeT &FN)
Constructs a new FieldChainInfo object with FN as the new head of the list.
FieldChainInfo(const FieldChainInfo &Other)=default
FieldChainInfo add(const FieldNodeT &FN)
Constructs a new FieldChainInfo object with FN appended.
void printNoteMsg(llvm::raw_ostream &Out) const
A lightweight polymorphic wrapper around FieldRegion *.
virtual bool isBase() const
FieldNode(const FieldRegion *FR)
void Profile(llvm::FoldingSetNodeID &ID) const
virtual void printSeparator(llvm::raw_ostream &Out) const =0
Print the separator.
bool isSameRegion(const FieldRegion *OtherFR) const
Helper method for uniqueing.
const FieldRegion * getRegion() const
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...
FieldNode & operator=(const FieldNode &)=delete
FieldNode & operator=(const FieldNode &&)=delete
FieldNode(const FieldNode &)=delete
FieldNode(FieldNode &&)=delete
const FieldDecl * getDecl() const
~FieldNode()=default
FieldNodes are never meant to be created on the heap, see FindUninitializedFields::addFieldToUninits(...
virtual void printNode(llvm::raw_ostream &Out) const =0
Print the node. Should contain the name of the field stored in FR.
std::pair< ProgramStateRef, const UninitFieldMap & > getResults()
Returns with the modified state and a map of (uninitialized region, note message) pairs.
FindUninitializedFields(ProgramStateRef State, const TypedValueRegion *const R, const UninitObjCheckerOptions &Opts)
Constructs the FindUninitializedField object, searches for and stores uninitialized fields in R.
bool isAnyFieldInitialized()
Returns whether the analyzed region contains at least one initialized field.
MemRegion - The root abstract class for all memory regions.
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
TypedValueRegion - An abstract class representing regions having a typed value.
std::string getVariableName(const FieldDecl *Field)
Returns with Field's name.
std::map< const FieldRegion *, llvm::SmallString< 50 > > UninitFieldMap
bool isPrimitiveType(const QualType &T)
Returns true if T is a primitive type.
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
bool isDereferencableType(const QualType &T)
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
@ Other
Other implicit parameter.
bool ShouldConvertNotesToWarnings
std::string IgnoredRecordsWithFieldPattern
bool CheckPointeeInitialization