clang 10.0.0git

DynamicCastInfo.h
Go to the documentation of this file.
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 : From(from), To(to), ResultKind(resultKind) {}
23
24 QualType from() const { return From; }
25 QualType to() const { return To; }
26
27 bool equals(QualType from, QualType to) const {
28 return From == from && To == to;
29 }
30
31 bool succeeds() const { return ResultKind == CastResult::Success; }
32 bool fails() const { return ResultKind == CastResult::Failure; }
33
34 bool operator==(const DynamicCastInfo &RHS) const {
35 return From == RHS.From && To == RHS.To;
36 }
37 bool operator<(const DynamicCastInfo &RHS) const {
38 return From < RHS.From && To < RHS.To;
39 }
40
41 void Profile(llvm::FoldingSetNodeID &ID) const {
42 ID.Add(From);
43 ID.Add(To);
44 ID.AddInteger(ResultKind);
45 }
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
clang::Builtin::ID
ID
Definition: Builtins.h:46
ento
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:654
Type.h
C Language Family Type Representation.
clang::ento::DynamicCastInfo
Definition: DynamicCastInfo.h:17
clang::ento::DynamicCastInfo::succeeds
bool succeeds() const
Definition: DynamicCastInfo.h:31
clang::ento::DynamicCastInfo::to
QualType to() const
Definition: DynamicCastInfo.h:25
clang::ento::DynamicCastInfo::fails
bool fails() const
Definition: DynamicCastInfo.h:32
clang::ento::DynamicCastInfo::Success
Definition: DynamicCastInfo.h:19
clang::ento::DynamicCastInfo::operator==
bool operator==(const DynamicCastInfo &RHS) const
Definition: DynamicCastInfo.h:34
clang::ento::DynamicCastInfo::equals
bool equals(QualType from, QualType to) const
Definition: DynamicCastInfo.h:27
clang::ento::DynamicCastInfo::DynamicCastInfo
DynamicCastInfo(QualType from, QualType to, CastResult resultKind)
Definition: DynamicCastInfo.h:21
clang::ento::DynamicCastInfo::Failure
Definition: DynamicCastInfo.h:19
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:21
clang::ento::DynamicCastInfo::CastResult
CastResult
Definition: DynamicCastInfo.h:19
clang::ento::DynamicCastInfo::operator<
bool operator<(const DynamicCastInfo &RHS) const
Definition: DynamicCastInfo.h:37
clang::ento::DynamicCastInfo::Profile
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: DynamicCastInfo.h:41
clang::ento::DynamicCastInfo::from
QualType from() const
Definition: DynamicCastInfo.h:24