diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2009-06-02 05:28:56 +0000 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2009-06-02 05:28:56 +0000 |
| commit | 091a9ac0140ffc410807b53db8531335a41636e5 (patch) | |
| tree | 06f4f9361c0692c359d6d3ebd15cdce70fba0d24 /clang/lib/AST | |
| parent | 179f2b9ec71a86ef78cd264e01470da434736f37 (diff) | |
| download | bcm5719-llvm-091a9ac0140ffc410807b53db8531335a41636e5.tar.gz bcm5719-llvm-091a9ac0140ffc410807b53db8531335a41636e5.zip | |
Cleaned-up version of gc attribute type merging. I still don't like it
very much, but I have a feeling we're never going to have an
implementation that makes sense because of compatibility issues.
llvm-svn: 72715
Diffstat (limited to 'clang/lib/AST')
| -rw-r--r-- | clang/lib/AST/ASTContext.cpp | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 28325edbd40..6a7113c685c 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -3028,18 +3028,33 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) { if (LHSClass == Type::FunctionProto) LHSClass = Type::FunctionNoProto; if (RHSClass == Type::FunctionProto) RHSClass = Type::FunctionNoProto; - QualType::GCAttrTypes RHSGCAttr = QualType::GCNone; - QualType::GCAttrTypes LHSGCAttr = QualType::GCNone; + // Strip off objc_gc attributes off the top level so they can be merged. + // This is a complete mess, but the attribute itself doesn't make much sense. if (RHSClass == Type::ExtQual) { - RHSGCAttr = RHSCan.getObjCGCAttr(); - if (RHSGCAttr != QualType::GCNone) - RHSClass = RHSCan.getUnqualifiedType()->getTypeClass(); + QualType::GCAttrTypes GCAttr = RHSCan.getObjCGCAttr(); + if (GCAttr != QualType::GCNone) { + RHS = QualType(cast<ExtQualType>(RHS.getDesugaredType())->getBaseType(), + RHS.getCVRQualifiers()); + QualType Result = mergeTypes(LHS, RHS); + if (Result.getObjCGCAttr() == QualType::GCNone) + Result = getObjCGCQualType(Result, GCAttr); + else if (Result.getObjCGCAttr() != GCAttr) + Result = QualType(); + return Result; + } } - if (LHSClass == Type::ExtQual) { - LHSGCAttr = LHSCan.getObjCGCAttr(); - if (LHSGCAttr != QualType::GCNone) - LHSClass = LHSCan.getUnqualifiedType()->getTypeClass(); + QualType::GCAttrTypes GCAttr = LHSCan.getObjCGCAttr(); + if (GCAttr != QualType::GCNone) { + LHS = QualType(cast<ExtQualType>(LHS.getDesugaredType())->getBaseType(), + LHS.getCVRQualifiers()); + QualType Result = mergeTypes(LHS, RHS); + if (Result.getObjCGCAttr() == QualType::GCNone) + Result = getObjCGCQualType(Result, GCAttr); + else if (Result.getObjCGCAttr() != GCAttr) + Result = QualType(); + getObjCGCQualType(Result, GCAttr); + } } // Same as above for arrays @@ -3139,16 +3154,10 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) { QualType RHSPointee = RHS->getAsPointerType()->getPointeeType(); QualType ResultType = mergeTypes(LHSPointee, RHSPointee); if (ResultType.isNull()) return QualType(); - if (getCanonicalType(LHSPointee) == getCanonicalType(ResultType)) { - if (RHSGCAttr != LHSGCAttr && RHSGCAttr != QualType::GCNone) - LHS = getObjCGCQualType(LHS, RHSGCAttr); + if (getCanonicalType(LHSPointee) == getCanonicalType(ResultType)) return LHS; - } - if (getCanonicalType(RHSPointee) == getCanonicalType(ResultType)) { - if (RHSGCAttr != LHSGCAttr && LHSGCAttr != QualType::GCNone) - RHS = getObjCGCQualType(RHS, LHSGCAttr); + if (getCanonicalType(RHSPointee) == getCanonicalType(ResultType)) return RHS; - } return getPointerType(ResultType); } case Type::BlockPointer: |

