diff --git a/interpreter/cling/include/cling/Interpreter/RuntimeUniverse.h b/interpreter/cling/include/cling/Interpreter/RuntimeUniverse.h index 446a37e69f3a6..c6f0f2eab0972 100644 --- a/interpreter/cling/include/cling/Interpreter/RuntimeUniverse.h +++ b/interpreter/cling/include/cling/Interpreter/RuntimeUniverse.h @@ -171,17 +171,11 @@ namespace cling { ///\param[in] placement - where to copy ///\param[in] size - size of the array. /// - template + template void copyArray(T* src, void* placement, std::size_t size) { for (std::size_t i = 0; i < size; ++i) new ((void*)(((T*)placement) + i)) T(src[i]); } - - // "size" is the number of elements even for subarrays; flatten the type: - template - void copyArray(const T (*src)[N], void* placement, std::size_t size) { - copyArray(src[0], placement, size); - } } // end namespace internal } // end namespace runtime } // end namespace cling diff --git a/interpreter/cling/lib/Interpreter/ExternalInterpreterSource.cpp b/interpreter/cling/lib/Interpreter/ExternalInterpreterSource.cpp index 42d2a2dcf1422..1c83a4e0ecb3f 100644 --- a/interpreter/cling/lib/Interpreter/ExternalInterpreterSource.cpp +++ b/interpreter/cling/lib/Interpreter/ExternalInterpreterSource.cpp @@ -111,7 +111,7 @@ namespace cling { const Decl* To = llvm::cantFail(m_Importer->Import(declToImport)); assert(To && "Import did not work!"); assert((DS.empty() || - DS[0].getID() == clang::diag::err_unsupported_ast_node) && + DS[0].getID() != clang::diag::err_unsupported_ast_node) && "Import not supported!"); #endif return; diff --git a/interpreter/cling/lib/Interpreter/ValueExtractionSynthesizer.cpp b/interpreter/cling/lib/Interpreter/ValueExtractionSynthesizer.cpp index 830d50ace2583..cf6d6cdf2979a 100644 --- a/interpreter/cling/lib/Interpreter/ValueExtractionSynthesizer.cpp +++ b/interpreter/cling/lib/Interpreter/ValueExtractionSynthesizer.cpp @@ -295,7 +295,14 @@ namespace { if (const ConstantArrayType* constArray = dyn_cast(desugaredTy.getTypePtr())) { CallArgs.clear(); - CallArgs.push_back(E); + // Get a pointer to the base element type so the instantiated copyArray + // template can do placement new. + QualType baseElementType = m_Context->getBaseElementType(desugaredTy); + TypeSourceInfo* TSI = m_Context->getTrivialTypeSourceInfo( + m_Context->getPointerType(baseElementType), noLoc); + Expr* srcPointer = + m_Sema->BuildCStyleCastExpr(noLoc, TSI, noLoc, E).get(); + CallArgs.push_back(srcPointer); CallArgs.push_back(placement); size_t arrSize = m_Context->getConstantArrayElementCount(constArray);