summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2022-07-25 11:17:11 +0200
committerEmilio Cobos Álvarez <emilio@crisal.io>2022-07-25 12:06:38 +0200
commitef2ee38f3a1a2e0d169a610b9bd7bf52ea966059 (patch)
tree864636deeaa0f7b2c706e98bcb6144bb6ffe7646 /src
parent105b9422cd5f8cd7aca9def458c157be219a03ff (diff)
ty: Use canonical type to access pointee.
Using the canonical type fixes this but changes the output of some tests (in particular, pointer to typedefs now point to the underlying type). So do this only in known-bad cases. Fixes #2244
Diffstat (limited to 'src')
-rw-r--r--src/ir/ty.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/ir/ty.rs b/src/ir/ty.rs
index d573408c..38ab4564 100644
--- a/src/ir/ty.rs
+++ b/src/ir/ty.rs
@@ -1031,7 +1031,16 @@ impl Type {
CXType_ObjCObjectPointer |
CXType_MemberPointer |
CXType_Pointer => {
- let pointee = ty.pointee_type().unwrap();
+ let mut pointee = ty.pointee_type().unwrap();
+ if *ty != canonical_ty {
+ let canonical_pointee =
+ canonical_ty.pointee_type().unwrap();
+ // clang sometimes loses pointee constness here, see
+ // #2244.
+ if canonical_pointee.is_const() != pointee.is_const() {
+ pointee = canonical_pointee;
+ }
+ }
let inner =
Item::from_ty_or_ref(pointee, location, None, ctx);
TypeKind::Pointer(inner)