Coverage Report

Created: 2020-02-18 08:44

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicCastInfo.h
Line
Count
Source (jump to first uncovered line)
1
//===- DynamicCastInfo.h - Runtime cast 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_DYNAMICCASTINFO_H
10
#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICCASTINFO_H
11
12
#include "clang/AST/Type.h"
13
14
namespace clang {
15
namespace ento {
16
17
class DynamicCastInfo {
18
public:
19
  enum CastResult { Success, Failure };
20
21
  DynamicCastInfo(QualType from, QualType to, CastResult resultKind)
22
54
      : From(from), To(to), ResultKind(resultKind) {}
23
24
4
  QualType from() const { return From; }
25
7
  QualType to() const { return To; }
26
27
34
  bool equals(QualType from, QualType to) const {
28
34
    return From == from && 
To == to18
;
29
34
  }
30
31
10
  bool succeeds() const { return ResultKind == CastResult::Success; }
32
3
  bool fails() const { return ResultKind == CastResult::Failure; }
33
34
28
  bool operator==(const DynamicCastInfo &RHS) const {
35
28
    return From == RHS.From && 
To == RHS.To16
;
36
28
  }
37
24
  bool operator<(const DynamicCastInfo &RHS) const {
38
24
    return From < RHS.From && 
To < RHS.To0
;
39
24
  }
40
41
78
  void Profile(llvm::FoldingSetNodeID &ID) const {
42
78
    ID.Add(From);
43
78
    ID.Add(To);
44
78
    ID.AddInteger(ResultKind);
45
78
  }
46
47
private:
48
  QualType From, To;
49
  CastResult ResultKind;
50
};
51
52
} // namespace ento
53
} // namespace clang
54
55
#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICCASTINFO_H