1353942Sdim//===- DynamicType.h - Dynamic type related APIs ----------------*- C++ -*-===// 2353942Sdim// 3353942Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353942Sdim// See https://llvm.org/LICENSE.txt for license information. 5353942Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6353942Sdim// 7353942Sdim//===----------------------------------------------------------------------===// 8353942Sdim// 9353942Sdim// This file defines APIs that track and query dynamic type information. This 10353942Sdim// information can be used to devirtualize calls during the symbolic execution 11353942Sdim// or do type checking. 12353942Sdim// 13353942Sdim//===----------------------------------------------------------------------===// 14353942Sdim 15353942Sdim#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPE_H 16353942Sdim#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPE_H 17353942Sdim 18353942Sdim#include "clang/AST/Type.h" 19353942Sdim#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicCastInfo.h" 20353942Sdim#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeInfo.h" 21353942Sdim#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" 22353942Sdim#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h" 23353942Sdim#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h" 24353942Sdim#include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h" 25353942Sdim#include "llvm/ADT/ImmutableMap.h" 26353942Sdim#include "llvm/ADT/Optional.h" 27353942Sdim#include <utility> 28353942Sdim 29353942Sdimnamespace clang { 30353942Sdimnamespace ento { 31353942Sdim 32353942Sdim/// Get dynamic type information for the region \p MR. 33353942SdimDynamicTypeInfo getDynamicTypeInfo(ProgramStateRef State, const MemRegion *MR); 34353942Sdim 35353942Sdim/// Get raw dynamic type information for the region \p MR. 36353942Sdimconst DynamicTypeInfo *getRawDynamicTypeInfo(ProgramStateRef State, 37353942Sdim const MemRegion *MR); 38353942Sdim 39353942Sdim/// Get dynamic cast information from \p CastFromTy to \p CastToTy of \p MR. 40353942Sdimconst DynamicCastInfo *getDynamicCastInfo(ProgramStateRef State, 41353942Sdim const MemRegion *MR, 42353942Sdim QualType CastFromTy, 43353942Sdim QualType CastToTy); 44353942Sdim 45353942Sdim/// Set dynamic type information of the region; return the new state. 46353942SdimProgramStateRef setDynamicTypeInfo(ProgramStateRef State, const MemRegion *MR, 47353942Sdim DynamicTypeInfo NewTy); 48353942Sdim 49353942Sdim/// Set dynamic type information of the region; return the new state. 50353942SdimProgramStateRef setDynamicTypeInfo(ProgramStateRef State, const MemRegion *MR, 51353942Sdim QualType NewTy, bool CanBeSubClassed = true); 52353942Sdim 53353942Sdim/// Set dynamic type and cast information of the region; return the new state. 54353942SdimProgramStateRef setDynamicTypeAndCastInfo(ProgramStateRef State, 55353942Sdim const MemRegion *MR, 56353942Sdim QualType CastFromTy, 57353942Sdim QualType CastToTy, 58353942Sdim bool IsCastSucceeds); 59353942Sdim 60353942Sdim/// Removes the dead type informations from \p State. 61353942SdimProgramStateRef removeDeadTypes(ProgramStateRef State, SymbolReaper &SR); 62353942Sdim 63353942Sdim/// Removes the dead cast informations from \p State. 64353942SdimProgramStateRef removeDeadCasts(ProgramStateRef State, SymbolReaper &SR); 65353942Sdim 66353942Sdimvoid printDynamicTypeInfoJson(raw_ostream &Out, ProgramStateRef State, 67353942Sdim const char *NL = "\n", unsigned int Space = 0, 68353942Sdim bool IsDot = false); 69353942Sdim 70353942Sdim} // namespace ento 71353942Sdim} // namespace clang 72353942Sdim 73353942Sdim#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPE_H 74