clang  14.0.0git
DynamicType.h
Go to the documentation of this file.
1 //===- DynamicType.h - Dynamic type 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 type information. This
10 // information can be used to devirtualize calls during the symbolic execution
11 // or do type checking.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPE_H
16 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPE_H
17 
18 #include "clang/AST/Type.h"
25 #include "llvm/ADT/ImmutableMap.h"
26 #include "llvm/ADT/Optional.h"
27 
28 namespace clang {
29 namespace ento {
30 
31 /// Get dynamic type information for the region \p MR.
32 DynamicTypeInfo getDynamicTypeInfo(ProgramStateRef State, const MemRegion *MR);
33 
34 /// Get raw dynamic type information for the region \p MR.
35 const DynamicTypeInfo *getRawDynamicTypeInfo(ProgramStateRef State,
36  const MemRegion *MR);
37 
38 /// Get dynamic type information stored in a class object represented by \p Sym.
40  SymbolRef Sym);
41 
42 /// Get dynamic cast information from \p CastFromTy to \p CastToTy of \p MR.
43 const DynamicCastInfo *getDynamicCastInfo(ProgramStateRef State,
44  const MemRegion *MR,
45  QualType CastFromTy,
46  QualType CastToTy);
47 
48 /// Set dynamic type information of the region; return the new state.
50  DynamicTypeInfo NewTy);
51 
52 /// Set dynamic type information of the region; return the new state.
54  QualType NewTy, bool CanBeSubClassed = true);
55 
56 /// Set constraint on a type contained in a class object; return the new state.
58  SymbolRef Sym,
59  DynamicTypeInfo NewTy);
60 
61 /// Set constraint on a type contained in a class object; return the new state.
63  SymbolRef Sym, QualType NewTy,
64  bool CanBeSubClassed = true);
65 
66 /// Set dynamic type and cast information of the region; return the new state.
68  const MemRegion *MR,
69  QualType CastFromTy,
70  QualType CastToTy,
71  bool IsCastSucceeds);
72 
73 /// Removes the dead type informations from \p State.
75 
76 /// Removes the dead cast informations from \p State.
78 
79 /// Removes the dead Class object type informations from \p State.
81  SymbolReaper &SR);
82 
83 void printDynamicTypeInfoJson(raw_ostream &Out, ProgramStateRef State,
84  const char *NL = "\n", unsigned int Space = 0,
85  bool IsDot = false);
86 
87 } // namespace ento
88 } // namespace clang
89 
90 #endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPE_H
clang::ento::setDynamicTypeInfo
ProgramStateRef setDynamicTypeInfo(ProgramStateRef State, const MemRegion *MR, DynamicTypeInfo NewTy)
Set dynamic type information of the region; return the new state.
clang::ento::removeDeadClassObjectTypes
ProgramStateRef removeDeadClassObjectTypes(ProgramStateRef State, SymbolReaper &SR)
Removes the dead Class object type informations from State.
clang::ento::ProgramStateRef
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
Definition: ProgramState_Fwd.h:37
ProgramState_Fwd.h
SymbolManager.h
clang::ento::SymbolRef
const SymExpr * SymbolRef
Definition: SymExpr.h:110
clang::ento::printDynamicTypeInfoJson
void printDynamicTypeInfoJson(raw_ostream &Out, ProgramStateRef State, const char *NL="\n", unsigned int Space=0, bool IsDot=false)
clang::ento::removeDeadCasts
ProgramStateRef removeDeadCasts(ProgramStateRef State, SymbolReaper &SR)
Removes the dead cast informations from State.
DynamicTypeInfo.h
DynamicCastInfo.h
clang::ento::setClassObjectDynamicTypeInfo
ProgramStateRef setClassObjectDynamicTypeInfo(ProgramStateRef State, SymbolRef Sym, DynamicTypeInfo NewTy)
Set constraint on a type contained in a class object; return the new state.
clang::ento::getDynamicCastInfo
const DynamicCastInfo * getDynamicCastInfo(ProgramStateRef State, const MemRegion *MR, QualType CastFromTy, QualType CastToTy)
Get dynamic cast information from CastFromTy to CastToTy of MR.
Type.h
clang::ento::removeDeadTypes
ProgramStateRef removeDeadTypes(ProgramStateRef State, SymbolReaper &SR)
Removes the dead type informations from State.
clang::ento::setDynamicTypeAndCastInfo
ProgramStateRef setDynamicTypeAndCastInfo(ProgramStateRef State, const MemRegion *MR, QualType CastFromTy, QualType CastToTy, bool IsCastSucceeds)
Set dynamic type and cast information of the region; return the new state.
State
LineState State
Definition: UnwrappedLineFormatter.cpp:986
ProgramState.h
clang
Definition: CalledOnceCheck.h:17
clang::ento::getDynamicTypeInfo
DynamicTypeInfo getDynamicTypeInfo(ProgramStateRef State, const MemRegion *MR)
Get dynamic type information for the region MR.
ProgramStateTrait.h
clang::ento::getClassObjectDynamicTypeInfo
DynamicTypeInfo getClassObjectDynamicTypeInfo(ProgramStateRef State, SymbolRef Sym)
Get dynamic type information stored in a class object represented by Sym.
clang::ento::getRawDynamicTypeInfo
const DynamicTypeInfo * getRawDynamicTypeInfo(ProgramStateRef State, const MemRegion *MR)
Get raw dynamic type information for the region MR.