1 //== DynamicTypeMap.h - Dynamic type map ----------------------- -*- C++ -*--=//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file provides APIs for tracking dynamic type information.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEMAP_H
15 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEMAP_H
16 #include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h"
17 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
18 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
19 #include "llvm/ADT/ImmutableMap.h"
24 /// The GDM component containing the dynamic type info. This is a map from a
25 /// symbol to its most likely type.
26 struct DynamicTypeMap {};
27 typedef llvm::ImmutableMap<const MemRegion *, DynamicTypeInfo>
30 struct ProgramStateTrait<DynamicTypeMap>
31 : public ProgramStatePartialTrait<DynamicTypeMapImpl> {
32 static void *GDMIndex() {
38 /// \brief Get dynamic type information for a region.
39 DynamicTypeInfo getDynamicTypeInfo(ProgramStateRef State,
40 const MemRegion *Reg);
42 /// \brief Set dynamic type information of the region; return the new state.
43 ProgramStateRef setDynamicTypeInfo(ProgramStateRef State, const MemRegion *Reg,
44 DynamicTypeInfo NewTy);
46 /// \brief Set dynamic type information of the region; return the new state.
47 inline ProgramStateRef setDynamicTypeInfo(ProgramStateRef State,
48 const MemRegion *Reg, QualType NewTy,
49 bool CanBeSubClassed = true) {
50 return setDynamicTypeInfo(State, Reg,
51 DynamicTypeInfo(NewTy, CanBeSubClassed));
57 #endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEMAP_H