1 //===- DynamicTypeInfo.h - Runtime type information -------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
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 {
21 DynamicTypeInfo() : DynTy(QualType()) {}
23 DynamicTypeInfo(QualType Ty, bool CanBeSub = true)
24 : DynTy(Ty), CanBeASubClass(CanBeSub) {}
26 /// Returns false if the type information is precise (the type 'DynTy' is
27 /// the only type in the lattice), true otherwise.
28 bool canBeASubClass() const { return CanBeASubClass; }
30 /// Returns true if the dynamic type info is available.
31 bool isValid() const { return !DynTy.isNull(); }
33 /// Returns the currently inferred upper bound on the runtime type.
34 QualType getType() const { return DynTy; }
36 bool operator==(const DynamicTypeInfo &RHS) const {
37 return DynTy == RHS.DynTy && CanBeASubClass == RHS.CanBeASubClass;
40 void Profile(llvm::FoldingSetNodeID &ID) const {
42 ID.AddBoolean(CanBeASubClass);
53 #endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEINFO_H