[cfe-commits] r162528 - in /cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive: DynamicTypeInfo.h ProgramState.h

Anna Zaks ganna at apple.com
Thu Aug 23 18:39:11 PDT 2012


Author: zaks
Date: Thu Aug 23 20:39:10 2012
New Revision: 162528

URL: http://llvm.org/viewvc/llvm-project?rev=162528&view=rev
Log:
[analyzer] Move DynamicTypeInfo out of the ProgramState.h

(I am not sure if we should move the setters and getters as well and
make them into static methods..)

Added:
    cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeInfo.h
Modified:
    cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h

Added: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeInfo.h?rev=162528&view=auto
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeInfo.h (added)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeInfo.h Thu Aug 23 20:39:10 2012
@@ -0,0 +1,54 @@
+//== 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_SA_CORE_DYNAMICTYPEINFO_H
+#define LLVM_CLANG_SA_CORE_DYNAMICTYPEINFO_H
+
+#include "clang/AST/Type.h"
+
+namespace clang {
+namespace ento {
+/// \class DynamicTypeInfo
+///
+/// \brief Stores the currently inferred strictest bound on the runtime type
+/// of a region in a given state along the analysis path.
+class DynamicTypeInfo {
+public:
+
+private:
+  QualType T;
+  bool CanBeASubClass;
+
+public:
+
+  DynamicTypeInfo() : T(QualType()) {}
+  DynamicTypeInfo(QualType WithType, bool CanBeSub = true)
+    : T(WithType), CanBeASubClass(CanBeSub) {}
+
+  /// \brief Return true 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 T is the only type in the lattice
+  /// (the type information is precise), true otherwise.
+  bool canBeASubClass() const { return CanBeASubClass; }
+
+  void Profile(llvm::FoldingSetNodeID &ID) const {
+    T.Profile(ID);
+    ID.AddInteger((unsigned)CanBeASubClass);
+  }
+  bool operator==(const DynamicTypeInfo &X) const {
+    return T == X.T && CanBeASubClass == X.CanBeASubClass;
+  }
+};
+
+}} // end clang::ento namespace
+
+#endif

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h?rev=162528&r1=162527&r2=162528&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h Thu Aug 23 20:39:10 2012
@@ -7,7 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 //
-//  This file defines SymbolRef, ExprBindKey, and ProgramState*.
+// This file defines the state of the program along the analyzes path.
 //
 //===----------------------------------------------------------------------===//
 
@@ -16,6 +16,7 @@
 
 #include "clang/Basic/LLVM.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeInfo.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/Environment.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/Store.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h"
@@ -56,38 +57,6 @@
   }
 };
 
-/// \class DynamicTypeInfo
-///
-/// \brief Stores the currently inferred strictest bound on the runtime type
-/// of a region in a given state along the analysis path.
-class DynamicTypeInfo {
-  QualType T;
-  bool CanBeASubClass;
-
-public:
-  DynamicTypeInfo() : T(QualType()) {}
-  DynamicTypeInfo(QualType WithType, bool CanBeSub = true)
-    : T(WithType), CanBeASubClass(CanBeSub) {}
-
-  /// \brief Return true 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 T is the only type in the lattice
-  /// (the type information is precise), true otherwise.
-  bool canBeASubClass() const { return CanBeASubClass; }
-  
-  void Profile(llvm::FoldingSetNodeID &ID) const {
-    T.Profile(ID);
-    ID.AddInteger((unsigned)CanBeASubClass);
-  }
-  bool operator==(const DynamicTypeInfo &X) const {
-    return T == X.T && CanBeASubClass == X.CanBeASubClass;
-  }
-};
-
 /// \class ProgramState
 /// ProgramState - This class encapsulates:
 ///
@@ -827,7 +796,7 @@
   bool scan(const SymExpr *sym);
 };
 
-} // end GR namespace
+} // end ento namespace
 
 } // end clang namespace
 





More information about the cfe-commits mailing list