From 79e4dc6056a5e1c7c2e9632219282746d0bc2058 Mon Sep 17 00:00:00 2001 From: user1 Date: Fri, 31 Mar 2017 08:59:27 -0700 Subject: added checks for getAsPlaceholderType() returning null --- mutator-lvl0.cpp | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/mutator-lvl0.cpp b/mutator-lvl0.cpp index 606dc6e..7e388d4 100644 --- a/mutator-lvl0.cpp +++ b/mutator-lvl0.cpp @@ -4125,6 +4125,7 @@ public: uint64_t ICETypeSize = ASTC->getTypeSize(CanonTypeDaddy); uint64_t ChildTypeSize = ASTC->getTypeSize(CanonTypeChild); + /* bool ICETypeIsSignedInt = CanonTypeDaddy->getAsPlaceholderType()->isSignedInteger(); bool ChildTypeIsSignedInt = CanonTypeChild->getAsPlaceholderType()->isSignedInteger(); @@ -4132,6 +4133,33 @@ public: bool ChildTypeIsUSignedInt = CanonTypeChild->getAsPlaceholderType()->isUnsignedInteger(); if (CanonTypeDaddy->getAsPlaceholderType()->isInteger() && CanonTypeChild->getAsPlaceholderType()->isInteger()) + */ + + bool ICETypeIsSignedInt = false; + bool ICETypeIsUSignedInt = false; + bool ICETypeIsInteger = false; + if (CanonTypeDaddy) { + auto placeholderType = CanonTypeDaddy->getAsPlaceholderType(); + if (placeholderType) { + ICETypeIsSignedInt = placeholderType->isSignedInteger(); + ICETypeIsUSignedInt = placeholderType->isUnsignedInteger(); + ICETypeIsInteger = placeholderType->isInteger(); + } + } + + bool ChildTypeIsSignedInt = false; + bool ChildTypeIsUSignedInt = false; + bool ChildTypeIsInteger = false; + if (CanonTypeChild) { + auto placeholderType = CanonTypeChild->getAsPlaceholderType(); + if (placeholderType) { + ChildTypeIsSignedInt = placeholderType->isSignedInteger(); + ChildTypeIsUSignedInt = placeholderType->isUnsignedInteger(); + ChildTypeIsInteger = placeholderType->isInteger(); + } + } + + if (ICETypeIsInteger && ChildTypeIsInteger) { if ((ICETypeIsSignedInt && ChildTypeIsUSignedInt) || (ICETypeIsUSignedInt && ChildTypeIsSignedInt)) { @@ -4202,10 +4230,32 @@ public: const clang::Type* DaddyCPXElementType = DaddyCPXQT.getTypePtr(); const clang::Type * ChildCPXElementType = ChildCPXQT.getTypePtr(); + /* bool IsSignedCPXDaddy = DaddyCPXElementType->getAsPlaceholderType()->isSignedInteger(); bool IsSignedCPXChild = ChildCPXElementType->getAsPlaceholderType()->isSignedInteger(); bool IsUnsignedCPXDaddy = DaddyCPXElementType->getAsPlaceholderType()->isUnsignedInteger(); bool IsUnsignedCPXChild = ChildCPXElementType->getAsPlaceholderType()->isUnsignedInteger(); + */ + + bool IsSignedCPXDaddy = false; + bool IsUnsignedCPXDaddy = false; + if (DaddyCPXElementType) { + auto placeholderType = DaddyCPXElementType->getAsPlaceholderType(); + if (placeholderType) { + IsSignedCPXDaddy = placeholderType->isSignedInteger(); + IsUnsignedCPXDaddy = placeholderType->isUnsignedInteger(); + } + } + + bool IsSignedCPXChild = false; + bool IsUnsignedCPXChild = false; + if (ChildCPXElementType) { + auto placeholderType = ChildCPXElementType->getAsPlaceholderType(); + if (placeholderType) { + IsSignedCPXChild = placeholderType->isSignedInteger(); + IsUnsignedCPXChild = placeholderType->isUnsignedInteger(); + } + } if ((IsSignedCPXDaddy && IsUnsignedCPXChild) || (IsUnsignedCPXDaddy && IsSignedCPXChild)) { @@ -4869,7 +4919,14 @@ public: const clang::Type* CanonTP = ASTC->getCanonicalType(TP); - bool TypeIsUSignedInt = CanonTP->getAsPlaceholderType()->isUnsignedInteger(); + //bool TypeIsUSignedInt = CanonTP->getAsPlaceholderType()->isUnsignedInteger(); + bool TypeIsUSignedInt = false; + if (CanonTP) { + auto placeholderType = CanonTP->getAsPlaceholderType(); + if (placeholderType) { + TypeIsUSignedInt = placeholderType->isUnsignedInteger(); + } + } if (TypeIsUSignedInt) { -- cgit v1.2.3