Coverage Report

Created: 2022-07-16 07:03

/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
370
      : From(from), To(to), ResultKind(resultKind) {}
23
24
14
  QualType from() const { return From; }
25
50
  QualType to() const { return To; }
26
27
976
  bool equals(QualType from, QualType to) const {
28
976
    return From == from && To == to;
29
976
  }
30
31
410
  bool succeeds() const { return ResultKind == CastResult::Success; }
32
18
  bool fails() const { return ResultKind == CastResult::Failure; }
33
34
306
  bool operator==(const DynamicCastInfo &RHS) const {
35
306
    return From == RHS.From && To == RHS.To;
36
306
  }
37
292
  bool operator<(const DynamicCastInfo &RHS) const {
38
292
    return From < RHS.From && 
To < RHS.To0
;
39
292
  }
40
41
662
  void Profile(llvm::FoldingSetNodeID &ID) const {
42
662
    ID.Add(From);
43
662
    ID.Add(To);
44
662
    ID.AddInteger(ResultKind);
45
662
  }
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