[cfe-commits] r111798 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaObjCXX/pointer-to-objc-pointer-conv.mm
Argyrios Kyrtzidis
akyrtzi at gmail.com
Mon Aug 23 00:12:16 PDT 2010
Author: akirtzidis
Date: Mon Aug 23 02:12:16 2010
New Revision: 111798
URL: http://llvm.org/viewvc/llvm-project?rev=111798&view=rev
Log:
In Sema::AddBuiltinOperatorCandidates, candidate pointer types set can also contain a ObjCObjectPointerType since r111699.
Don't assume that they are only PointerTypes or we will crash.
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=111798&r1=111797&r2=111798&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Mon Aug 23 02:12:16 2010
@@ -4599,7 +4599,7 @@
for (BuiltinCandidateTypeSet::iterator Ptr = CandidateTypes.pointer_begin();
Ptr != CandidateTypes.pointer_end(); ++Ptr) {
QualType ParamTy = *Ptr;
- QualType PointeeTy = ParamTy->getAs<PointerType>()->getPointeeType();
+ QualType PointeeTy = ParamTy->getPointeeType();
AddBuiltinCandidate(Context.getLValueReferenceType(PointeeTy),
&ParamTy, Args, 1, CandidateSet);
}
@@ -5080,7 +5080,7 @@
for (BuiltinCandidateTypeSet::iterator Ptr = CandidateTypes.pointer_begin();
Ptr != CandidateTypes.pointer_end(); ++Ptr) {
QualType ParamTypes[2] = { *Ptr, Context.getPointerDiffType() };
- QualType PointeeType = (*Ptr)->getAs<PointerType>()->getPointeeType();
+ QualType PointeeType = (*Ptr)->getPointeeType();
QualType ResultTy = Context.getLValueReferenceType(PointeeType);
// T& operator[](T*, ptrdiff_t)
@@ -5108,18 +5108,16 @@
QualType C1Ty = (*Ptr);
QualType C1;
QualifierCollector Q1;
- if (const PointerType *PointerTy = C1Ty->getAs<PointerType>()) {
- C1 = QualType(Q1.strip(PointerTy->getPointeeType()), 0);
- if (!isa<RecordType>(C1))
- continue;
- // heuristic to reduce number of builtin candidates in the set.
- // Add volatile/restrict version only if there are conversions to a
- // volatile/restrict type.
- if (!VisibleTypeConversionsQuals.hasVolatile() && Q1.hasVolatile())
- continue;
- if (!VisibleTypeConversionsQuals.hasRestrict() && Q1.hasRestrict())
- continue;
- }
+ C1 = QualType(Q1.strip(C1Ty->getPointeeType()), 0);
+ if (!isa<RecordType>(C1))
+ continue;
+ // heuristic to reduce number of builtin candidates in the set.
+ // Add volatile/restrict version only if there are conversions to a
+ // volatile/restrict type.
+ if (!VisibleTypeConversionsQuals.hasVolatile() && Q1.hasVolatile())
+ continue;
+ if (!VisibleTypeConversionsQuals.hasRestrict() && Q1.hasRestrict())
+ continue;
for (BuiltinCandidateTypeSet::iterator
MemPtr = CandidateTypes.member_pointer_begin(),
MemPtrEnd = CandidateTypes.member_pointer_end();
Modified: cfe/trunk/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm?rev=111798&r1=111797&r2=111798&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm (original)
+++ cfe/trunk/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm Mon Aug 23 02:12:16 2010
@@ -33,7 +33,17 @@
bool CompareClass(Class obj) { return *this == obj; }
bool CompareI1(I1* obj) { return *this == obj; }
+ Wrapper &operator*();
+ Wrapper &operator[](int);
+ Wrapper& operator->*(int);
+
private:
long _value;
};
+void f() {
+ Wrapper w;
+ w[0];
+ *w;
+ w->*(0);
+}
More information about the cfe-commits
mailing list