[PATCH] D70302: [CodeGen] Fix clang crash on aggregate initialization of array of labels

2019-12-02 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D70302#1764261 , @johannes wrote:

> I see, apologies for the premature commit.


No problem, LLVM's code review practices are somewhat opaque.




Comment at: clang/test/CodeGen/label-array-aggregate-init.c:1
+// RUN: %clang -cc1 -emit-llvm %s -o /dev/null
+

johannes wrote:
> rnk wrote:
> > It's best practice to filecheck for something, even if this used to crash.
> I guess the test should make sure that the array is constructed successfully 
> after codegen.
> I'm unsure about the best way to test that. 
I went ahead and did it in rG536cedaecbe586ec9cf86d5102872adc27e6ea23.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70302/new/

https://reviews.llvm.org/D70302



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70302: [CodeGen] Fix clang crash on aggregate initialization of array of labels

2019-11-30 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes added a comment.

In D70302#1763025 , @rnk wrote:

> Fix looks good post commit, but we should enhance the test.


I see, apologies for the premature commit.




Comment at: clang/test/CodeGen/label-array-aggregate-init.c:1
+// RUN: %clang -cc1 -emit-llvm %s -o /dev/null
+

rnk wrote:
> It's best practice to filecheck for something, even if this used to crash.
I guess the test should make sure that the array is constructed successfully 
after codegen.
I'm unsure about the best way to test that. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70302/new/

https://reviews.llvm.org/D70302



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70302: [CodeGen] Fix clang crash on aggregate initialization of array of labels

2019-11-28 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Fix looks good post commit, but we should enhance the test.




Comment at: clang/test/CodeGen/label-array-aggregate-init.c:1
+// RUN: %clang -cc1 -emit-llvm %s -o /dev/null
+

It's best practice to filecheck for something, even if this used to crash.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70302/new/

https://reviews.llvm.org/D70302



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70302: [CodeGen] Fix clang crash on aggregate initialization of array of labels

2019-11-27 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

I think this was commited too soon. You should receive LGTM from clang 
maintainer(s).

In D70302#1747372 , @nickie wrote:

> LGTM, for all that it's worth.





Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70302/new/

https://reviews.llvm.org/D70302



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70302: [CodeGen] Fix clang crash on aggregate initialization of array of labels

2019-11-27 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes added a comment.

Committed as 1ac700cdef787383ad49a0e37d9894491ef19480 
 - this 
should be a safe fix


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70302/new/

https://reviews.llvm.org/D70302



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70302: [CodeGen] Fix clang crash on aggregate initialization of array of labels

2019-11-27 Thread Johannes Altmanninger via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1ac700cdef78: [CodeGen] Fix clang crash on aggregate 
initialization of array of labels (authored by johannes).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70302/new/

https://reviews.llvm.org/D70302

Files:
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/ConstantEmitter.h
  clang/test/CodeGen/label-array-aggregate-init.c


