clang: include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALBUILDER_H

15#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALBUILDER_H

16

31#include "llvm/ADT/ImmutableList.h"

32#include

33#include

34

36

47

48namespace ento {

49

55 virtual void anchor();

56

57protected:

59

60

62

63

65

66

68

70

72

73

75

76

78

79public:

82

84

86

87

90

93

94

95

98

99

100

103

104

105

106

109

110

111

113

114

115

116

117

119

120

121

122

123

125

126

127

128

130

131

134

137

140

141

143

145

148

151

153

157

161

164

167

170

172

173

174

178 const void *symbolTag = nullptr) {

179 return SymMgr.conjureSymbol(Elem, LCtx, type, visitCount, symbolTag);

180 }

181

182

184

185

187

188

189

190

191

192

193

197 unsigned count);

206 unsigned visitCount,

207 const void *symbolTag = nullptr);

209 unsigned visitCount,

210 const void *symbolTag = nullptr);

211

212

216

217

218

219

220

221

224 unsigned Count);

225

228

233 unsigned count);

234

236

238

241 unsigned blockCount);

242

243

244

245

246

248

252

256 BasicVals.getLazyCompoundValData(store, region));

257 }

258

262

266

270

274

276

282

286

288

292

296

300

307

311

315

319

322

325

328

331

332

335

339

343

344

345

346

348

349 assert((type->isPointerType() || type->isObjCObjectPointerType() ||

350 type->isBlockPointerType() || type->isNullPtrType() ||

351 type->isReferenceType()) &&

352 "makeNullWithType must use pointer type");

353

354

355

356

357 type = type->isReferenceType()

358 ? Context.getPointerType(type->getPointeeType())

361 }

362

366

370

374

378

379

380 std::optionalloc::MemRegionVal

382

383

384

385

391

392

395

396

399};

400

403 ProgramStateManager &stateMgr);

404

405}

406

407}

408

409#endif

Defines the clang::ASTContext interface.

static bool isUnsigned(SValBuilder &SVB, NonLoc Value)

Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.

Defines the clang::LangOptions interface.

C Language Family Type Representation.

llvm::APInt getValue() const

Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...

AddrLabelExpr - The GNU address of label extension, representing &&label.

Stores options for the analyzer from the command line.

BinaryOperatorKind Opcode

Represents a block literal declaration, which is like an unnamed FunctionDecl.

A boolean literal, per ([C++ lex.bool] Boolean literals).

Represents a static or instance method of a struct/union/class.

Represents a C++ struct/union/class.

Represents a ValueDecl that came out of a declarator.

This represents one expression.

Represents a function declaration or definition.

It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...

This represents a decl that may have a name.

ObjCBoolLiteralExpr - Objective-C Boolean Literal.

A (possibly-)qualified type.

It represents a stack frame of the call stack (based on CallEvent).

Stmt - This represents one statement.

bool isUnsignedIntegerOrEnumerationType() const

Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...

A safe wrapper around APSInt objects allocated and owned by BasicValueFactory.

Represents an abstract call to a function or method along a particular path.

static bool isLocType(QualType T)

MemRegion - The root abstract class for all memory regions.

DefinedSVal getConjuredHeapSymbolVal(ConstCFGElementRef elem, const LocationContext *LCtx, QualType type, unsigned Count)

Conjure a symbol representing heap allocated memory region.

DefinedOrUnknownSVal makeZeroVal(QualType type)

Construct an SVal representing '0' for the specified type.

DefinedSVal getMemberPointer(const NamedDecl *ND)

NonLoc makePointerToMember(const DeclaratorDecl *DD)

Definition SValBuilder.h:259

SVal evalMinus(NonLoc val)

SVal evalComplement(NonLoc val)

virtual const llvm::APSInt * getKnownValue(ProgramStateRef state, SVal val)=0

Evaluates a given SVal.

BasicValueFactory & getBasicValueFactory()

Definition SValBuilder.h:162

loc::ConcreteInt makeLoc(const llvm::APSInt &integer)

Definition SValBuilder.h:375

NonLoc makeCompoundVal(QualType type, llvm::ImmutableList< SVal > vals)

Definition SValBuilder.h:249

SymbolManager SymMgr

Manages the creation of symbols.

Definition SValBuilder.h:64

virtual SVal evalBinOpLN(ProgramStateRef state, BinaryOperator::Opcode op, Loc lhs, NonLoc rhs, QualType resultTy)=0

