clang  9.0.0svn
DynamicTypeMap.h
Go to the documentation of this file.
1 //===- DynamicTypeMap.h - Dynamic type map ----------------------*- 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 provides APIs for tracking dynamic type information.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEMAP_H
14 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEMAP_H
15 
20 #include "llvm/ADT/ImmutableMap.h"
21 #include "clang/AST/Type.h"
22 
23 namespace clang {
24 namespace ento {
25 
26 class MemRegion;
27 
28 /// The GDM component containing the dynamic type info. This is a map from a
29 /// symbol to its most likely type.
30 struct DynamicTypeMap {};
31 
32 using DynamicTypeMapImpl =
33  llvm::ImmutableMap<const MemRegion *, DynamicTypeInfo>;
34 
35 template <>
37  : public ProgramStatePartialTrait<DynamicTypeMapImpl> {
38  static void *GDMIndex();
39 };
40 
41 /// Get dynamic type information for a region.
43  const MemRegion *Reg);
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  const MemRegion *Reg, QualType NewTy,
52  bool CanBeSubClassed = true) {
53  return setDynamicTypeInfo(State, Reg,
54  DynamicTypeInfo(NewTy, CanBeSubClassed));
55 }
56 
57 void printDynamicTypeInfo(ProgramStateRef State, raw_ostream &Out,
58  const char *NL, const char *Sep);
59 
60 } // namespace ento
61 } // namespace clang
62 
63 #endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEMAP_H
A (possibly-)qualified type.
Definition: Type.h:639
MemRegion - The root abstract class for all memory regions.
Definition: MemRegion.h:94
C Language Family Type Representation.
The GDM component containing the dynamic type info.
LineState State
llvm::ImmutableMap< const MemRegion *, DynamicTypeInfo > DynamicTypeMapImpl
Stores the currently inferred strictest bound on the runtime type of a region in a given state along ...
ProgramStateRef setDynamicTypeInfo(ProgramStateRef State, const MemRegion *Reg, DynamicTypeInfo NewTy)
Set dynamic type information of the region; return the new state.
Dataflow Directional Tag Classes.
DynamicTypeInfo getDynamicTypeInfo(ProgramStateRef State, const MemRegion *Reg)
Get dynamic type information for a region.
void printDynamicTypeInfo(ProgramStateRef State, raw_ostream &Out, const char *NL, const char *Sep)