/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/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 | | #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEINFO_H |
9 | | #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEINFO_H |
10 | | |
11 | | #include "clang/AST/Type.h" |
12 | | |
13 | | namespace clang { |
14 | | namespace ento { |
15 | | |
16 | | /// Stores the currently inferred strictest bound on the runtime type |
17 | | /// of a region in a given state along the analysis path. |
18 | | class DynamicTypeInfo { |
19 | | private: |
20 | | QualType T; |
21 | | bool CanBeASubClass; |
22 | | |
23 | | public: |
24 | | |
25 | 1 | DynamicTypeInfo() : T(QualType()) {} |
26 | | DynamicTypeInfo(QualType WithType, bool CanBeSub = true) |
27 | 7.06k | : T(WithType), CanBeASubClass(CanBeSub) {} |
28 | | |
29 | | /// Return false if no dynamic type info is available. |
30 | 5.14k | bool isValid() const { return !T.isNull(); } |
31 | | |
32 | | /// Returns the currently inferred upper bound on the runtime type. |
33 | 6.09k | QualType getType() const { return T; } |
34 | | |
35 | | /// Returns false if the type information is precise (the type T is |
36 | | /// the only type in the lattice), true otherwise. |
37 | 2.77k | bool canBeASubClass() const { return CanBeASubClass; } |
38 | | |
39 | 5.18k | void Profile(llvm::FoldingSetNodeID &ID) const { |
40 | 5.18k | ID.Add(T); |
41 | 5.18k | ID.AddInteger((unsigned)CanBeASubClass); |
42 | 5.18k | } |
43 | 1.01k | bool operator==(const DynamicTypeInfo &X) const { |
44 | 1.01k | return T == X.T && CanBeASubClass == X.CanBeASubClass; |
45 | 1.01k | } |
46 | | }; |
47 | | |
48 | | } // end ento |
49 | | } // end clang |
50 | | |
51 | | #endif |