[cfe-commits] r104374 - in /cfe/trunk: include/clang/AST/CXXInheritance.h lib/AST/CXXInheritance.cpp lib/Sema/SemaCXXCast.cpp lib/Sema/SemaExceptionSpec.cpp test/SemaCXX/member-pointer.cpp

Douglas Gregor dgregor at apple.com
Fri May 21 13:29:55 PDT 2010


Author: dgregor
Date: Fri May 21 15:29:55 2010
New Revision: 104374

URL: http://llvm.org/viewvc/llvm-project?rev=104374&view=rev
Log:
Use CanQualType to enforce the use of a canonical type argument to
CXXBasePaths::isAmbiguous(), rather than just asserting that we have a
canonical type. Fixes PR7176.

Modified:
    cfe/trunk/include/clang/AST/CXXInheritance.h
    cfe/trunk/lib/AST/CXXInheritance.cpp
    cfe/trunk/lib/Sema/SemaCXXCast.cpp
    cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
    cfe/trunk/test/SemaCXX/member-pointer.cpp

Modified: cfe/trunk/include/clang/AST/CXXInheritance.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CXXInheritance.h?rev=104374&r1=104373&r2=104374&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/CXXInheritance.h (original)
+++ cfe/trunk/include/clang/AST/CXXInheritance.h Fri May 21 15:29:55 2010
@@ -196,7 +196,7 @@
   /// \brief Determine whether the path from the most-derived type to the
   /// given base type is ambiguous (i.e., it refers to multiple subobjects of
   /// the same base type).
-  bool isAmbiguous(QualType BaseType);
+  bool isAmbiguous(CanQualType BaseType);
   
   /// \brief Whether we are finding multiple paths to detect ambiguities.
   bool isFindingAmbiguities() const { return FindAmbiguities; }

Modified: cfe/trunk/lib/AST/CXXInheritance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CXXInheritance.cpp?rev=104374&r1=104373&r2=104374&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CXXInheritance.cpp (original)
+++ cfe/trunk/lib/AST/CXXInheritance.cpp Fri May 21 15:29:55 2010
@@ -49,9 +49,8 @@
 /// ambiguous, i.e., there are two or more paths that refer to
 /// different base class subobjects of the same type. BaseType must be
 /// an unqualified, canonical class type.
-bool CXXBasePaths::isAmbiguous(QualType BaseType) {
-  assert(BaseType.isCanonical() && "Base type must be the canonical type");
-  assert(BaseType.hasQualifiers() == 0 && "Base type must be unqualified");
+bool CXXBasePaths::isAmbiguous(CanQualType BaseType) {
+  BaseType = BaseType.getUnqualifiedType();
   std::pair<bool, unsigned>& Subobjects = ClassSubobjects[BaseType];
   return Subobjects.second + (Subobjects.first? 1 : 0) > 1;
 }

Modified: cfe/trunk/lib/Sema/SemaCXXCast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCXXCast.cpp?rev=104374&r1=104373&r2=104374&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCXXCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCXXCast.cpp Fri May 21 15:29:55 2010
@@ -859,7 +859,7 @@
   }
 
   // B is a base of D. But is it an allowed base? If not, it's a hard error.
-  if (Paths.isAmbiguous(DestClass)) {
+  if (Paths.isAmbiguous(Self.Context.getCanonicalType(DestClass))) {
     Paths.clear();
     Paths.setRecordingPaths(true);
     bool StillOkay = Self.IsDerivedFrom(SrcClass, DestClass, Paths);

Modified: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExceptionSpec.cpp?rev=104374&r1=104373&r2=104374&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExceptionSpec.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExceptionSpec.cpp Fri May 21 15:29:55 2010
@@ -389,7 +389,7 @@
       if (!IsDerivedFrom(CanonicalSubT, CanonicalSuperT, Paths))
         continue;
 
-      if (Paths.isAmbiguous(CanonicalSuperT))
+      if (Paths.isAmbiguous(Context.getCanonicalType(CanonicalSuperT)))
         continue;
 
       // Do this check from a context without privileges.

Modified: cfe/trunk/test/SemaCXX/member-pointer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/member-pointer.cpp?rev=104374&r1=104373&r2=104374&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/member-pointer.cpp (original)
+++ cfe/trunk/test/SemaCXX/member-pointer.cpp Fri May 21 15:29:55 2010
@@ -157,3 +157,20 @@
     return object->*p2m; // expected-error {{left hand operand to ->*}}
   }
 }
+
+namespace PR7176 {
+  namespace base
+  {
+    struct Process
+    { };
+    struct Continuous : Process
+    {
+      bool cond();
+    };
+  }
+
+  typedef bool( base::Process::*Condition )();
+
+  void m()
+  { (void)(Condition) &base::Continuous::cond; }
+}





More information about the cfe-commits mailing list