Implement semantic checking of static_cast and dynamic_cast.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58509 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaInherit.h b/lib/Sema/SemaInherit.h
index 801ed74..eccd31f 100644
--- a/lib/Sema/SemaInherit.h
+++ b/lib/Sema/SemaInherit.h
@@ -25,6 +25,7 @@
 namespace clang {
   class Sema;
   class CXXBaseSpecifier;
+  class CXXRecordType;
 
   /// BasePathElement - An element in a path from a derived class to a
   /// base class. Each step in the path references the link from a
@@ -97,20 +98,28 @@
     std::map<QualType, std::pair<bool, unsigned>, QualTypeOrdering> 
       ClassSubobjects;
 
-    /// FindAmbiguities - Whether Sema::IsDirectedFrom should try find
+    /// FindAmbiguities - Whether Sema::IsDerivedFrom should try find
     /// ambiguous paths while it is looking for a path from a derived
     /// type to a base type.
     bool FindAmbiguities;
 
-    /// RecordPaths - Whether Sema::IsDirectedFrom should record paths
+    /// RecordPaths - Whether Sema::IsDerivedFrom should record paths
     /// while it is determining whether there are paths from a derived
     /// type to a base type.
     bool RecordPaths;
 
+    /// DetectVirtual - Whether Sema::IsDerivedFrom should abort the search
+    /// if it finds a path that goes across a virtual base. The virtual class
+    /// is also recorded.
+    bool DetectVirtual;
+
     /// ScratchPath - A BasePath that is used by Sema::IsDerivedFrom
     /// to help build the set of paths.
     BasePath ScratchPath;
 
+    /// DetectedVirtual - The base class that is virtual.
+    const CXXRecordType *DetectedVirtual;
+
     friend class Sema;
 
   public:
@@ -118,8 +127,12 @@
     
     /// BasePaths - Construct a new BasePaths structure to record the
     /// paths for a derived-to-base search.
-    explicit BasePaths(bool FindAmbiguities = true, bool RecordPaths = true) 
-      : FindAmbiguities(FindAmbiguities), RecordPaths(RecordPaths) { }
+    explicit BasePaths(bool FindAmbiguities = true,
+                       bool RecordPaths = true,
+                       bool DetectVirtual = true)
+      : FindAmbiguities(FindAmbiguities), RecordPaths(RecordPaths),
+        DetectVirtual(DetectVirtual), DetectedVirtual(0)
+    {}
 
     paths_iterator begin() const { return Paths.begin(); }
     paths_iterator end()   const { return Paths.end(); }
@@ -137,6 +150,14 @@
     /// paths or not.
     void setRecordingPaths(bool RP) { RecordPaths = RP; }
 
+    /// isDetectingVirtual - Whether we are detecting virtual bases.
+    bool isDetectingVirtual() const { return DetectVirtual; }
+
+    /// getDetectedVirtual - The virtual base discovered on the path.
+    const CXXRecordType* getDetectedVirtual() const {
+      return DetectedVirtual;
+    }
+
     void clear();
   };
 }