Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h
Line
Count
Source
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
16
#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeInfo.h"
17
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
18
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h"
19
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
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 <>
35
struct ProgramStateTrait<DynamicTypeMap>
36
    : public ProgramStatePartialTrait<DynamicTypeMapTy> {
37
  static void *GDMIndex();
38
};
39
40
/// Get dynamic type information for a region.
41
DynamicTypeInfo getDynamicTypeInfo(ProgramStateRef State,
42
                                   const MemRegion *Reg);
43
44
/// Set dynamic type information of the region; return the new state.
45
ProgramStateRef setDynamicTypeInfo(ProgramStateRef State, const MemRegion *Reg,
46
                                   DynamicTypeInfo NewTy);
47
48
/// Set dynamic type information of the region; return the new state.
49
inline ProgramStateRef setDynamicTypeInfo(ProgramStateRef State,
50
                                          const MemRegion *Reg, QualType NewTy,
51
3.16k
                                          bool CanBeSubClassed = true) {
52
3.16k
  return setDynamicTypeInfo(State, Reg,
53
3.16k
                            DynamicTypeInfo(NewTy, CanBeSubClassed));
54
3.16k
}
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