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 DynamicTypeMapTy = llvm::ImmutableMap<const MemRegion *, DynamicTypeInfo>;
33 
34 template <>
36  : public ProgramStatePartialTrait<DynamicTypeMapTy> {
37  static void *GDMIndex();
38 };
39 
40 /// Get dynamic type information for a region.
42  const MemRegion *Reg);
43 
44 /// Set dynamic type information of the region; return the new state.
46  DynamicTypeInfo NewTy);
47 
48 /// Set dynamic type information of the region; return the new state.
50  const MemRegion *Reg, QualType NewTy,
51  bool CanBeSubClassed = true) {
52  return setDynamicTypeInfo(State, Reg,
53  DynamicTypeInfo(NewTy, CanBeSubClassed));
54 }
55 
56 void printDynamicTypeInfoJson(raw_ostream &Out, ProgramStateRef State,
57  const char *NL = "\n", unsigned int Space = 0,
58  bool IsDot = false);
59 
60 } // namespace ento
61 } // namespace clang
62 
63 #endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEMAP_H
A (possibly-)qualified type.
Definition: Type.h:643
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
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.
llvm::ImmutableMap< const MemRegion *, DynamicTypeInfo > DynamicTypeMapTy
DynamicTypeInfo getDynamicTypeInfo(ProgramStateRef State, const MemRegion *Reg)
Get dynamic type information for a region.
void printDynamicTypeInfoJson(raw_ostream &Out, ProgramStateRef State, const char *NL="\, unsigned int Space=0, bool IsDot=false)