clang  14.0.0git
DynamicExtent.h
Go to the documentation of this file.
1 //===- DynamicExtent.h - Dynamic extent related APIs ------------*- 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 APIs that track and query dynamic extent information.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICEXTENT_H
14 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICEXTENT_H
15 
21 
22 namespace clang {
23 namespace ento {
24 
25 /// \returns The stored dynamic extent for the region \p MR.
26 DefinedOrUnknownSVal getDynamicExtent(ProgramStateRef State,
27  const MemRegion *MR, SValBuilder &SVB);
28 
29 /// \returns The element extent of the type \p Ty.
30 DefinedOrUnknownSVal getElementExtent(QualType Ty, SValBuilder &SVB);
31 
32 /// \returns The stored element count of the region \p MR.
33 DefinedOrUnknownSVal getDynamicElementCount(ProgramStateRef State,
34  const MemRegion *MR,
35  SValBuilder &SVB, QualType Ty);
36 
37 /// Set the dynamic extent \p Extent of the region \p MR.
39  DefinedOrUnknownSVal Extent, SValBuilder &SVB);
40 
41 /// Get the dynamic extent for a symbolic value that represents a buffer. If
42 /// there is an offsetting to the underlying buffer we consider that too.
43 /// Returns with an SVal that represents the extent, this is Unknown if the
44 /// engine cannot deduce the extent.
45 /// E.g.
46 /// char buf[3];
47 /// (buf); // extent is 3
48 /// (buf + 1); // extent is 2
49 /// (buf + 3); // extent is 0
50 /// (buf + 4); // extent is -1
51 ///
52 /// char *bufptr;
53 /// (bufptr) // extent is unknown
55 
56 } // namespace ento
57 } // namespace clang
58 
59 #endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICEXTENT_H
clang::ento::ProgramStateRef
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
Definition: ProgramState_Fwd.h:37
ProgramState_Fwd.h
clang::ento::getDynamicExtentWithOffset
SVal getDynamicExtentWithOffset(ProgramStateRef State, SVal BufV)
Get the dynamic extent for a symbolic value that represents a buffer.
clang::ento::getDynamicElementCount
DefinedOrUnknownSVal getDynamicElementCount(ProgramStateRef State, const MemRegion *MR, SValBuilder &SVB, QualType Ty)
clang::ento::getElementExtent
DefinedOrUnknownSVal getElementExtent(QualType Ty, SValBuilder &SVB)
SValBuilder.h
State
LineState State
Definition: UnwrappedLineFormatter.cpp:987
ProgramState.h
clang::ento::getDynamicExtent
DefinedOrUnknownSVal getDynamicExtent(ProgramStateRef State, const MemRegion *MR, SValBuilder &SVB)
clang
Definition: CalledOnceCheck.h:17
MemRegion.h
clang::ento::setDynamicExtent
ProgramStateRef setDynamicExtent(ProgramStateRef State, const MemRegion *MR, DefinedOrUnknownSVal Extent, SValBuilder &SVB)
Set the dynamic extent Extent of the region MR.
ProgramStateTrait.h