clang 8.0.0

DynamicTypeMap.h
Go to the documentation of this file.
1 //===- DynamicTypeMap.h - Dynamic type map ----------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file provides APIs for tracking dynamic type information.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEMAP_H
15 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEMAP_H
16
17 #include "clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeInfo.h"
18 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
19 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h"
20 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
21 #include "llvm/ADT/ImmutableMap.h"
22 #include "clang/AST/Type.h"
23
24 namespace clang {
25 namespace ento {
26
27 class MemRegion;
28
29 /// The GDM component containing the dynamic type info. This is a map from a
30 /// symbol to its most likely type.
31 struct DynamicTypeMap {};
32
33 using DynamicTypeMapImpl =
34 llvm::ImmutableMap<const MemRegion *, DynamicTypeInfo>;
35
36 template <>
37 struct ProgramStateTrait<DynamicTypeMap>
38 : public ProgramStatePartialTrait<DynamicTypeMapImpl> {
39 static void *GDMIndex();
40 };
41
42 /// Get dynamic type information for a region.
43 DynamicTypeInfo getDynamicTypeInfo(ProgramStateRef State,
44 const MemRegion *Reg);
45
46 /// Set dynamic type information of the region; return the new state.
47 ProgramStateRef setDynamicTypeInfo(ProgramStateRef State, const MemRegion *Reg,
48 DynamicTypeInfo NewTy);
49
50 /// Set dynamic type information of the region; return the new state.
51 inline ProgramStateRef setDynamicTypeInfo(ProgramStateRef State,
52 const MemRegion *Reg, QualType NewTy,
53 bool CanBeSubClassed = true) {
54 return setDynamicTypeInfo(State, Reg,
55 DynamicTypeInfo(NewTy, CanBeSubClassed));
56 }
57
58 void printDynamicTypeInfo(ProgramStateRef State, raw_ostream &Out,
59 const char *NL, const char *Sep);
60
61 } // namespace ento
62 } // namespace clang
63
64 #endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEMAP_H
ento
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:638
clang::ento::MemRegion
MemRegion - The root abstract class for all memory regions.
Definition: MemRegion.h:95
DynamicTypeInfo.h
Type.h
C Language Family Type Representation.
clang::ento::DynamicTypeMap
The GDM component containing the dynamic type info.
Definition: DynamicTypeMap.h:31
State
LineState State
Definition: UnwrappedLineFormatter.cpp:877
ProgramState_Fwd.h
clang::ento::ProgramStateTrait
Definition: ProgramState.h:55
clang::ento::ProgramStatePartialTrait
Definition: ProgramState.h:53
clang::ento::DynamicTypeMapImpl
llvm::ImmutableMap< const MemRegion *, DynamicTypeInfo > DynamicTypeMapImpl
Definition: DynamicTypeMap.h:34
clang::ento::DynamicTypeInfo
Stores the currently inferred strictest bound on the runtime type of a region in a given state along ...
Definition: DynamicTypeInfo.h:19
ProgramState.h
clang::ento::setDynamicTypeInfo
ProgramStateRef setDynamicTypeInfo(ProgramStateRef State, const MemRegion *Reg, DynamicTypeInfo NewTy)
Set dynamic type information of the region; return the new state.
Definition: DynamicTypeMap.cpp:49
llvm::IntrusiveRefCntPtr
Definition: LLVM.h:45
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:22
clang::ento::getDynamicTypeInfo
DynamicTypeInfo getDynamicTypeInfo(ProgramStateRef State, const MemRegion *Reg)
Get dynamic type information for a region.
Definition: DynamicTypeMap.cpp:28
ProgramStateTrait.h
clang::ento::printDynamicTypeInfo
void printDynamicTypeInfo(ProgramStateRef State, raw_ostream &Out, const char *NL, const char *Sep)
Definition: DynamicTypeMap.cpp:57