[PATCH] D70302: [CodeGen] Fix clang crash on aggregate initialization of array of labels
Johannes Altmanninger via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 27 16:08:42 PST 2019
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 *[]){ &&L, 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 &CGM;
- 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 &Ctx = CGF.getContext();
APValue Evaluated =
SLE->EvaluateInContext(Ctx, CGF.CurSourceLocExprScope.getDefaultExpr());
- return ConstantEmitter(CGF.CGM, &CGF)
- .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 &CGM = 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(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70302.231330.patch
Type: text/x-patch
Size: 1943 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191128/4d080cb1/attachment.bin>
More information about the cfe-commits
mailing list