clang 22.0.0git
SValBuilder.h
Go to the documentation of this file.
1// SValBuilder.h - Construction of SVals from evaluating expressions -*- 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 SValBuilder, a class that defines the interface for
10// "symbolical evaluators" which construct an SVal from an expression.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALBUILDER_H
15#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALBUILDER_H
16
19#include "clang/AST/Expr.h"
20#include "clang/AST/ExprObjC.h"
21#include "clang/AST/Type.h"
22#include "clang/Analysis/CFG.h"
23#include "clang/Basic/LLVM.h"
31#include "llvm/ADT/ImmutableList.h"
32#include <cstdint>
33#include <optional>
34
35namespace clang {
36
37class AnalyzerOptions;
38class BlockDecl;
39class CXXBoolLiteralExpr;
40class CXXMethodDecl;
41class CXXRecordDecl;
42class DeclaratorDecl;
43class FunctionDecl;
44class LocationContext;
45class StackFrameContext;
46class Stmt;
47
48namespace ento {
49
50class CallEvent;
51class ConditionTruthVal;
52class ProgramStateManager;
53class StoreRef;
55 virtual void anchor();
56
57protected:
59
60 /// Manager of APSInt values.
62
63 /// Manages the creation of symbols.
65
66 /// Manages the creation of memory regions.
68
70
72
73 /// The scalar type to use for array indices.
75
76 /// The width of the scalar type used for array indices.
77 const unsigned ArrayIndexWidth;
78
79public:
80 SValBuilder(llvm::BumpPtrAllocator &alloc, ASTContext &context,
81 ProgramStateManager &stateMgr);
82
83 virtual ~SValBuilder() = default;
84
85 SVal evalCast(SVal V, QualType CastTy, QualType OriginalTy);
86
87 // Handles casts of type CK_IntegralCast.
89 QualType originalType);
90
93
94 /// Create a new value which represents a binary expression with two non-
95 /// location operands.
97 NonLoc lhs, NonLoc rhs, QualType resultTy) = 0;
98
99 /// Create a new value which represents a binary expression with two memory
100 /// location operands.
102 Loc lhs, Loc rhs, QualType resultTy) = 0;
103
104 /// Create a new value which represents a binary expression with a memory
105 /// location and non-location operands. For example, this would be used to
106 /// evaluate a pointer arithmetic operation.
108 Loc lhs, NonLoc rhs, QualType resultTy) = 0;
109
110 /// Evaluates a given SVal. If the SVal has only one possible (integer) value,
111 /// that value is returned. Otherwise, returns NULL.
112 virtual const llvm::APSInt *getKnownValue(ProgramStateRef state, SVal val) = 0;
113
114 /// Tries to get the minimal possible (integer) value of a given SVal. This
115 /// always returns the value of a ConcreteInt, but may return NULL if the
116 /// value is symbolic and the constraint manager cannot provide a useful
117 /// answer.
118 virtual const llvm::APSInt *getMinValue(ProgramStateRef state, SVal val) = 0;
119
120 /// Tries to get the maximal possible (integer) value of a given SVal. This
121 /// always returns the value of a ConcreteInt, but may return NULL if the
122 /// value is symbolic and the constraint manager cannot provide a useful
123 /// answer.
124 virtual const llvm::APSInt *getMaxValue(ProgramStateRef state, SVal val) = 0;
125
126 /// Simplify symbolic expressions within a given SVal. Return an SVal
127 /// that represents the same value, but is hopefully easier to work with
128 /// than the original SVal.
129 virtual SVal simplifySVal(ProgramStateRef State, SVal Val) = 0;
130
131 /// Constructs a symbolic expression for two non-location values.
133 NonLoc lhs, NonLoc rhs, QualType resultTy);
134
136 SVal operand, QualType type);
137
139 SVal lhs, SVal rhs, QualType type);
140
141 /// \return Whether values in \p lhs and \p rhs are equal at \p state.
143
144 SVal evalEQ(ProgramStateRef state, SVal lhs, SVal rhs);
145
148
150 const ASTContext &getContext() const { return Context; }
151
153
155 return Context.getLangOpts().CPlusPlus ? Context.BoolTy : Context.IntTy;
156 }
157
159 return ArrayIndexTy;
160 }
161
164
166 const SymbolManager &getSymbolManager() const { return SymMgr; }
167
169 const MemRegionManager &getRegionManager() const { return MemMgr; }
170
171 const AnalyzerOptions &getAnalyzerOptions() const { return AnOpts; }
172
173 // Forwarding methods to SymbolManager.
174
176 const LocationContext *LCtx,
177 QualType type, unsigned visitCount,
178 const void *symbolTag = nullptr) {
179 return SymMgr.conjureSymbol(Elem, LCtx, type, visitCount, symbolTag);
180 }
181
182 /// Construct an SVal representing '0' for the specified type.
184
185 /// Make a unique symbol for value of region.
187
188 /// Create a new symbol with a unique 'name'.
189 ///
190 /// We resort to conjured symbols when we cannot construct a derived symbol.
191 /// The advantage of symbols derived/built from other symbols is that we
192 /// preserve the relation between related(or even equivalent) expressions, so
193 /// conjured symbols should be used sparingly.
194 DefinedOrUnknownSVal conjureSymbolVal(const void *symbolTag,
196 const LocationContext *LCtx,
197 unsigned count);
198 DefinedOrUnknownSVal conjureSymbolVal(const void *symbolTag,
200 const LocationContext *LCtx,
201 QualType type, unsigned count);
203 const LocationContext *LCtx,
204 QualType type, unsigned visitCount);
206 unsigned visitCount,
207 const void *symbolTag = nullptr);
209 unsigned visitCount,
210 const void *symbolTag = nullptr);
211
212 /// Conjure a symbol representing heap allocated memory region.
214 const LocationContext *LCtx,
215 QualType type, unsigned Count);
216
217 /// Create an SVal representing the result of an alloca()-like call, that is,
218 /// an AllocaRegion on the stack.
219 ///
220 /// After calling this function, it's a good idea to set the extent of the
221 /// returned AllocaRegion.
223 const LocationContext *LCtx,
224 unsigned Count);
225
227 SymbolRef parentSymbol, const TypedValueRegion *region);
228
229 DefinedSVal getMetadataSymbolVal(const void *symbolTag,
230 const MemRegion *region,
231 const Expr *expr, QualType type,
232 const LocationContext *LCtx,
233 unsigned count);
234
236
238
240 const LocationContext *locContext,
241 unsigned blockCount);
242
243 /// Returns the value of \p E, if it can be determined in a non-path-sensitive
244 /// manner.
245 ///
246 /// If \p E is not a constant or cannot be modeled, returns \c std::nullopt.
247 std::optional<SVal> getConstantVal(const Expr *E);
248
249 NonLoc makeCompoundVal(QualType type, llvm::ImmutableList<SVal> vals) {
251 }
252
254 const TypedValueRegion *region) {
256 BasicVals.getLazyCompoundValData(store, region));
257 }
258
260 return nonloc::PointerToMember(DD);
261 }
262
264 return nonloc::PointerToMember(PTMD);
265 }
266
268 return nonloc::ConcreteInt(BasicVals.getValue(0, ArrayIndexTy));
269 }
270
271 NonLoc makeArrayIndex(uint64_t idx) {
272 return nonloc::ConcreteInt(BasicVals.getValue(idx, ArrayIndexTy));
273 }
274
276
278 return nonloc::ConcreteInt(
279 BasicVals.getValue(integer->getValue(),
281 }
282
284 return makeTruthVal(boolean->getValue(), boolean->getType());
285 }
286
288
289 nonloc::ConcreteInt makeIntVal(const llvm::APSInt& integer) {
290 return nonloc::ConcreteInt(BasicVals.getValue(integer));
291 }
292
293 loc::ConcreteInt makeIntLocVal(const llvm::APSInt &integer) {
294 return loc::ConcreteInt(BasicVals.getValue(integer));
295 }
296
297 NonLoc makeIntVal(const llvm::APInt& integer, bool isUnsigned) {
298 return nonloc::ConcreteInt(BasicVals.getValue(integer, isUnsigned));
299 }
300
301 DefinedSVal makeIntVal(uint64_t integer, QualType type) {
302 if (Loc::isLocType(type))
303 return loc::ConcreteInt(BasicVals.getValue(integer, type));
304
305 return nonloc::ConcreteInt(BasicVals.getValue(integer, type));
306 }
307
308 NonLoc makeIntVal(uint64_t integer, bool isUnsigned) {
310 }
311
312 NonLoc makeIntValWithWidth(QualType ptrType, uint64_t integer) {
313 return nonloc::ConcreteInt(BasicVals.getValue(integer, ptrType));
314 }
315
316 NonLoc makeLocAsInteger(Loc loc, unsigned bits) {
318 }
319
321 APSIntPtr rhs, QualType type);
322
324 const SymExpr *lhs, QualType type);
325
327 const SymExpr *rhs, QualType type);
328
330 QualType type);
331
332 /// Create a NonLoc value for cast.
333 nonloc::SymbolVal makeNonLoc(const SymExpr *operand, QualType fromTy,
334 QualType toTy);
335
338 }
339
342 }
343
344 /// Create NULL pointer, with proper pointer bit-width for given address
345 /// space.
346 /// \param type pointer type.
348 // We cannot use the `isAnyPointerType()`.
349 assert((type->isPointerType() || type->isObjCObjectPointerType() ||
350 type->isBlockPointerType() || type->isNullPtrType() ||
351 type->isReferenceType()) &&
352 "makeNullWithType must use pointer type");
353
354 // The `sizeof(T&)` is `sizeof(T)`, thus we replace the reference with a
355 // pointer. Here we assume that references are actually implemented by
356 // pointers under-the-hood.
357 type = type->isReferenceType()
358 ? Context.getPointerType(type->getPointeeType())
359 : type;
361 }
362
365 }
366
368 return loc::MemRegionVal(region);
369 }
370
372 return loc::GotoLabel(expr->getLabel());
373 }
374
375 loc::ConcreteInt makeLoc(const llvm::APSInt &integer) {
376 return loc::ConcreteInt(BasicVals.getValue(integer));
377 }
378
379 /// Return MemRegionVal on success cast, otherwise return std::nullopt.
380 std::optional<loc::MemRegionVal>
382
383 /// Make an SVal that represents the given symbol. This follows the convention
384 /// of representing Loc-type symbols (symbolic pointers and references)
385 /// as Loc values wrapping the symbol rather than as plain symbol values.
387 if (Loc::isLocType(Sym->getType()))
388 return makeLoc(Sym);
389 return nonloc::SymbolVal(Sym);
390 }
391
392 /// Return a memory region for the 'this' object reference.
394 const StackFrameContext *SFC);
395
396 /// Return a memory region for the 'this' object reference.
398 const StackFrameContext *SFC);
399};
400
401SValBuilder* createSimpleSValBuilder(llvm::BumpPtrAllocator &alloc,
402 ASTContext &context,
403 ProgramStateManager &stateMgr);
404
405} // namespace ento
406
407} // namespace clang
408
409#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALBUILDER_H
Defines the clang::ASTContext interface.
#define V(N, I)
Definition: ASTContext.h:3597
static bool isUnsigned(SValBuilder &SVB, NonLoc Value)
const Decl * D
Expr * E
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
C Language Family Type Representation.
__device__ __2f16 b
llvm::APInt getValue() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:188
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const LangOptions & getLangOpts() const
Definition: ASTContext.h:894
CanQualType BoolTy
Definition: ASTContext.h:1223
CanQualType IntTy
Definition: ASTContext.h:1231
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition: Expr.h:4486
Stores options for the analyzer from the command line.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4634
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition: ExprCXX.h:723
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2129
Represents a C++ struct/union/class.
Definition: DeclCXX.h:258
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:779
This represents one expression.
Definition: Expr.h:112
QualType getType() const
Definition: Expr.h:144
Represents a function declaration or definition.
Definition: Decl.h:1999
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
This represents a decl that may have a name.
Definition: Decl.h:273
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition: ExprObjC.h:88
A (possibly-)qualified type.
Definition: TypeBase.h:937
It represents a stack frame of the call stack (based on CallEvent).
bool isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
Definition: Type.cpp:2277
A safe wrapper around APSInt objects allocated and owned by BasicValueFactory.
Definition: APSIntPtr.h:19
const CompoundValData * getCompoundValData(QualType T, llvm::ImmutableList< SVal > Vals)
APSIntPtr getZeroWithTypeSize(QualType T)
APSIntPtr getIntValue(uint64_t X, bool isUnsigned)
const std::pair< SVal, uintptr_t > & getPersistentSValWithData(const SVal &V, uintptr_t Data)
APSIntPtr getTruthValue(bool b, QualType T)
const LazyCompoundValData * getLazyCompoundValData(const StoreRef &store, const TypedValueRegion *region)
Represents an abstract call to a function or method along a particular path.
Definition: CallEvent.h:153
static bool isLocType(QualType T)
Definition: SVals.h:262
const SymbolicRegion * getSymbolicRegion(SymbolRef Sym, const MemSpaceRegion *MemSpace=nullptr)
Retrieve or create a "symbolic" memory region.
Definition: MemRegion.cpp:1260
MemRegion - The root abstract class for all memory regions.
Definition: MemRegion.h:98
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.
Definition: SValBuilder.cpp:62
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'.
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
nonloc::SymbolVal makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op, APSIntPtr rhs, QualType type)
Definition: SValBuilder.cpp:77
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
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
Definition: SVals.h:56
Symbolic value.
Definition: SymExpr.h:32
virtual QualType getType() const =0
A symbol representing the result of an expression in the case when we do not know anything about what...
Definition: SymbolManager.h:82
const SymbolConjured * conjureSymbol(ConstCFGElementRef Elem, const LocationContext *LCtx, QualType T, unsigned VisitCount, const void *SymbolTag=nullptr)
TypedValueRegion - An abstract class representing regions having a typed value.
Definition: MemRegion.h:563
The simplest example of a concrete compound value is nonloc::CompoundVal, which represents a concrete...
Definition: SVals.h:339
Value representing integer constant.
Definition: SVals.h:300
While nonloc::CompoundVal covers a few simple use cases, nonloc::LazyCompoundVal is a more performant...
Definition: SVals.h:389
Value representing pointer-to-member.
Definition: SVals.h:434
Represents symbolic expression that isn't a location.
Definition: SVals.h:279
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)
The JSON file list parser is used to communicate input to InstallAPI.
BinaryOperatorKind
CFGBlock::ConstCFGElementRef ConstCFGElementRef
Definition: CFG.h:1199
UnaryOperatorKind