1 //== DynamicTypeInfo.h - Runtime type information ----------------*- C++ -*--=//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEINFO_H
10 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEINFO_H
12 #include "clang/AST/Type.h"
17 /// Stores the currently inferred strictest bound on the runtime type
18 /// of a region in a given state along the analysis path.
19 class DynamicTypeInfo {
26 DynamicTypeInfo() : T(QualType()) {}
27 DynamicTypeInfo(QualType WithType, bool CanBeSub = true)
28 : T(WithType), CanBeASubClass(CanBeSub) {}
30 /// Return false if no dynamic type info is available.
31 bool isValid() const { return !T.isNull(); }
33 /// Returns the currently inferred upper bound on the runtime type.
34 QualType getType() const { return T; }
36 /// Returns false if the type information is precise (the type T is
37 /// the only type in the lattice), true otherwise.
38 bool canBeASubClass() const { return CanBeASubClass; }
40 void Profile(llvm::FoldingSetNodeID &ID) const {
42 ID.AddInteger((unsigned)CanBeASubClass);
44 bool operator==(const DynamicTypeInfo &X) const {
45 return T == X.T && CanBeASubClass == X.CanBeASubClass;