Coverage Report

Created: 2020-02-25 14:32

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeInfo.h
Line
Count
Source
1
//===- DynamicTypeInfo.h - Runtime type information -------------*- 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
#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEINFO_H
10
#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEINFO_H
11
12
#include "clang/AST/Type.h"
13
14
namespace clang {
15
namespace ento {
16
17
/// Stores the currently inferred strictest bound on the runtime type
18
/// of a region in a given state along the analysis path.
19
class DynamicTypeInfo {
20
public:
21
1
  DynamicTypeInfo() : DynTy(QualType()) {}
22
23
  DynamicTypeInfo(QualType Ty, bool CanBeSub = true)
24
13.2k
      : DynTy(Ty), CanBeASubClass(CanBeSub) {}
25
26
  /// Returns false if the type information is precise (the type 'DynTy' is
27
  /// the only type in the lattice), true otherwise.
28
3.07k
  bool canBeASubClass() const { return CanBeASubClass; }
29
30
  /// Returns true if the dynamic type info is available.
31
5.54k
  bool isValid() const { return !DynTy.isNull(); }
32
33
  /// Returns the currently inferred upper bound on the runtime type.
34
6.49k
  QualType getType() const { return DynTy; }
35
36
31.7k
  bool operator==(const DynamicTypeInfo &RHS) const {
37
31.7k
    return DynTy == RHS.DynTy && CanBeASubClass == RHS.CanBeASubClass;
38
31.7k
  }
39
40
33.9k
  void Profile(llvm::FoldingSetNodeID &ID) const {
41
33.9k
    ID.Add(DynTy);
42
33.9k
    ID.AddBoolean(CanBeASubClass);
43
33.9k
  }
44
45
private:
46
  QualType DynTy;
47
  bool CanBeASubClass;
48
};
49
50
} // namespace ento
51
} // namespace clang
52
53
#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEINFO_H