summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2012-09-12 23:13:31 +0000
committerRichard Trieu <rtrieu@google.com>2012-09-12 23:13:31 +0000
commita9fe99a1743a49e636d65b70d68d062ab6edef3b (patch)
treec5f9aa9b3a054eb963791c6ca704c7502f71af23
parent24f3a14026058b38a5f4ca2b9f04ea9ac3afa9e8 (diff)
downloadbcm5719-llvm-a9fe99a1743a49e636d65b70d68d062ab6edef3b.tar.gz
bcm5719-llvm-a9fe99a1743a49e636d65b70d68d062ab6edef3b.zip
Add two new functions to Qualifiers.
static Qualifiers removeCommonQualifiers(Qualifiers &L, Qualifiers &R) Removes the common qualifiers from L and R and returns them in a new Qualifier. This will be used in template diffing. void removeQualifiers(Qualifiers Q) Removes the qualifiers in Q from the current qualifier. This replaces the current underlying implementation of operator- and operator -= which only performed bit masking. llvm-svn: 163752
-rw-r--r--clang/include/clang/AST/Type.h57
1 files changed, 56 insertions, 1 deletions
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 86300119293..2d99a8c2ef7 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -160,6 +160,44 @@ public:
Qualifiers() : Mask(0) {}
+ /// \brief Returns the common set of qualifiers while removing them from
+ /// the given sets.
+ static Qualifiers removeCommonQualifiers(Qualifiers &L, Qualifiers &R) {
+ // If both are only CVR-qualified, bit operations are sufficient.
+ if (!(L.Mask & ~CVRMask) && !(R.Mask & ~CVRMask)) {
+ Qualifiers Q;
+ Q.Mask = L.Mask & R.Mask;
+ L.Mask &= ~Q.Mask;
+ R.Mask &= ~Q.Mask;
+ return Q;
+ }
+
+ Qualifiers Q;
+ unsigned CommonCRV = L.getCVRQualifiers() & R.getCVRQualifiers();
+ Q.addCVRQualifiers(CommonCRV);
+ L.removeCVRQualifiers(CommonCRV);
+ R.removeCVRQualifiers(CommonCRV);
+
+ if (L.getObjCGCAttr() == R.getObjCGCAttr()) {
+ Q.setObjCGCAttr(L.getObjCGCAttr());
+ L.removeObjCGCAttr();
+ R.removeObjCGCAttr();
+ }
+
+ if (L.getObjCLifetime() == R.getObjCLifetime()) {
+ Q.setObjCLifetime(L.getObjCLifetime());
+ L.removeObjCLifetime();
+ R.removeObjCLifetime();
+ }
+
+ if (L.getAddressSpace() == R.getAddressSpace()) {
+ Q.setAddressSpace(L.getAddressSpace());
+ L.removeAddressSpace();
+ R.removeAddressSpace();
+ }
+ return Q;
+ }
+
static Qualifiers fromFastMask(unsigned Mask) {
Qualifiers Qs;
Qs.addFastQualifiers(Mask);
@@ -333,6 +371,23 @@ public:
}
}
+ /// \brief Remove the qualifiers from the given set from this set.
+ void removeQualifiers(Qualifiers Q) {
+ // If the other set doesn't have any non-boolean qualifiers, just
+ // bit-and the inverse in.
+ if (!(Q.Mask & ~CVRMask))
+ Mask &= ~Q.Mask;
+ else {
+ Mask &= ~(Q.Mask & CVRMask);
+ if (getObjCGCAttr() == Q.getObjCGCAttr())
+ removeObjCGCAttr();
+ if (getObjCLifetime() == Q.getObjCLifetime())
+ removeObjCLifetime();
+ if (getAddressSpace() == Q.getAddressSpace())
+ removeAddressSpace();
+ }
+ }
+
/// \brief Add the qualifiers from the given set to this set, given that
/// they don't conflict.
void addConsistentQualifiers(Qualifiers qs) {
@@ -400,7 +455,7 @@ public:
}
Qualifiers &operator-=(Qualifiers R) {
- Mask = Mask & ~(R.Mask);
+ removeQualifiers(R);
return *this;
}
OpenPOWER on IntegriCloud