================
@@ -8274,6 +8275,15 @@ inline void QualType::removeLocalVolatile() {
removeLocalFastQualifiers(Qualifiers::Volatile);
}
+inline QualType QualType::removeNonAddressSpaceQualifiers() {
+ if (getQualifiers().hasTargetSpecificAddressSpace()) {
+ removeLocalFastQualifiers();
+ } else {
+ return getCanonicalType().getUnqualifiedType();
+ }
+ return *this;
+}
----------------
steakhal wrote:
I'm not sure how broadly this function is useful for anyone else.
If only the static analyzer uses this, then probably we should just have this
as a static helper there instead.
```suggestion
inline QualType QualType::removeNonAddressSpaceQualifiers() {
if (getQualifiers().hasTargetSpecificAddressSpace()) {
removeLocalFastQualifiers();
return *this;
}
return getCanonicalType().getUnqualifiedType();
}
```
BTW I'm not really familiar with the QualType methods, but I was not expecting
mutations if we anyway return a value. What I'd expect when calling this
function that this would not mutate (and have side effect) the object itself
but just return the right value instead.
This semantic is usually achieved by taking a copy of self, apply the mutation
on the copy and return the mutated copy.
Alternatively, you could decide to have a `void` return type to solve this
inconsistency, and clearly admit that calling this has side effects.
https://github.com/llvm/llvm-project/pull/151249
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits