From: Nick Lewycky Date: Wed, 16 Feb 2011 23:59:08 +0000 (+0000) Subject: Ensure that the NRVO flag has some block to insert into. Fixes PR9178! X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a03733b28b7c0a6dde83561a8a391c1067f404a5;p=clang Ensure that the NRVO flag has some block to insert into. Fixes PR9178! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125694 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index c31840a78e..129416fa07 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -648,7 +648,8 @@ void CodeGenFunction::EmitAutoVarDecl(const VarDecl &D, // to this variable. Set it to zero to indicate that NRVO was not // applied. llvm::Value *Zero = Builder.getFalse(); - NRVOFlag = CreateTempAlloca(Zero->getType(), "nrvo"); + NRVOFlag = CreateTempAlloca(Zero->getType(), "nrvo"); + EnsureInsertPoint(); Builder.CreateStore(Zero, NRVOFlag); // Record the NRVO flag for this variable. diff --git a/test/CodeGenCXX/nrvo-noreturn.cc b/test/CodeGenCXX/nrvo-noreturn.cc new file mode 100644 index 0000000000..a8259cab5f --- /dev/null +++ b/test/CodeGenCXX/nrvo-noreturn.cc @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -emit-llvm-only %s +// PR9178 + +void abort() __attribute__((__noreturn__)); +struct CoinModelLink { + CoinModelLink(); + ~CoinModelLink(); +}; +class CoinModel { + CoinModelLink firstInQuadraticColumn(); +}; +CoinModelLink CoinModel::firstInQuadraticColumn() { + abort(); + CoinModelLink x; + return x; +} +