diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2012-11-15 23:40:48 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2012-11-15 23:40:48 +0000 |
commit | ab19712823b2c3b92bf7022747570c4675c308a7 (patch) | |
tree | aca68f6551f228a79907d73187832c310ce37696 | |
parent | 0608cd8bd48badd5358783f9e0cfb88667c34e9c (diff) | |
download | bcm5719-llvm-ab19712823b2c3b92bf7022747570c4675c308a7.tar.gz bcm5719-llvm-ab19712823b2c3b92bf7022747570c4675c308a7.zip |
Make sure CodeGenTypes correctly reconverts function types. Fixes PR14355, a crash in IR generation.
llvm-svn: 168112
-rw-r--r-- | clang/lib/CodeGen/CodeGenTypes.cpp | 12 | ||||
-rw-r--r-- | clang/test/CodeGen/incomplete-function-type-2.c | 17 |
2 files changed, 28 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp index 3c6c5c9a2e2..d7f15a730bf 100644 --- a/clang/lib/CodeGen/CodeGenTypes.cpp +++ b/clang/lib/CodeGen/CodeGenTypes.cpp @@ -453,9 +453,19 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) { // cannot lower the function type. if (!isFuncTypeConvertible(FT)) { // This function's type depends on an incomplete tag type. + + // Force conversion of all the relevant record types, to make sure + // we re-convert the FunctionType when appropriate. + if (const RecordType *RT = FT->getResultType()->getAs<RecordType>()) + ConvertRecordDeclType(RT->getDecl()); + if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(FT)) + for (unsigned i = 0, e = FPT->getNumArgs(); i != e; i++) + if (const RecordType *RT = FPT->getArgType(i)->getAs<RecordType>()) + ConvertRecordDeclType(RT->getDecl()); + // Return a placeholder type. ResultType = llvm::StructType::get(getLLVMContext()); - + SkippedLayout = true; break; } diff --git a/clang/test/CodeGen/incomplete-function-type-2.c b/clang/test/CodeGen/incomplete-function-type-2.c new file mode 100644 index 00000000000..c6882f6c8a7 --- /dev/null +++ b/clang/test/CodeGen/incomplete-function-type-2.c @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s + +// PR14355: don't crash +// Keep this test in its own file because CodeGenTypes has global state. +// CHECK: define void @test10_foo({}* %p1.coerce) nounwind { +struct test10_B; +typedef struct test10_B test10_F3(double); +void test10_foo(test10_F3 p1); +struct test10_B test10_b(double); +void test10_bar() { + test10_foo(test10_b); +} +struct test10_B {}; +void test10_foo(test10_F3 p1) +{ + p1(0.0); +} |