Print expressions containing any valid pointer type.

Prior behavior was crashing when all it is is a pointer value.
Affecting Objective-C values on OS X.
This commit is contained in:
Frederich Munch 2016-06-06 15:30:08 -04:00 committed by sftnight
parent e71a2c60e1
commit fd083261b9
2 changed files with 19 additions and 9 deletions

View File

@ -329,11 +329,9 @@ namespace {
Call = m_Sema->ActOnFinishFullExpr(Call.get());
}
}
else if (desugaredTy->isIntegralOrEnumerationType()
|| desugaredTy->isReferenceType()
|| desugaredTy->isPointerType()
|| desugaredTy->isNullPtrType()
|| desugaredTy->isFloatingType()) {
else {
// Mark the current number of arguemnts
const size_t nArgs = CallArgs.size();
if (desugaredTy->isIntegralOrEnumerationType()) {
// 1) enum, integral, float, double, referece, pointer types :
// call to cling::internal::setValueNoAlloc(...);
@ -355,7 +353,7 @@ namespace {
E).get();
CallArgs.push_back(AddrOfE);
}
else if (desugaredTy->isPointerType()) {
else if (desugaredTy->isAnyPointerType()) {
// function pointers need explicit void* cast.
QualType VoidPtrTy = m_Context->VoidPtrTy;
TypeSourceInfo* TSI
@ -373,11 +371,17 @@ namespace {
// case, because of the overload resolution.
CallArgs.push_back(E);
}
Call = m_Sema->ActOnCallExpr(/*Scope*/0, m_UnresolvedNoAlloc,
// Test CallArgs.size to make sure an additional argument (the value)
// has been pushed on, if not than we didn't know how to handle the type
if (CallArgs.size() > nArgs) {
Call = m_Sema->ActOnCallExpr(/*Scope*/0, m_UnresolvedNoAlloc,
locStart, CallArgs, locEnd);
}
else
assert(0 && "Unhandled code path?");
}
else
assert(0 && "Unhandled code path?");
assert(!Call.isInvalid() && "Invalid Call");

View File

@ -104,6 +104,9 @@ static std::string getTypeString(const Value &V) {
typeWithOptDeref << "(void**)";
}
}
else if (Ty->isObjCObjectPointerType()) {
typeWithOptDeref << "(const void**)";
}
else {
// In other cases, dereference the address of the object.
// If no overload or specific template matches,
@ -276,6 +279,9 @@ static std::string invokePrintValueOverload(const Value &V) {
return "nullptr";
return executePrintValue<void *>(V, V.getPtr());
}
else if (Ty->isObjCObjectPointerType()) {
return executePrintValue<void *>(V, V.getPtr());
}
else {
// struct case.
if (!V.getPtr())