clang  12.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 #include <utility>
28 
29 namespace clang {
30 namespace ento {
31 
32 /// Get dynamic type information for the region \p MR.
33 DynamicTypeInfo getDynamicTypeInfo(ProgramStateRef State, const MemRegion *MR);
34 
35 /// Get raw dynamic type information for the region \p MR.
36 const DynamicTypeInfo *getRawDynamicTypeInfo(ProgramStateRef State,
37  const MemRegion *MR);
38 
39 /// Get dynamic type information stored in a class object represented by \p Sym.
41  SymbolRef Sym);
42 
43 /// Get dynamic cast information from \p CastFromTy to \p CastToTy of \p MR.
44 const DynamicCastInfo *getDynamicCastInfo(ProgramStateRef State,
45  const MemRegion *MR,
46  QualType CastFromTy,
47  QualType CastToTy);
48 
49 /// Set dynamic type information of the region; return the new state.
51  DynamicTypeInfo NewTy);
52 
53 /// Set dynamic type information of the region; return the new state.
55  QualType NewTy, bool CanBeSubClassed = true);
56 
57 /// Set constraint on a type contained in a class object; return the new state.
59  SymbolRef Sym,
60  DynamicTypeInfo NewTy);
61 
62 /// Set constraint on a type contained in a class object; return the new state.
64  SymbolRef Sym, QualType NewTy,
65  bool CanBeSubClassed = true);
66 
67 /// Set dynamic type and cast information of the region; return the new state.
69  const MemRegion *MR,
70  QualType CastFromTy,
71  QualType CastToTy,
72  bool IsCastSucceeds);
73 
74 /// Removes the dead type informations from \p State.
76 
77 /// Removes the dead cast informations from \p State.
79 
80 /// Removes the dead Class object type informations from \p State.
82  SymbolReaper &SR);
83 
84 void printDynamicTypeInfoJson(raw_ostream &Out, ProgramStateRef State,
85  const char *NL = "\n", unsigned int Space = 0,
86  bool IsDot = false);
87 
88 } // namespace ento
89 } // namespace clang
90 
91 #endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPE_H
ProgramStateRef setDynamicTypeInfo(ProgramStateRef State, const MemRegion *MR, DynamicTypeInfo NewTy)
Set dynamic type information of the region; return the new state.
C Language Family Type Representation.
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
const SymExpr * SymbolRef
Definition: SymExpr.h:110
LineState State
ProgramStateRef removeDeadCasts(ProgramStateRef State, SymbolReaper &SR)
Removes the dead cast informations from State.
const DynamicCastInfo * getDynamicCastInfo(ProgramStateRef State, const MemRegion *MR, QualType CastFromTy, QualType CastToTy)
Get dynamic cast information from CastFromTy to CastToTy of MR.
ProgramStateRef removeDeadTypes(ProgramStateRef State, SymbolReaper &SR)
Removes the dead type informations from State.
ProgramStateRef setClassObjectDynamicTypeInfo(ProgramStateRef State, SymbolRef Sym, DynamicTypeInfo NewTy)
Set constraint on a type contained in a class object; return the new state.
Dataflow Directional Tag Classes.
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.
DynamicTypeInfo getClassObjectDynamicTypeInfo(ProgramStateRef State, SymbolRef Sym)
Get dynamic type information stored in a class object represented by Sym.
DynamicTypeInfo getDynamicTypeInfo(ProgramStateRef State, const MemRegion *MR)
Get dynamic type information for the region MR.
void printDynamicTypeInfoJson(raw_ostream &Out, ProgramStateRef State, const char *NL="\, unsigned int Space=0, bool IsDot=false)
ProgramStateRef removeDeadClassObjectTypes(ProgramStateRef State, SymbolReaper &SR)
Removes the dead Class object type informations from State.
const DynamicTypeInfo * getRawDynamicTypeInfo(ProgramStateRef State, const MemRegion *MR)
Get raw dynamic type information for the region MR.