Create a new value which represents a binary expression with a memory location and non-location opera...

DefinedSVal getMetadataSymbolVal(const void *symbolTag, const MemRegion *region, const Expr *expr, QualType type, const LocationContext *LCtx, unsigned count)

MemRegionManager & getRegionManager()

Definition SValBuilder.h:168

ProgramStateManager & getStateManager()

Definition SValBuilder.h:152

SVal makeSymExprValNN(BinaryOperator::Opcode op, NonLoc lhs, NonLoc rhs, QualType resultTy)

Constructs a symbolic expression for two non-location values.

virtual SVal evalBinOpLL(ProgramStateRef state, BinaryOperator::Opcode op, Loc lhs, Loc rhs, QualType resultTy)=0

Create a new value which represents a binary expression with two memory location operands.

const unsigned ArrayIndexWidth

The width of the scalar type used for array indices.

Definition SValBuilder.h:77

DefinedSVal getBlockPointer(const BlockDecl *block, CanQualType locTy, const LocationContext *locContext, unsigned blockCount)

DefinedSVal getFunctionPointer(const FunctionDecl *func)

const QualType ArrayIndexTy

The scalar type to use for array indices.

Definition SValBuilder.h:74

NonLoc makePointerToMember(const PointerToMemberData *PTMD)

Definition SValBuilder.h:263

NonLoc makeIntValWithWidth(QualType ptrType, uint64_t integer)

Definition SValBuilder.h:312

loc::GotoLabel makeLoc(const AddrLabelExpr *expr)

Definition SValBuilder.h:371

NonLoc makeArrayIndex(uint64_t idx)

Definition SValBuilder.h:271

ASTContext & getContext()

Definition SValBuilder.h:149

nonloc::ConcreteInt makeIntVal(const IntegerLiteral *integer)

Definition SValBuilder.h:277

SVal convertToArrayIndex(SVal val)

QualType getArrayIndexType() const

Definition SValBuilder.h:158

loc::MemRegionVal makeLoc(SymbolRef sym)

Definition SValBuilder.h:363

virtual const llvm::APSInt * getMinValue(ProgramStateRef state, SVal val)=0

Tries to get the minimal possible (integer) value of a given SVal.

const BasicValueFactory & getBasicValueFactory() const

Definition SValBuilder.h:163

virtual SVal evalBinOpNN(ProgramStateRef state, BinaryOperator::Opcode op, NonLoc lhs, NonLoc rhs, QualType resultTy)=0

Create a new value which represents a binary expression with two non- location operands.

DefinedSVal makeSymbolVal(SymbolRef Sym)

Make an SVal that represents the given symbol.

Definition SValBuilder.h:386

SVal evalCast(SVal V, QualType CastTy, QualType OriginalTy)

Cast a given SVal to another SVal using given QualType's.

NonLoc makeIntVal(uint64_t integer, bool isUnsigned)

Definition SValBuilder.h:308

const AnalyzerOptions & getAnalyzerOptions() const

Definition SValBuilder.h:171

nonloc::ConcreteInt makeTruthVal(bool b)

Definition SValBuilder.h:340

DefinedSVal makeIntVal(uint64_t integer, QualType type)

Definition SValBuilder.h:301

BasicValueFactory BasicVals

Manager of APSInt values.

Definition SValBuilder.h:61

ConditionTruthVal areEqual(ProgramStateRef state, SVal lhs, SVal rhs)

virtual SVal simplifySVal(ProgramStateRef State, SVal Val)=0

Simplify symbolic expressions within a given SVal.

QualType getConditionType() const

Definition SValBuilder.h:154

MemRegionManager MemMgr

Manages the creation of memory regions.

Definition SValBuilder.h:67

SVal evalEQ(ProgramStateRef state, SVal lhs, SVal rhs)

SVal evalUnaryOp(ProgramStateRef state, UnaryOperator::Opcode opc, SVal operand, QualType type)

DefinedOrUnknownSVal getDerivedRegionValueSymbolVal(SymbolRef parentSymbol, const TypedValueRegion *region)

loc::MemRegionVal getCXXThis(const CXXMethodDecl *D, const StackFrameContext *SFC)

Return a memory region for the 'this' object reference.

nonloc::ConcreteInt makeTruthVal(bool b, QualType type)

Definition SValBuilder.h:336

const MemRegionManager & getRegionManager() const

