blob: accbe7d3eace13ff619a4b3e8aea40970dddaa8c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
//== DynamicTypeInfo.h - Runtime type information ----------------*- C++ -*--=//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEINFO_H
#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEINFO_H
#include "clang/AST/Type.h"
namespace clang {
namespace ento {
/// \brief Stores the currently inferred strictest bound on the runtime type
/// of a region in a given state along the analysis path.
class DynamicTypeInfo {
private:
QualType T;
bool CanBeASubClass;
public:
DynamicTypeInfo() : T(QualType()) {}
DynamicTypeInfo(QualType WithType, bool CanBeSub = true)
: T(WithType), CanBeASubClass(CanBeSub) {}
/// \brief Return false if no dynamic type info is available.
bool isValid() const { return !T.isNull(); }
/// \brief Returns the currently inferred upper bound on the runtime type.
QualType getType() const { return T; }
/// \brief Returns false if the type information is precise (the type T is
/// the only type in the lattice), true otherwise.
bool canBeASubClass() const { return CanBeASubClass; }
void Profile(llvm::FoldingSetNodeID &ID) const {
ID.Add(T);
ID.AddInteger((unsigned)CanBeASubClass);
}
bool operator==(const DynamicTypeInfo &X) const {
return T == X.T && CanBeASubClass == X.CanBeASubClass;
}
};
} // namespace ento
} // namespace clang
#endif
|