Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:37:08

0001 //===- DynamicExtent.h - Dynamic extent related APIs ------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 //  This file defines APIs that track and query dynamic extent information.
0010 //
0011 //===----------------------------------------------------------------------===//
0012 
0013 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICEXTENT_H
0014 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICEXTENT_H
0015 
0016 #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
0017 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
0018 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
0019 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h"
0020 #include "clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h"
0021 
0022 namespace clang {
0023 namespace ento {
0024 
0025 /// \returns The stored dynamic extent for the region \p MR.
0026 DefinedOrUnknownSVal getDynamicExtent(ProgramStateRef State,
0027                                       const MemRegion *MR, SValBuilder &SVB);
0028 
0029 /// \returns The element extent of the type \p Ty.
0030 DefinedOrUnknownSVal getElementExtent(QualType Ty, SValBuilder &SVB);
0031 
0032 /// \returns The stored element count of the region \p MR.
0033 DefinedOrUnknownSVal getDynamicElementCount(ProgramStateRef State,
0034                                             const MemRegion *MR,
0035                                             SValBuilder &SVB, QualType Ty);
0036 
0037 /// Set the dynamic extent \p Extent of the region \p MR.
0038 ProgramStateRef setDynamicExtent(ProgramStateRef State, const MemRegion *MR,
0039                                  DefinedOrUnknownSVal Extent);
0040 
0041 /// Get the dynamic extent for a symbolic value that represents a buffer. If
0042 /// there is an offsetting to the underlying buffer we consider that too.
0043 /// Returns with an SVal that represents the extent, this is Unknown if the
0044 /// engine cannot deduce the extent.
0045 /// E.g.
0046 ///   char buf[3];
0047 ///   (buf); // extent is 3
0048 ///   (buf + 1); // extent is 2
0049 ///   (buf + 3); // extent is 0
0050 ///   (buf + 4); // extent is -1
0051 ///
0052 ///   char *bufptr;
0053 ///   (bufptr) // extent is unknown
0054 SVal getDynamicExtentWithOffset(ProgramStateRef State, SVal BufV);
0055 
0056 /// \returns The stored element count of the region represented by a symbolic
0057 /// value \p BufV.
0058 DefinedOrUnknownSVal getDynamicElementCountWithOffset(ProgramStateRef State,
0059                                                       SVal BufV, QualType Ty);
0060 
0061 } // namespace ento
0062 } // namespace clang
0063 
0064 #endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICEXTENT_H