clang  10.0.0svn
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 cast information from \p CastFromTy to \p CastToTy of \p MR.
40 const DynamicCastInfo *getDynamicCastInfo(ProgramStateRef State,
41  const MemRegion *MR,
42  QualType CastFromTy,
43  QualType CastToTy);
44 
45 /// Set dynamic type information of the region; return the new state.
47  DynamicTypeInfo NewTy);
48 
49 /// Set dynamic type information of the region; return the new state.
51  QualType NewTy, bool CanBeSubClassed = true);
52 
53 /// Set dynamic type and cast information of the region; return the new state.
55  const MemRegion *MR,
56  QualType CastFromTy,
57  QualType CastToTy,
58  bool IsCastSucceeds);
59 
60 /// Removes the dead type informations from \p State.
62 
63 /// Removes the dead cast informations from \p State.
65 
66 void printDynamicTypeInfoJson(raw_ostream &Out, ProgramStateRef State,
67  const char *NL = "\n", unsigned int Space = 0,
68  bool IsDot = false);
69 
70 } // namespace ento
71 } // namespace clang
72 
73 #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.
Definition: DynamicType.cpp:79
C Language Family Type Representation.
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
const DynamicCastInfo * getDynamicCastInfo(ProgramStateRef State, const MemRegion *MR, QualType CastFromTy, QualType CastToTy)
Get dynamic cast information from CastFromTy to CastToTy of MR.
Definition: DynamicType.cpp:64
LineState State
ProgramStateRef removeDeadCasts(ProgramStateRef State, SymbolReaper &SR)
Removes the dead cast informations from State.
ProgramStateRef removeDeadTypes(ProgramStateRef State, SymbolReaper &SR)
Removes the dead type informations from State.
const DynamicTypeInfo * getRawDynamicTypeInfo(ProgramStateRef State, const MemRegion *MR)
Get raw dynamic type information for the region MR.
Definition: DynamicType.cpp:59
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.
Definition: DynamicType.cpp:91
DynamicTypeInfo getDynamicTypeInfo(ProgramStateRef State, const MemRegion *MR)
Get dynamic type information for the region MR.
Definition: DynamicType.cpp:40
void printDynamicTypeInfoJson(raw_ostream &Out, ProgramStateRef State, const char *NL="\, unsigned int Space=0, bool IsDot=false)