[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
Fri Nov 15 03:39:26 PST 2019
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 *[]){ &&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(
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());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70302.229497.patch
Type: text/x-patch
Size: 2499 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191115/352e8e38/attachment.bin>
More information about the cfe-commits
mailing list