Index: clang/test/CodeGen/label-array-aggregate-init.c
===
--- /dev/null
+++ clang/test/CodeGen/label-array-aggregate-init.c
@@ -0,0 +1,6 @@
+// RUN: %clang -cc1 -emit-llvm %s -o /dev/null
+
+int main() {
+L:
+  (void)(void *[]){ &, 0, 0 };
+}
Index: clang/lib/CodeGen/ConstantEmitter.h
===
--- clang/lib/CodeGen/ConstantEmitter.h
+++ clang/lib/CodeGen/ConstantEmitter.h
@@ -23,7 +23,7 @@
 class ConstantEmitter {
 public:
   CodeGenModule 
-  CodeGenFunction *CGF;
+  CodeGenFunction *const CGF;
 
 private:
   bool Abstract = false;
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -644,8 +644,8 @@
 auto  = CGF.getContext();
 APValue Evaluated =
 SLE->EvaluateInContext(Ctx, 
CGF.CurSourceLocExprScope.getDefaultExpr());
-return ConstantEmitter(CGF.CGM, )
-.emitAbstract(SLE->getLocation(), Evaluated, SLE->getType());
+return ConstantEmitter(CGF).emitAbstract(SLE->getLocation(), Evaluated,
+ SLE->getType());
   }
 
   Value *VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) {
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -493,7 +493,7 @@
   if (NumInitElements * elementSize.getQuantity() > 16 &&
   elementType.isTriviallyCopyableType(CGF.getContext())) {
 CodeGen::CodeGenModule  = CGF.CGM;
-ConstantEmitter Emitter(CGM);
+ConstantEmitter Emitter(CGF);
 LangAS AS = ArrayQTy.getAddressSpace();
 if (llvm::Constant *C = Emitter.tryEmitForInitializer(E, AS, ArrayQTy)) {
   auto GV = new llvm::GlobalVariable(


Index: clang/test/CodeGen/label-array-aggregate-init.c
===
--- /dev/null
+++ clang/test/CodeGen/label-array-aggregate-init.c
@@ -0,0 +1,6 @@
+// RUN: %clang -cc1 -emit-llvm %s -o /dev/null
+
+int main() {
+L:
+  (void)(void *[]){ &, 0, 0 };
+}
Index: clang/lib/CodeGen/ConstantEmitter.h
===
--- clang/lib/CodeGen/ConstantEmitter.h
+++ clang/lib/CodeGen/ConstantEmitter.h
@@ -23,7 +23,7 @@
 class ConstantEmitter {
 public:
   CodeGenModule 
-  CodeGenFunction *CGF;
+  CodeGenFunction *const CGF;
 
 private:
   bool Abstract = false;
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -644,8 +644,8 @@
 auto  = CGF.getContext();
 APValue Evaluated =
 SLE->EvaluateInContext(Ctx, CGF.CurSourceLocExprScope.getDefaultExpr());
-return ConstantEmitter(CGF.CGM, )
-.emitAbstract(SLE->getLocation(), Evaluated, SLE->getType());
+return ConstantEmitter(CGF).emitAbstract(SLE->getLocation(), Evaluated,
+ SLE->getType());
   }
 
   Value *VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) {
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -493,7 +493,7 @@
   if (NumInitElements * elementSize.getQuantity() > 16 &&
   elementType.isTriviallyCopyableType(CGF.getContext())) {
 CodeGen::CodeGenModule  = CGF.CGM;
-ConstantEmitter Emitter(CGM);
+ConstantEmitter Emitter(CGF);
 LangAS AS = ArrayQTy.getAddressSpace();
 if (llvm::Constant *C = Emitter.tryEmitForInitializer(E, AS, ArrayQTy)) {
   auto GV = new llvm::GlobalVariable(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70302: [CodeGen] Fix clang crash on aggregate initialization of array of labels

2019-11-27 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 231330.
johannes edited the summary of this revision.
johannes added a comment.

update commit message


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70302/new/

https://reviews.llvm.org/D70302

Files:
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/ConstantEmitter.h
  clang/test/CodeGen/label-array-aggregate-init.c


Index: clang/test/CodeGen/label-array-aggregate-init.c
===
--- /dev/null
+++ clang/test/CodeGen/label-array-aggregate-init.c
@@ -0,0 +1,6 @@
+// RUN: %clang -cc1 -emit-llvm %s -o /dev/null
+
+int main() {
+L:
+  (void)(void *[]){ &, 0, 0 };
+}
Index: clang/lib/CodeGen/ConstantEmitter.h
===
--- clang/lib/CodeGen/ConstantEmitter.h
+++ clang/lib/CodeGen/ConstantEmitter.h
@@ -23,7 +23,7 @@
 class ConstantEmitter {
 public:
   CodeGenModule 
-  CodeGenFunction *CGF;
+  CodeGenFunction *const CGF;
 
 private:
   bool Abstract = false;
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -644,8 +644,8 @@
 auto  = CGF.getContext();
 APValue Evaluated =
 SLE->EvaluateInContext(Ctx, 
CGF.CurSourceLocExprScope.getDefaultExpr());
-return ConstantEmitter(CGF.CGM, )
-.emitAbstract(SLE->getLocation(), Evaluated, SLE->getType());
+return ConstantEmitter(CGF).emitAbstract(SLE->getLocation(), Evaluated,
+ SLE->getType());
   }
 
   Value *VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) {
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -493,7 +493,7 @@
   if (NumInitElements * elementSize.getQuantity() > 16 &&
   elementType.isTriviallyCopyableType(CGF.getContext())) {
 CodeGen::CodeGenModule  = CGF.CGM;
-ConstantEmitter Emitter(CGM);
+ConstantEmitter Emitter(CGF);
 LangAS AS = ArrayQTy.getAddressSpace();
 if (llvm::Constant *C = Emitter.tryEmitForInitializer(E, AS, ArrayQTy)) {
   auto GV = new llvm::GlobalVariable(


Index: clang/test/CodeGen/label-array-aggregate-init.c
===
--- /dev/null
+++ clang/test/CodeGen/label-array-aggregate-init.c
@@ -0,0 +1,6 @@
+// RUN: %clang -cc1 -emit-llvm %s -o /dev/null
+
+int main() {
+L:
+  (void)(void *[]){ &, 0, 0 };
+}
Index: clang/lib/CodeGen/ConstantEmitter.h
===
--- clang/lib/CodeGen/ConstantEmitter.h
+++ clang/lib/CodeGen/ConstantEmitter.h
@@ -23,7 +23,7 @@
 class ConstantEmitter {
 public:
   CodeGenModule 
-  CodeGenFunction *CGF;
+  CodeGenFunction *const CGF;
 
 private:
   bool Abstract = false;
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -644,8 +644,8 @@
 auto  = CGF.getContext();
 APValue Evaluated =
 SLE->EvaluateInContext(Ctx, CGF.CurSourceLocExprScope.getDefaultExpr());
-return ConstantEmitter(CGF.CGM, )
-.emitAbstract(SLE->getLocation(), Evaluated, SLE->getType());
+return ConstantEmitter(CGF).emitAbstract(SLE->getLocation(), Evaluated,
+ SLE->getType());
   }
 
   Value *VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) {
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -493,7 +493,7 @@
   if (NumInitElements * elementSize.getQuantity() > 16 &&
   elementType.isTriviallyCopyableType(CGF.getContext())) {
 CodeGen::CodeGenModule  = CGF.CGM;
-ConstantEmitter Emitter(CGM);
+ConstantEmitter Emitter(CGF);
 LangAS AS = ArrayQTy.getAddressSpace();
 if (llvm::Constant *C = Emitter.tryEmitForInitializer(E, AS, ArrayQTy)) {
   auto GV = new llvm::GlobalVariable(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70302: [CodeGen] Fix clang crash on aggregate initialization of array of labels

2019-11-16 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes marked an inline comment as done.
johannes added inline comments.



Comment at: clang/lib/CodeGen/CGExpr.cpp:1021
 void CodeGenModule::EmitExplicitCastExprType(const ExplicitCastExpr *E,
- CodeGenFunction *CGF) {
+ CodeGenFunction *const CGF) {
   // Bind VLAs in the cast type.

nickie wrote:
> I don't think that `const` is necessary here.  We're talking about the 
> function's parameter.  Why isn't `E` a `*const` too?
Right, this was left over from when I thought it was necessary. Removed the 
`const` because it is surprising.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70302/new/

https://reviews.llvm.org/D70302



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70302: [CodeGen] Fix clang crash on aggregate initialization of array of labels

2019-11-16 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 229556.
johannes added a comment.

Remove unneccesary const on parameter


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70302/new/

https://reviews.llvm.org/D70302

Files:
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/ConstantEmitter.h
  clang/test/CodeGen/label-array-aggregate-init.c


Index: clang/test/CodeGen/label-array-aggregate-init.c
===
--- /dev/null
+++ clang/test/CodeGen/label-array-aggregate-init.c
@@ -0,0 +1,6 @@
+// RUN: %clang -cc1 -emit-llvm %s -o /dev/null
+
+int main() {
+L:
+  (void)(void *[]){ &, 0, 0 };
+}
Index: clang/lib/CodeGen/ConstantEmitter.h
===
--- clang/lib/CodeGen/ConstantEmitter.h
+++ clang/lib/CodeGen/ConstantEmitter.h
@@ -23,7 +23,7 @@
 class ConstantEmitter {
 public:
   CodeGenModule 
-  CodeGenFunction *CGF;
+  CodeGenFunction *const CGF;
 
 private:
   bool Abstract = false;
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -644,8 +644,8 @@
 auto  = CGF.getContext();
 APValue Evaluated =
 SLE->EvaluateInContext(Ctx, 
CGF.CurSourceLocExprScope.getDefaultExpr());
-return ConstantEmitter(CGF.CGM, )
-.emitAbstract(SLE->getLocation(), Evaluated, SLE->getType());
+return ConstantEmitter(CGF).emitAbstract(SLE->getLocation(), Evaluated,
+ SLE->getType());
   }
 
   Value *VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) {
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -493,7 +493,7 @@
   if (NumInitElements * elementSize.getQuantity() > 16 &&
   elementType.isTriviallyCopyableType(CGF.getContext())) {
 CodeGen::CodeGenModule  = CGF.CGM;
-ConstantEmitter Emitter(CGM);
+ConstantEmitter Emitter(CGF);
 LangAS AS = ArrayQTy.getAddressSpace();
 if (llvm::Constant *C = Emitter.tryEmitForInitializer(E, AS, ArrayQTy)) {
   auto GV = new llvm::GlobalVariable(


Index: clang/test/CodeGen/label-array-aggregate-init.c
===
--- /dev/null
+++ clang/test/CodeGen/label-array-aggregate-init.c
@@ -0,0 +1,6 @@
+// RUN: %clang -cc1 -emit-llvm %s -o /dev/null
+
+int main() {
+L:
+  (void)(void *[]){ &, 0, 0 };
+}
Index: clang/lib/CodeGen/ConstantEmitter.h
===
--- clang/lib/CodeGen/ConstantEmitter.h
+++ clang/lib/CodeGen/ConstantEmitter.h
@@ -23,7 +23,7 @@
 class ConstantEmitter {
 public:
   CodeGenModule 
-  CodeGenFunction *CGF;
+  CodeGenFunction *const CGF;
 
 private:
   bool Abstract = false;
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -644,8 +644,8 @@
 auto  = CGF.getContext();
 APValue Evaluated =
 SLE->EvaluateInContext(Ctx, CGF.CurSourceLocExprScope.getDefaultExpr());
-return ConstantEmitter(CGF.CGM, )
-.emitAbstract(SLE->getLocation(), Evaluated, SLE->getType());
+return ConstantEmitter(CGF).emitAbstract(SLE->getLocation(), Evaluated,
+ SLE->getType());
   }
 
   Value *VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) {
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -493,7 +493,7 @@
   if (NumInitElements * elementSize.getQuantity() > 16 &&
   elementType.isTriviallyCopyableType(CGF.getContext())) {
 CodeGen::CodeGenModule  = CGF.CGM;
-ConstantEmitter Emitter(CGM);
+ConstantEmitter Emitter(CGF);
 LangAS AS = ArrayQTy.getAddressSpace();
 if (llvm::Constant *C = Emitter.tryEmitForInitializer(E, AS, ArrayQTy)) {
   auto GV = new llvm::GlobalVariable(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70302: [CodeGen] Fix clang crash on aggregate initialization of array of labels

2019-11-16 Thread Nikolaos S. Papaspyrou via Phabricator via cfe-commits
nickie marked an inline comment as done.
nickie added a comment.

LGTM, for all that it's worth.




Comment at: clang/lib/CodeGen/CGExpr.cpp:1021
 void CodeGenModule::EmitExplicitCastExprType(const ExplicitCastExpr *E,
- CodeGenFunction *CGF) {
+ CodeGenFunction *const CGF) {
   // Bind VLAs in the cast type.

I don't think that `const` is necessary here.  We're talking about the 
function's parameter.  Why isn't `E` a `*const` too?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70302/new/

https://reviews.llvm.org/D70302



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70302: [CodeGen] Fix clang crash on aggregate initialization of array of labels

2019-11-15 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes created this revision.
Herald added a project: clang.

Fixes pr/43700.

Also simplify another call, and make the CGF member a const pointer
since it is public but only assigned in the constructor.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70302

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/ConstantEmitter.h
  clang/test/CodeGen/label-array-aggregate-init.c


Index: clang/test/CodeGen/label-array-aggregate-init.c
===
--- /dev/null
+++ clang/test/CodeGen/label-array-aggregate-init.c
@@ -0,0 +1,7 @@
+// RUN: %clang -cc1 -emit-llvm %s -o /dev/null
+
+int main() {
+L:
+  (void)(void *[]){ &, 0, 0 };
+}
+
Index: clang/lib/CodeGen/ConstantEmitter.h
===
--- clang/lib/CodeGen/ConstantEmitter.h
+++ clang/lib/CodeGen/ConstantEmitter.h
@@ -23,7 +23,7 @@
 class ConstantEmitter {
 public:
   CodeGenModule 
-  CodeGenFunction *CGF;
+  CodeGenFunction *const CGF;
 
 private:
   bool Abstract = false;
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -644,8 +644,8 @@
 auto  = CGF.getContext();
 APValue Evaluated =
 SLE->EvaluateInContext(Ctx, 
CGF.CurSourceLocExprScope.getDefaultExpr());
-return ConstantEmitter(CGF.CGM, )
-.emitAbstract(SLE->getLocation(), Evaluated, SLE->getType());
+return ConstantEmitter(CGF).emitAbstract(SLE->getLocation(), Evaluated,
+ SLE->getType());
   }
 
   Value *VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) {
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -493,7 +493,7 @@
   if (NumInitElements * elementSize.getQuantity() > 16 &&
   elementType.isTriviallyCopyableType(CGF.getContext())) {
 CodeGen::CodeGenModule  = CGF.CGM;
-ConstantEmitter Emitter(CGM);
+ConstantEmitter Emitter(CGF);
 LangAS AS = ArrayQTy.getAddressSpace();
 if (llvm::Constant *C = Emitter.tryEmitForInitializer(E, AS, ArrayQTy)) {
   auto GV = new llvm::GlobalVariable(
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -1018,7 +1018,7 @@
 }
 
 void CodeGenModule::EmitExplicitCastExprType(const ExplicitCastExpr *E,
- CodeGenFunction *CGF) {
+ CodeGenFunction *const CGF) {
   // Bind VLAs in the cast type.
   if (CGF && E->getType()->isVariablyModifiedType())
 CGF->EmitVariablyModifiedType(E->getType());


Index: clang/test/CodeGen/label-array-aggregate-init.c
===
--- /dev/null
+++ clang/test/CodeGen/label-array-aggregate-init.c
@@ -0,0 +1,7 @@
+// RUN: %clang -cc1 -emit-llvm %s -o /dev/null
+
+int main() {
+L:
+  (void)(void *[]){ &, 0, 0 };
+}
+
Index: clang/lib/CodeGen/ConstantEmitter.h
===
--- clang/lib/CodeGen/ConstantEmitter.h
+++ clang/lib/CodeGen/ConstantEmitter.h
@@ -23,7 +23,7 @@
 class ConstantEmitter {
 public:
   CodeGenModule 
-  CodeGenFunction *CGF;
+  CodeGenFunction *const CGF;
 
 private:
   bool Abstract = false;
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -644,8 +644,8 @@
 auto  = CGF.getContext();
 APValue Evaluated =
 SLE->EvaluateInContext(Ctx, CGF.CurSourceLocExprScope.getDefaultExpr());
-return ConstantEmitter(CGF.CGM, )
-.emitAbstract(SLE->getLocation(), Evaluated, SLE->getType());
+return ConstantEmitter(CGF).emitAbstract(SLE->getLocation(), Evaluated,
+ SLE->getType());
   }
 
   Value *VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) {
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -493,7 +493,7 @@
   if (NumInitElements * elementSize.getQuantity() > 16 &&
   elementType.isTriviallyCopyableType(CGF.getContext())) {
 CodeGen::CodeGenModule  = CGF.CGM;
-ConstantEmitter Emitter(CGM);
+ConstantEmitter Emitter(CGF);
 LangAS AS = ArrayQTy.getAddressSpace();
 if (llvm::Constant *C = Emitter.tryEmitForInitializer(E, AS, ArrayQTy)) {
   auto GV = new llvm::GlobalVariable(
Index: clang/lib/CodeGen/CGExpr.cpp
===
---