clang 17.0.0git
SVals.h
Go to the documentation of this file.
1//===- SVals.h - Abstract Values for Static Analysis ------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines SVal, Loc, and NonLoc, classes that represent
10// abstract r-values for use with path-sensitive value tracking.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALS_H
15#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALS_H
16
17#include "clang/AST/Expr.h"
18#include "clang/AST/Type.h"
19#include "clang/Basic/LLVM.h"
21#include "llvm/ADT/FoldingSet.h"
22#include "llvm/ADT/ImmutableList.h"
23#include "llvm/ADT/PointerUnion.h"
24#include "llvm/Support/Casting.h"
25#include <cassert>
26#include <cstdint>
27#include <optional>
28#include <utility>
29
30//==------------------------------------------------------------------------==//
31// Base SVal types.
32//==------------------------------------------------------------------------==//
33
34namespace clang {
35
36class CXXBaseSpecifier;
37class FunctionDecl;
38class LabelDecl;
39
40namespace ento {
41
42class CompoundValData;
43class LazyCompoundValData;
44class MemRegion;
45class PointerToMemberData;
46class SValBuilder;
47class TypedValueRegion;
48
49namespace nonloc {
50
51/// Sub-kinds for NonLoc values.
52enum Kind {
53#define NONLOC_SVAL(Id, Parent) Id ## Kind,
54#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.def"
55};
56
57} // namespace nonloc
58
59namespace loc {
60
61/// Sub-kinds for Loc values.
62enum Kind {
63#define LOC_SVAL(Id, Parent) Id ## Kind,
64#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.def"
65};
66
67} // namespace loc
68
69/// SVal - This represents a symbolic expression, which can be either
70/// an L-value or an R-value.
71///
72class SVal {
73public:
74 enum BaseKind {
75 // The enumerators must be representable using 2 bits.
76#define BASIC_SVAL(Id, Parent) Id ## Kind,
77#define ABSTRACT_SVAL_WITH_KIND(Id, Parent) Id ## Kind,
78#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.def"
79 };
80 enum { BaseBits = 2, BaseMask = 0b11 };
81
82protected:
83 const void *Data = nullptr;
84
85 /// The lowest 2 bits are a BaseKind (0 -- 3).
86 /// The higher bits are an unsigned "kind" value.
87 unsigned Kind = 0;
88
89 explicit SVal(const void *d, bool isLoc, unsigned ValKind)
90 : Data(d), Kind((isLoc ? LocKind : NonLocKind) | (ValKind << BaseBits)) {}
91
92 explicit SVal(BaseKind k, const void *D = nullptr) : Data(D), Kind(k) {}
93
94public:
95 explicit SVal() = default;
96
97 /// Convert to the specified SVal type, asserting that this SVal is of
98 /// the desired type.
99 template <typename T> T castAs() const { return llvm::cast<T>(*this); }
100
101 /// Convert to the specified SVal type, returning std::nullopt if this SVal is
102 /// not of the desired type.
103 template <typename T> std::optional<T> getAs() const {
104 return llvm::dyn_cast<T>(*this);
105 }
106
107 unsigned getRawKind() const { return Kind; }
108 BaseKind getBaseKind() const { return (BaseKind) (Kind & BaseMask); }
109 unsigned getSubKind() const { return Kind >> BaseBits; }
110
111 // This method is required for using SVal in a FoldingSetNode. It
112 // extracts a unique signature for this SVal object.
113 void Profile(llvm::FoldingSetNodeID &ID) const {
114 ID.AddInteger((unsigned) getRawKind());
115 ID.AddPointer(Data);
116 }
117
118 bool operator==(SVal R) const {
119 return getRawKind() == R.getRawKind() && Data == R.Data;
120 }
121
122 bool operator!=(SVal R) const { return !(*this == R); }
123
124 bool isUnknown() const {
125 return getRawKind() == UnknownValKind;
126 }
127
128 bool isUndef() const {
129 return getRawKind() == UndefinedValKind;
130 }
131
132 bool isUnknownOrUndef() const {
133 return getRawKind() <= UnknownValKind;
134 }
135
136 bool isValid() const {
137 return getRawKind() > UnknownValKind;
138 }
139
140 bool isConstant() const;
141
142 bool isConstant(int I) const;
143
144 bool isZeroConstant() const;
145
146 /// getAsFunctionDecl - If this SVal is a MemRegionVal and wraps a
147 /// CodeTextRegion wrapping a FunctionDecl, return that FunctionDecl.
148 /// Otherwise return 0.
149 const FunctionDecl *getAsFunctionDecl() const;
150
151 /// If this SVal is a location and wraps a symbol, return that
152 /// SymbolRef. Otherwise return 0.
153 ///
154 /// Casts are ignored during lookup.
155 /// \param IncludeBaseRegions The boolean that controls whether the search
156 /// should continue to the base regions if the region is not symbolic.
157 SymbolRef getAsLocSymbol(bool IncludeBaseRegions = false) const;
158
159 /// Get the symbol in the SVal or its base region.
161
162 /// If this SVal wraps a symbol return that SymbolRef.
163 /// Otherwise, return 0.
164 ///
165 /// Casts are ignored during lookup.
166 /// \param IncludeBaseRegions The boolean that controls whether the search
167 /// should continue to the base regions if the region is not symbolic.
168 SymbolRef getAsSymbol(bool IncludeBaseRegions = false) const;
169
170 /// If this SVal is loc::ConcreteInt or nonloc::ConcreteInt,
171 /// return a pointer to APSInt which is held in it.
172 /// Otherwise, return nullptr.
173 const llvm::APSInt *getAsInteger() const;
174
175 const MemRegion *getAsRegion() const;
176
177 /// printJson - Pretty-prints in JSON format.
178 void printJson(raw_ostream &Out, bool AddQuotes) const;
179
180 void dumpToStream(raw_ostream &OS) const;
181 void dump() const;
182
184 const SymExpr *SE = getAsSymbol(/*IncludeBaseRegions=*/true);
185 if (SE)
186 return SE->symbol_begin();
187 else
189 }
190
192 return SymExpr::symbol_end();
193 }
194
195 /// Try to get a reasonable type for the given value.
196 ///
197 /// \returns The best approximation of the value type or Null.
198 /// In theory, all symbolic values should be typed, but this function
199 /// is still a WIP and might have a few blind spots.
200 ///
201 /// \note This function should not be used when the user has access to the
202 /// bound expression AST node as well, since AST always has exact types.
203 ///
204 /// \note Loc values are interpreted as pointer rvalues for the purposes of
205 /// this method.
206 QualType getType(const ASTContext &) const;
207};
208
209inline raw_ostream &operator<<(raw_ostream &os, clang::ento::SVal V) {
210 V.dumpToStream(os);
211 return os;
212}
213
214class UndefinedVal : public SVal {
215public:
216 UndefinedVal() : SVal(UndefinedValKind) {}
217 static bool classof(SVal V) { return V.getBaseKind() == UndefinedValKind; }
218};
219
221public:
222 // We want calling these methods to be a compiler error since they are
223 // tautologically false.
224 bool isUndef() const = delete;
225 bool isValid() const = delete;
226
227 static bool classof(SVal V) { return !V.isUndef(); }
228
229protected:
230 explicit DefinedOrUnknownSVal(const void *d, bool isLoc, unsigned ValKind)
231 : SVal(d, isLoc, ValKind) {}
232 explicit DefinedOrUnknownSVal(BaseKind k, void *D = nullptr) : SVal(k, D) {}
233};
234
236public:
237 explicit UnknownVal() : DefinedOrUnknownSVal(UnknownValKind) {}
238
239 static bool classof(SVal V) { return V.getBaseKind() == UnknownValKind; }
240};
241
243public:
244 // We want calling these methods to be a compiler error since they are
245 // tautologically true/false.
246 bool isUnknown() const = delete;
247 bool isUnknownOrUndef() const = delete;
248 bool isValid() const = delete;
249
250 static bool classof(SVal V) { return !V.isUnknownOrUndef(); }
251
252protected:
253 explicit DefinedSVal(const void *d, bool isLoc, unsigned ValKind)
254 : DefinedOrUnknownSVal(d, isLoc, ValKind) {}
255};
256
257/// Represents an SVal that is guaranteed to not be UnknownVal.
258class KnownSVal : public SVal {
259public:
262 static bool classof(SVal V) { return !V.isUnknown(); }
263};
264
265class NonLoc : public DefinedSVal {
266protected:
267 explicit NonLoc(unsigned SubKind, const void *d)
268 : DefinedSVal(d, false, SubKind) {}
269
270public:
271 void dumpToStream(raw_ostream &Out) const;
272
273 static bool isCompoundType(QualType T) {
274 return T->isArrayType() || T->isRecordType() ||
275 T->isAnyComplexType() || T->isVectorType();
276 }
277
278 static bool classof(SVal V) { return V.getBaseKind() == NonLocKind; }
279};
280
281class Loc : public DefinedSVal {
282protected:
283 explicit Loc(unsigned SubKind, const void *D)
284 : DefinedSVal(const_cast<void *>(D), true, SubKind) {}
285
286public:
287 void dumpToStream(raw_ostream &Out) const;
288
289 static bool isLocType(QualType T) {
290 return T->isAnyPointerType() || T->isBlockPointerType() ||
291 T->isReferenceType() || T->isNullPtrType();
292 }
293
294 static bool classof(SVal V) { return V.getBaseKind() == LocKind; }
295};
296
297//==------------------------------------------------------------------------==//
298// Subclasses of NonLoc.
299//==------------------------------------------------------------------------==//
300
301namespace nonloc {
302
303/// Represents symbolic expression that isn't a location.
304class SymbolVal : public NonLoc {
305public:
306 SymbolVal() = delete;
307 SymbolVal(SymbolRef sym) : NonLoc(SymbolValKind, sym) {
308 assert(sym);
309 assert(!Loc::isLocType(sym->getType()));
310 }
311
312 LLVM_ATTRIBUTE_RETURNS_NONNULL
314 return (const SymExpr *) Data;
315 }
316
317 bool isExpression() const {
318 return !isa<SymbolData>(getSymbol());
319 }
320
321 static bool classof(SVal V) {
322 return V.getBaseKind() == NonLocKind && V.getSubKind() == SymbolValKind;
323 }
324
325 static bool classof(NonLoc V) { return V.getSubKind() == SymbolValKind; }
326};
327
328/// Value representing integer constant.
329class ConcreteInt : public NonLoc {
330public:
331 explicit ConcreteInt(const llvm::APSInt& V) : NonLoc(ConcreteIntKind, &V) {}
332
333 const llvm::APSInt& getValue() const {
334 return *static_cast<const llvm::APSInt *>(Data);
335 }
336
337 static bool classof(SVal V) {
338 return V.getBaseKind() == NonLocKind && V.getSubKind() == ConcreteIntKind;
339 }
340
341 static bool classof(NonLoc V) { return V.getSubKind() == ConcreteIntKind; }
342};
343
344class LocAsInteger : public NonLoc {
345 friend class ento::SValBuilder;
346
347 explicit LocAsInteger(const std::pair<SVal, uintptr_t> &data)
348 : NonLoc(LocAsIntegerKind, &data) {
349 // We do not need to represent loc::ConcreteInt as LocAsInteger,
350 // as it'd collapse into a nonloc::ConcreteInt instead.
351 assert(data.first.getBaseKind() == LocKind &&
352 (data.first.getSubKind() == loc::MemRegionValKind ||
353 data.first.getSubKind() == loc::GotoLabelKind));
354 }
355
356public:
357 Loc getLoc() const {
358 const std::pair<SVal, uintptr_t> *D =
359 static_cast<const std::pair<SVal, uintptr_t> *>(Data);
360 return D->first.castAs<Loc>();
361 }
362
363 unsigned getNumBits() const {
364 const std::pair<SVal, uintptr_t> *D =
365 static_cast<const std::pair<SVal, uintptr_t> *>(Data);
366 return D->second;
367 }
368
369 static bool classof(SVal V) {
370 return V.getBaseKind() == NonLocKind && V.getSubKind() == LocAsIntegerKind;
371 }
372
373 static bool classof(NonLoc V) { return V.getSubKind() == LocAsIntegerKind; }
374};
375
376class CompoundVal : public NonLoc {
377 friend class ento::SValBuilder;
378
379 explicit CompoundVal(const CompoundValData *D) : NonLoc(CompoundValKind, D) {
380 assert(D);
381 }
382
383public:
384 LLVM_ATTRIBUTE_RETURNS_NONNULL
385 const CompoundValData* getValue() const {
386 return static_cast<const CompoundValData *>(Data);
387 }
388
389 using iterator = llvm::ImmutableList<SVal>::iterator;
390
391 iterator begin() const;
392 iterator end() const;
393
394 static bool classof(SVal V) {
395 return V.getBaseKind() == NonLocKind && V.getSubKind() == CompoundValKind;
396 }
397
398 static bool classof(NonLoc V) { return V.getSubKind() == CompoundValKind; }
399};
400
401class LazyCompoundVal : public NonLoc {
402 friend class ento::SValBuilder;
403
404 explicit LazyCompoundVal(const LazyCompoundValData *D)
405 : NonLoc(LazyCompoundValKind, D) {
406 assert(D);
407 }
408
409public:
410 LLVM_ATTRIBUTE_RETURNS_NONNULL
412 return static_cast<const LazyCompoundValData *>(Data);
413 }
414
415 /// It might return null.
416 const void *getStore() const;
417
418 LLVM_ATTRIBUTE_RETURNS_NONNULL
419 const TypedValueRegion *getRegion() const;
420
421 static bool classof(SVal V) {
422 return V.getBaseKind() == NonLocKind &&
423 V.getSubKind() == LazyCompoundValKind;
424 }
425
426 static bool classof(NonLoc V) {
427 return V.getSubKind() == LazyCompoundValKind;
428 }
429};
430
431/// Value representing pointer-to-member.
432///
433/// This value is qualified as NonLoc because neither loading nor storing
434/// operations are applied to it. Instead, the analyzer uses the L-value coming
435/// from pointer-to-member applied to an object.
436/// This SVal is represented by a NamedDecl which can be a member function
437/// pointer or a member data pointer and an optional list of CXXBaseSpecifiers.
438/// This list is required to accumulate the pointer-to-member cast history to
439/// figure out the correct subobject field. In particular, implicit casts grow
440/// this list and explicit casts like static_cast shrink this list.
441class PointerToMember : public NonLoc {
442 friend class ento::SValBuilder;
443
444public:
446 llvm::PointerUnion<const NamedDecl *, const PointerToMemberData *>;
447
448 const PTMDataType getPTMData() const {
449 return PTMDataType::getFromOpaqueValue(const_cast<void *>(Data));
450 }
451
452 bool isNullMemberPointer() const;
453
454 const NamedDecl *getDecl() const;
455
456 template<typename AdjustedDecl>
457 const AdjustedDecl *getDeclAs() const {
458 return dyn_cast_or_null<AdjustedDecl>(getDecl());
459 }
460
461 using iterator = llvm::ImmutableList<const CXXBaseSpecifier *>::iterator;
462
463 iterator begin() const;
464 iterator end() const;
465
466 static bool classof(SVal V) {
467 return V.getBaseKind() == NonLocKind &&
468 V.getSubKind() == PointerToMemberKind;
469 }
470
471 static bool classof(NonLoc V) {
472 return V.getSubKind() == PointerToMemberKind;
473 }
474
475private:
476 explicit PointerToMember(const PTMDataType D)
477 : NonLoc(PointerToMemberKind, D.getOpaqueValue()) {}
478};
479
480} // namespace nonloc
481
482//==------------------------------------------------------------------------==//
483// Subclasses of Loc.
484//==------------------------------------------------------------------------==//
485
486namespace loc {
487
488class GotoLabel : public Loc {
489public:
490 explicit GotoLabel(const LabelDecl *Label) : Loc(GotoLabelKind, Label) {
491 assert(Label);
492 }
493
494 const LabelDecl *getLabel() const {
495 return static_cast<const LabelDecl *>(Data);
496 }
497
498 static bool classof(SVal V) {
499 return V.getBaseKind() == LocKind && V.getSubKind() == GotoLabelKind;
500 }
501
502 static bool classof(Loc V) { return V.getSubKind() == GotoLabelKind; }
503};
504
505class MemRegionVal : public Loc {
506public:
507 explicit MemRegionVal(const MemRegion* r) : Loc(MemRegionValKind, r) {
508 assert(r);
509 }
510
511 /// Get the underlining region.
512 const MemRegion *getRegion() const {
513 return static_cast<const MemRegion *>(Data);
514 }
515
516 /// Get the underlining region and strip casts.
517 const MemRegion* stripCasts(bool StripBaseCasts = true) const;
518
519 template <typename REGION>
520 const REGION* getRegionAs() const {
521 return dyn_cast<REGION>(getRegion());
522 }
523
524 bool operator==(const MemRegionVal &R) const {
525 return getRegion() == R.getRegion();
526 }
527
528 bool operator!=(const MemRegionVal &R) const {
529 return getRegion() != R.getRegion();
530 }
531
532 static bool classof(SVal V) {
533 return V.getBaseKind() == LocKind && V.getSubKind() == MemRegionValKind;
534 }
535
536 static bool classof(Loc V) { return V.getSubKind() == MemRegionValKind; }
537};
538
539class ConcreteInt : public Loc {
540public:
541 explicit ConcreteInt(const llvm::APSInt& V) : Loc(ConcreteIntKind, &V) {}
542
543 const llvm::APSInt &getValue() const {
544 return *static_cast<const llvm::APSInt *>(Data);
545 }
546
547 static bool classof(SVal V) {
548 return V.getBaseKind() == LocKind && V.getSubKind() == ConcreteIntKind;
549 }
550
551 static bool classof(Loc V) { return V.getSubKind() == ConcreteIntKind; }
552};
553
554} // namespace loc
555} // namespace ento
556} // namespace clang
557
558namespace llvm {
559template <typename To, typename From>
560struct CastInfo<
561 To, From,
562 std::enable_if_t<std::is_base_of<::clang::ento::SVal, From>::value>>
563 : public CastIsPossible<To, ::clang::ento::SVal> {
564 using Self = CastInfo<
565 To, From,
566 std::enable_if_t<std::is_base_of<::clang::ento::SVal, From>::value>>;
567 static bool isPossible(const From &V) {
568 return To::classof(*static_cast<const ::clang::ento::SVal *>(&V));
569 }
570 static std::optional<To> castFailed() { return std::optional<To>{}; }
571 static To doCast(const From &f) {
572 return *static_cast<const To *>(cast<::clang::ento::SVal>(&f));
573 }
574 static std::optional<To> doCastIfPossible(const From &f) {
575 if (!Self::isPossible(f))
576 return Self::castFailed();
577 return doCast(f);
578 }
579};
580} // namespace llvm
581
582#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALS_H
#define V(N, I)
Definition: ASTContext.h:3230
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
#define REGION(Id, Parent)
Definition: MemRegion.h:98
C Language Family Type Representation.
std::string Label
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:182
Represents a function declaration or definition.
Definition: Decl.h:1917
Represents the declaration of a label.
Definition: Decl.h:494
This represents a decl that may have a name.
Definition: Decl.h:247
A (possibly-)qualified type.
Definition: Type.h:736
bool isBlockPointerType() const
Definition: Type.h:6929
bool isArrayType() const
Definition: Type.h:6987
bool isReferenceType() const
Definition: Type.h:6933
bool isAnyComplexType() const
Definition: Type.h:7019
bool isVectorType() const
Definition: Type.h:7023
bool isAnyPointerType() const
Definition: Type.h:6925
bool isNullPtrType() const
Definition: Type.h:7254
bool isRecordType() const
Definition: Type.h:7011
bool isUndef() const =delete
static bool classof(SVal V)
Definition: SVals.h:227
DefinedOrUnknownSVal(const void *d, bool isLoc, unsigned ValKind)
Definition: SVals.h:230
bool isValid() const =delete
DefinedOrUnknownSVal(BaseKind k, void *D=nullptr)
Definition: SVals.h:232
static bool classof(SVal V)
Definition: SVals.h:250
bool isUnknown() const =delete
DefinedSVal(const void *d, bool isLoc, unsigned ValKind)
Definition: SVals.h:253
bool isUnknownOrUndef() const =delete
bool isValid() const =delete
Represents an SVal that is guaranteed to not be UnknownVal.
Definition: SVals.h:258
KnownSVal(const UndefinedVal &V)
Definition: SVals.h:261
KnownSVal(const DefinedSVal &V)
Definition: SVals.h:260
static bool classof(SVal V)
Definition: SVals.h:262
void dumpToStream(raw_ostream &Out) const
Definition: SVals.cpp:363
Loc(unsigned SubKind, const void *D)
Definition: SVals.h:283
static bool classof(SVal V)
Definition: SVals.h:294
static bool isLocType(QualType T)
Definition: SVals.h:289
MemRegion - The root abstract class for all memory regions.
Definition: MemRegion.h:95
static bool isCompoundType(QualType T)
Definition: SVals.h:273
static bool classof(SVal V)
Definition: SVals.h:278
void dumpToStream(raw_ostream &Out) const
Definition: SVals.cpp:297
NonLoc(unsigned SubKind, const void *d)
Definition: SVals.h:267
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
Definition: SVals.h:72
bool isUndef() const
Definition: SVals.h:128
bool operator!=(SVal R) const
Definition: SVals.h:122
const void * Data
Definition: SVals.h:83
bool isZeroConstant() const
Definition: SVals.cpp:261
unsigned getSubKind() const
Definition: SVals.h:109
bool isUnknownOrUndef() const
Definition: SVals.h:132
void dumpToStream(raw_ostream &OS) const
Definition: SVals.cpp:280
void dump() const
Definition: SVals.cpp:269
SymbolRef getAsSymbol(bool IncludeBaseRegions=false) const
If this SVal wraps a symbol return that SymbolRef.
Definition: SVals.cpp:104
const FunctionDecl * getAsFunctionDecl() const
getAsFunctionDecl - If this SVal is a MemRegionVal and wraps a CodeTextRegion wrapping a FunctionDecl...
Definition: SVals.cpp:46
SymExpr::symbol_iterator symbol_begin() const
Definition: SVals.h:183
void printJson(raw_ostream &Out, bool AddQuotes) const
printJson - Pretty-prints in JSON format.
Definition: SVals.cpp:271
bool isConstant() const
Definition: SVals.cpp:249
SymExpr::symbol_iterator symbol_end() const
Definition: SVals.h:191
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: SVals.h:113
unsigned getRawKind() const
Definition: SVals.h:107
unsigned Kind
The lowest 2 bits are a BaseKind (0 – 3).
Definition: SVals.h:87
SVal(BaseKind k, const void *D=nullptr)
Definition: SVals.h:92
std::optional< T > getAs() const
Convert to the specified SVal type, returning std::nullopt if this SVal is not of the desired type.
Definition: SVals.h:103
QualType getType(const ASTContext &) const
Try to get a reasonable type for the given value.
Definition: SVals.cpp:184
const llvm::APSInt * getAsInteger() const
If this SVal is loc::ConcreteInt or nonloc::ConcreteInt, return a pointer to APSInt which is held in ...
Definition: SVals.cpp:112
bool operator==(SVal R) const
Definition: SVals.h:118
SymbolRef getAsLocSymbol(bool IncludeBaseRegions=false) const
If this SVal is a location and wraps a symbol, return that SymbolRef.
Definition: SVals.cpp:68
const MemRegion * getAsRegion() const
Definition: SVals.cpp:120
BaseKind getBaseKind() const
Definition: SVals.h:108
bool isValid() const
Definition: SVals.h:136
SymbolRef getLocSymbolInBase() const
Get the symbol in the SVal or its base region.
Definition: SVals.cpp:80
SVal(const void *d, bool isLoc, unsigned ValKind)
Definition: SVals.h:89
T castAs() const
Convert to the specified SVal type, asserting that this SVal is of the desired type.
Definition: SVals.h:99
bool isUnknown() const
Definition: SVals.h:124
Iterator over symbols that the current symbol depends on.
Definition: SymExpr.h:70
Symbolic value.
Definition: SymExpr.h:29
static symbol_iterator symbol_end()
Definition: SymExpr.h:87
virtual QualType getType() const =0
symbol_iterator symbol_begin() const
Definition: SymExpr.h:86
TypedValueRegion - An abstract class representing regions having a typed value.
Definition: MemRegion.h:531
static bool classof(SVal V)
Definition: SVals.h:217
static bool classof(SVal V)
Definition: SVals.h:239
ConcreteInt(const llvm::APSInt &V)
Definition: SVals.h:541
static bool classof(SVal V)
Definition: SVals.h:547
static bool classof(Loc V)
Definition: SVals.h:551
const llvm::APSInt & getValue() const
Definition: SVals.h:543
const LabelDecl * getLabel() const
Definition: SVals.h:494
static bool classof(Loc V)
Definition: SVals.h:502
GotoLabel(const LabelDecl *Label)
Definition: SVals.h:490
static bool classof(SVal V)
Definition: SVals.h:498
const MemRegion * getRegion() const
Get the underlining region.
Definition: SVals.h:512
const MemRegion * stripCasts(bool StripBaseCasts=true) const
Get the underlining region and strip casts.
Definition: SVals.cpp:189
const REGION * getRegionAs() const
Definition: SVals.h:520
MemRegionVal(const MemRegion *r)
Definition: SVals.h:507
bool operator!=(const MemRegionVal &R) const
Definition: SVals.h:528
bool operator==(const MemRegionVal &R) const
Definition: SVals.h:524
static bool classof(Loc V)
Definition: SVals.h:536
static bool classof(SVal V)
Definition: SVals.h:532
static bool classof(NonLoc V)
Definition: SVals.h:398
LLVM_ATTRIBUTE_RETURNS_NONNULL const CompoundValData * getValue() const
Definition: SVals.h:385
static bool classof(SVal V)
Definition: SVals.h:394
llvm::ImmutableList< SVal >::iterator iterator
Definition: SVals.h:389
Value representing integer constant.
Definition: SVals.h:329
ConcreteInt(const llvm::APSInt &V)
Definition: SVals.h:331
const llvm::APSInt & getValue() const
Definition: SVals.h:333
static bool classof(NonLoc V)
Definition: SVals.h:341
static bool classof(SVal V)
Definition: SVals.h:337
LLVM_ATTRIBUTE_RETURNS_NONNULL const LazyCompoundValData * getCVData() const
Definition: SVals.h:411
LLVM_ATTRIBUTE_RETURNS_NONNULL const TypedValueRegion * getRegion() const
Definition: SVals.cpp:197
const void * getStore() const
It might return null.
Definition: SVals.cpp:193
static bool classof(NonLoc V)
Definition: SVals.h:426
static bool classof(SVal V)
Definition: SVals.h:421
static bool classof(SVal V)
Definition: SVals.h:369
unsigned getNumBits() const
Definition: SVals.h:363
static bool classof(NonLoc V)
Definition: SVals.h:373
Value representing pointer-to-member.
Definition: SVals.h:441
llvm::PointerUnion< const NamedDecl *, const PointerToMemberData * > PTMDataType
Definition: SVals.h:446
llvm::ImmutableList< const CXXBaseSpecifier * >::iterator iterator
Definition: SVals.h:461
const AdjustedDecl * getDeclAs() const
Definition: SVals.h:457
static bool classof(NonLoc V)
Definition: SVals.h:471
const PTMDataType getPTMData() const
Definition: SVals.h:448
const NamedDecl * getDecl() const
Definition: SVals.cpp:205
static bool classof(SVal V)
Definition: SVals.h:466
Represents symbolic expression that isn't a location.
Definition: SVals.h:304
SymbolVal(SymbolRef sym)
Definition: SVals.h:307
LLVM_ATTRIBUTE_RETURNS_NONNULL SymbolRef getSymbol() const
Definition: SVals.h:313
static bool classof(SVal V)
Definition: SVals.h:321
static bool classof(NonLoc V)
Definition: SVals.h:325
bool isExpression() const
Definition: SVals.h:317
Kind
Sub-kinds for Loc values.
Definition: SVals.h:62
Kind
Sub-kinds for NonLoc values.
Definition: SVals.h:52
raw_ostream & operator<<(raw_ostream &Out, const CheckerBase &Checker)
Dump checker name to stream.
Definition: Checker.cpp:35
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
YAML serialization mapping.
Definition: Dominators.h:30
Definition: Format.h:4756
#define true
Definition: stdbool.h:21
#define false
Definition: stdbool.h:22