[cfe-commits] r84281 - /cfe/trunk/lib/Sema/SemaOverload.cpp

Fariborz Jahanian fjahanian at apple.com
Fri Oct 16 15:08:06 PDT 2009


Author: fjahanian
Date: Fri Oct 16 17:08:05 2009
New Revision: 84281

URL: http://llvm.org/viewvc/llvm-project?rev=84281&view=rev
Log:
Use VisibleQuals to control setting of Volatile/Restrict qualifiers on
candidate types in BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants
further trimming the overload candidate set.


Modified:
    cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=84281&r1=84280&r2=84281&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Oct 16 17:08:05 2009
@@ -2873,7 +2873,8 @@
   /// Context - The AST context in which we will build the type sets.
   ASTContext &Context;
 
-  bool AddPointerWithMoreQualifiedTypeVariants(QualType Ty);
+  bool AddPointerWithMoreQualifiedTypeVariants(QualType Ty,
+                                               const Qualifiers &VisibleQuals);
   bool AddMemberPointerWithMoreQualifiedTypeVariants(QualType Ty);
 
 public:
@@ -2916,7 +2917,8 @@
 ///
 /// FIXME: what to do about extended qualifiers?
 bool
-BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(QualType Ty) {
+BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(QualType Ty
+                                            ,const Qualifiers &VisibleQuals) {
 
   // Insert this type.
   if (!PointerTypes.insert(Ty))
@@ -2927,11 +2929,16 @@
 
   QualType PointeeTy = PointerTy->getPointeeType();
   unsigned BaseCVR = PointeeTy.getCVRQualifiers();
-
+  bool hasVolatile = VisibleQuals.hasVolatile();
+  bool hasRestrict = VisibleQuals.hasRestrict();
+  
   // Iterate through all strict supersets of BaseCVR.
   for (unsigned CVR = BaseCVR+1; CVR <= Qualifiers::CVRMask; ++CVR) {
     if ((CVR | BaseCVR) != CVR) continue;
-    
+    // Skip over Volatile/Restrict if no Volatile/Restrict found anywhere
+    // in the types.
+    if ((CVR & Qualifiers::Volatile) && !hasVolatile) continue;
+    if ((CVR & Qualifiers::Restrict) && !hasRestrict) continue;
     QualType QPointeeTy = Context.getCVRQualifiedType(PointeeTy, CVR);
     PointerTypes.insert(Context.getPointerType(QPointeeTy));
   }
@@ -3003,7 +3010,7 @@
 
     // Insert our type, and its more-qualified variants, into the set
     // of types.
-    if (!AddPointerWithMoreQualifiedTypeVariants(Ty))
+    if (!AddPointerWithMoreQualifiedTypeVariants(Ty, VisibleQuals))
       return;
 
     // Add 'cv void*' to our set of types.
@@ -3011,7 +3018,8 @@
       QualType QualVoid
         = Context.getCVRQualifiedType(Context.VoidTy,
                                    PointeeTy.getCVRQualifiers());
-      AddPointerWithMoreQualifiedTypeVariants(Context.getPointerType(QualVoid));
+      AddPointerWithMoreQualifiedTypeVariants(Context.getPointerType(QualVoid),
+                                              VisibleQuals);
     }
 
     // If this is a pointer to a class type, add pointers to its bases
@@ -3105,7 +3113,7 @@
     else
       TyRec = ArgExpr->getType()->getAs<RecordType>();
     if (!TyRec) {
-      // Just to be safe, asssume the worst case.
+      // Just to be safe, assume the worst case.
       VRQuals.addVolatile();
       VRQuals.addRestrict();
       return VRQuals;





More information about the cfe-commits mailing list