Definition SValBuilder.h:169

virtual ~SValBuilder()=default

loc::ConcreteInt makeNullWithType(QualType type)

Create NULL pointer, with proper pointer bit-width for given address space.

Definition SValBuilder.h:347

virtual const llvm::APSInt * getMaxValue(ProgramStateRef state, SVal val)=0

Tries to get the maximal possible (integer) value of a given SVal.

NonLoc makeIntVal(const llvm::APInt &integer, bool isUnsigned)

Definition SValBuilder.h:297

ProgramStateManager & StateMgr

Definition SValBuilder.h:69

loc::MemRegionVal makeLoc(const MemRegion *region)

Definition SValBuilder.h:367

std::optional< SVal > getConstantVal(const Expr *E)

Returns the value of E, if it can be determined in a non-path-sensitive manner.

NonLoc makeLocAsInteger(Loc loc, unsigned bits)

Definition SValBuilder.h:316

DefinedOrUnknownSVal conjureSymbolVal(const void *symbolTag, ConstCFGElementRef elem, const LocationContext *LCtx, unsigned count)

Create a new symbol with a unique 'name'.

NonLoc makeZeroArrayIndex()

Definition SValBuilder.h:267

const ASTContext & getContext() const

Definition SValBuilder.h:150

SVal evalIntegralCast(ProgramStateRef state, SVal val, QualType castTy, QualType originalType)

SymbolManager & getSymbolManager()

Definition SValBuilder.h:165

DefinedOrUnknownSVal getRegionValueSymbolVal(const TypedValueRegion *region)

Make a unique symbol for value of region.

SVal evalBinOp(ProgramStateRef state, BinaryOperator::Opcode op, SVal lhs, SVal rhs, QualType type)

loc::ConcreteInt makeIntLocVal(const llvm::APSInt &integer)

Definition SValBuilder.h:293

NonLoc makeLazyCompoundVal(const StoreRef &store, const TypedValueRegion *region)

Definition SValBuilder.h:253

ASTContext & Context

Definition SValBuilder.h:58

nonloc::SymbolVal makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op, APSIntPtr rhs, QualType type)

const AnalyzerOptions & AnOpts

Definition SValBuilder.h:71

const SymbolManager & getSymbolManager() const

Definition SValBuilder.h:166

std::optional< loc::MemRegionVal > getCastedMemRegionVal(const MemRegion *region, QualType type)

Return MemRegionVal on success cast, otherwise return std::nullopt.

loc::MemRegionVal getAllocaRegionVal(const Expr *E, const LocationContext *LCtx, unsigned Count)

Create an SVal representing the result of an alloca()-like call, that is, an AllocaRegion on the stac...

nonloc::ConcreteInt makeBoolVal(const ObjCBoolLiteralExpr *boolean)

Definition SValBuilder.h:283

const SymbolConjured * conjureSymbol(ConstCFGElementRef Elem, const LocationContext *LCtx, QualType type, unsigned visitCount, const void *symbolTag=nullptr)

Definition SValBuilder.h:175

nonloc::ConcreteInt makeIntVal(const llvm::APSInt &integer)

Definition SValBuilder.h:289

SValBuilder(llvm::BumpPtrAllocator &alloc, ASTContext &context, ProgramStateManager &stateMgr)

SVal - This represents a symbolic expression, which can be either an L-value or an R-value.

virtual QualType getType() const =0

A symbol representing the result of an expression in the case when we do not know anything about what...

TypedValueRegion - An abstract class representing regions having a typed value.

The simplest example of a concrete compound value is nonloc::CompoundVal, which represents a concrete...

Value representing integer constant.

While nonloc::CompoundVal covers a few simple use cases, nonloc::LazyCompoundVal is a more performant...

Value representing pointer-to-member.

Represents symbolic expression that isn't a location.

const internal::VariadicAllOfMatcher< Type > type

Matches Types in the clang AST.

const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr

Matches expressions.

SValBuilder * createSimpleSValBuilder(llvm::BumpPtrAllocator &alloc, ASTContext &context, ProgramStateManager &stateMgr)

IntrusiveRefCntPtr< const ProgramState > ProgramStateRef

const SymExpr * SymbolRef

The JSON file list parser is used to communicate input to InstallAPI.

CanQual< Type > CanQualType

Represents a canonical, potentially-qualified type.

CFGBlock::ConstCFGElementRef ConstCFGElementRef