clang API Documentation

DynamicTypeInfo.h
Go to the documentation of this file.
00001 //== DynamicTypeInfo.h - Runtime type information ----------------*- C++ -*--=//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEINFO_H
00010 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEINFO_H
00011 
00012 #include "clang/AST/Type.h"
00013 
00014 namespace clang {
00015 namespace ento {
00016 
00017 /// \brief Stores the currently inferred strictest bound on the runtime type
00018 /// of a region in a given state along the analysis path.
00019 class DynamicTypeInfo {
00020 private:
00021   QualType T;
00022   bool CanBeASubClass;
00023 
00024 public:
00025 
00026   DynamicTypeInfo() : T(QualType()) {}
00027   DynamicTypeInfo(QualType WithType, bool CanBeSub = true)
00028     : T(WithType), CanBeASubClass(CanBeSub) {}
00029 
00030   /// \brief Return false if no dynamic type info is available.
00031   bool isValid() const { return !T.isNull(); }
00032 
00033   /// \brief Returns the currently inferred upper bound on the runtime type.
00034   QualType getType() const { return T; }
00035 
00036   /// \brief Returns false if the type information is precise (the type T is
00037   /// the only type in the lattice), true otherwise.
00038   bool canBeASubClass() const { return CanBeASubClass; }
00039 
00040   void Profile(llvm::FoldingSetNodeID &ID) const {
00041     ID.Add(T);
00042     ID.AddInteger((unsigned)CanBeASubClass);
00043   }
00044   bool operator==(const DynamicTypeInfo &X) const {
00045     return T == X.T && CanBeASubClass == X.CanBeASubClass;
00046   }
00047 };
00048 
00049 } // end ento
00050 } // end clang
00051 
00052 #endif