[PATCH] Assertion failure llvm/tools/clang/lib/CodeGen/CGExprScalar.cpp:3202: llvm::Value* clang::CodeGen::CodeGenFunction::EmitScalarExpr(const clang::Expr*, bool): Assertion `E && hasScalarEvaluationKind(E->getType()) && "Invalid scalar expression to emit"' failed.
jyoti allur
jyoti.yalamanchili at gmail.com
Mon Oct 21 01:01:24 PDT 2013
Hi rsmith, eli.friedman, dblaikie,
Testcase that results in assertion has been added at /llvm/tools/clang/test/CodeGenCXX/initlist68.C in the diff attached.
It looks like CodeGenFunction::EmitNewArrayInitializer does not handle multidimensinal array initialization as yet.
I have made a small patch for the same to handle two dimensional array initialization, if the approach is rite will further modify it to a generic code to handle multidimensions.
Could you please let me know your review comments for this patch?
http://llvm-reviews.chandlerc.com/D1986
Files:
llvm/tools/clang/lib/CodeGen/CGExprCXX.cpp
initlist68.C
Index: llvm/tools/clang/lib/CodeGen/CGExprCXX.cpp
===================================================================
--- llvm/tools/clang/lib/CodeGen/CGExprCXX.cpp
+++ llvm/tools/clang/lib/CodeGen/CGExprCXX.cpp
@@ -786,8 +786,17 @@
// element. TODO: some of these stores can be trivially
// observed to be unnecessary.
if (endOfInit) Builder.CreateStore(explicitPtr, endOfInit);
- StoreAnyExprIntoOneUnit(*this, ILE->getInit(i), elementType, explicitPtr);
- explicitPtr =Builder.CreateConstGEP1_32(explicitPtr, 1, "array.exp.next");
+ if(const InitListExpr *ILE1 = dyn_cast<InitListExpr>(ILE->getInit(i))) {
+ for (unsigned j = 0, e1 = ILE1->getNumInits(); j != e1; ++j) {
+ StoreAnyExprIntoOneUnit(*this, ILE1->getInit(j), elementType, explicitPtr);
+ explicitPtr =Builder.CreateConstGEP1_32(explicitPtr, 1, "array.exp.next");
+ }
+ }
+ else {
+ StoreAnyExprIntoOneUnit(*this, ILE->getInit(i), elementType, explicitPtr);
+ explicitPtr =Builder.CreateConstGEP1_32(explicitPtr, 1, "array.exp.next");
+ }
+
}
// The remaining elements are filled with the array filler expression.
Index: initlist68.C
===================================================================
--- initlist68.C
+++ initlist68.C
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+typedef __SIZE_TYPE__ size_t;
+void* operator new[](size_t, void *p) { return p; }
+template <typename T = size_t>
+void f ()
+{
+ size_t coord [2][2];
+ new (&coord) size_t [2][2]
+ {
+ {0,0},
+ {0,0},
+ };
+}
+
+int main ()
+{
+ f<>();
+}
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1986.1.patch
Type: text/x-patch
Size: 1647 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131021/a7a6ccd1/attachment.bin>
More information about the cfe-commits
mailing list