From 9abc7a50ef3cbd89fca9bfc7e7eff60f8b44eb50 Mon Sep 17 00:00:00 2001 From: sagitario Date: Fri, 3 Dec 2010 22:38:02 +0000 Subject: now converting only class pointers to references, not pointers to structs or void --- CHANGES | 4 ++++ VERSION | 2 +- src/cv2pdb.cpp | 9 ++++++++- src/cv2pdb.h | 1 + src/cvutil.cpp | 12 ++++++++++++ src/cvutil.h | 1 + test/cvtest.d | 12 ++++++++++++ 7 files changed, 39 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 31a4372..ee130b9 100644 --- a/CHANGES +++ b/CHANGES @@ -133,3 +133,7 @@ Version history * fixed error with nested types longer than 255 characters * more fixes for names longer than 300 characters +2010-12-03 Version 0.19 + + * now converting only class pointers to references, not pointers to structs or void + diff --git a/VERSION b/VERSION index abadf6a..53d6fa9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -VERSION = 0.18 +VERSION = 0.19 diff --git a/src/cv2pdb.cpp b/src/cv2pdb.cpp index e61fd12..f4f674e 100644 --- a/src/cv2pdb.cpp +++ b/src/cv2pdb.cpp @@ -1863,6 +1863,13 @@ bool CV2PDB::isCppInterface(const codeview_type* cvtype) return off == 0; } +bool CV2PDB::isClassType(int type) +{ + if(const codeview_type* cvt = getTypeData(type)) + return isClass(cvt); + return false; +} + void CV2PDB::ensureUDT(int type, const codeview_type* cvtype) { if (getStructProperty(cvtype) & kPropIncomplete) @@ -2125,7 +2132,7 @@ bool CV2PDB::initGlobalTypes() case LF_POINTER_V1: dtype->pointer_v2.id = LF_POINTER_V2; dtype->pointer_v2.datatype = translateType(type->pointer_v1.datatype); - if (Dversion > 0 && type->pointer_v1.datatype >= 0x1000 + if (Dversion > 0 && isClassType(type->pointer_v1.datatype) && (type->pointer_v1.attribute & 0xE0) == 0) { if (thisIsNotRef) // const pointer for this diff --git a/src/cv2pdb.h b/src/cv2pdb.h index 0b93b38..cdfed36 100644 --- a/src/cv2pdb.h +++ b/src/cv2pdb.h @@ -79,6 +79,7 @@ public: int fixProperty(int type, int prop, int fieldType); bool derivesFromObject(const codeview_type* cvtype); bool isCppInterface(const codeview_type* cvtype); + bool isClassType(int type); int sizeofClassType(const codeview_type* cvtype); int sizeofBasicType(int type); diff --git a/src/cvutil.cpp b/src/cvutil.cpp index c125b41..64802f2 100644 --- a/src/cvutil.cpp +++ b/src/cvutil.cpp @@ -21,6 +21,18 @@ bool isStruct(const codeview_type* cvtype) return false; } +bool isClass(const codeview_type* cvtype) +{ + switch(cvtype->common.id) + { + case LF_CLASS_V1: + case LF_CLASS_V2: + case LF_CLASS_V3: + return true; + } + return false; +} + int getStructProperty(const codeview_type* cvtype) { switch(cvtype->common.id) diff --git a/src/cvutil.h b/src/cvutil.h index 83b0939..4b35c6a 100644 --- a/src/cvutil.h +++ b/src/cvutil.h @@ -39,6 +39,7 @@ static const int kPropIncomplete = 0x80; static const int kPropScoped = 0x100; bool isStruct(const codeview_type* cvtype); +bool isClass(const codeview_type* cvtype); int getStructProperty(const codeview_type* cvtype); int getStructFieldlist(const codeview_type* cvtype); bool isCompleteStruct(const codeview_type* type, const BYTE* name, bool cstr); diff --git a/test/cvtest.d b/test/cvtest.d index 5bdc819..283e972 100644 --- a/test/cvtest.d +++ b/test/cvtest.d @@ -207,6 +207,17 @@ A outer_func(int x) return new A; } +void voidpointers(ubyte* p) +{ + void* vp = cast(void*) p; + const(void)* const_vp = cast(const(void)*) p; + const(void*) const_vp2 = cast(const(void*)) p; + + int* ip = cast(int*) p; + const(int)* const_ip = cast(const(int)*) p; + const(int*) const_ip2 = cast(const(int*)) p; +} + int arrays() { int[] iarr; @@ -286,6 +297,7 @@ int main(char[][]argv) long lng = 3; ulong ulng = 4; + voidpointers(null); arrays(); outer_func(3); A.outer_func(3); -- cgit v0.12