From 05717751534cd98361c9817a724a7a8d7847c62b Mon Sep 17 00:00:00 2001 From: George Burgess IV Date: Thu, 3 Nov 2016 02:21:43 +0000 Subject: [PATCH] [CodeGen] Use StringRef. NFC. Looks like CurFn's name outlives FunctionName, so we can just pass StringRefs around rather than going from a StringRef to a std::string to a const char* to a StringRef. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@285873 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGBlocks.cpp | 8 ++++---- lib/CodeGen/CGExprConstant.cpp | 4 ++-- lib/CodeGen/CodeGenModule.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp index 933cd2a62c..a9a0dea496 100644 --- a/lib/CodeGen/CGBlocks.cpp +++ b/lib/CodeGen/CGBlocks.cpp @@ -1052,10 +1052,10 @@ Address CodeGenFunction::GetAddrOfBlockDecl(const VarDecl *variable, } llvm::Constant * -CodeGenModule::GetAddrOfGlobalBlock(const BlockExpr *blockExpr, - const char *name) { - CGBlockInfo blockInfo(blockExpr->getBlockDecl(), name); - blockInfo.BlockExpression = blockExpr; +CodeGenModule::GetAddrOfGlobalBlock(const BlockExpr *BE, + StringRef Name) { + CGBlockInfo blockInfo(BE->getBlockDecl(), Name); + blockInfo.BlockExpression = BE; // Compute information about the layout, etc., of this block. computeBlockInfo(*this, nullptr, blockInfo); diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index c268c03792..cf834564c0 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -1086,7 +1086,7 @@ public: return CGM.GetAddrOfConstantCFString(Literal); } case Expr::BlockExprClass: { - std::string FunctionName; + StringRef FunctionName; if (CGF) FunctionName = CGF->CurFn->getName(); else @@ -1094,7 +1094,7 @@ public: // This is not really an l-value. llvm::Constant *Ptr = - CGM.GetAddrOfGlobalBlock(cast(E), FunctionName.c_str()); + CGM.GetAddrOfGlobalBlock(cast(E), FunctionName); return ConstantAddress(Ptr, CGM.getPointerAlign()); } case Expr::CXXTypeidExprClass: { diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h index bdd2026db2..7def77479c 100644 --- a/lib/CodeGen/CodeGenModule.h +++ b/lib/CodeGen/CodeGenModule.h @@ -773,7 +773,7 @@ public: llvm::Type *getGenericBlockLiteralType(); /// Gets the address of a block which requires no captures. - llvm::Constant *GetAddrOfGlobalBlock(const BlockExpr *BE, const char *); + llvm::Constant *GetAddrOfGlobalBlock(const BlockExpr *BE, StringRef Name); /// Return a pointer to a constant CFString object for the given string. ConstantAddress GetAddrOfConstantCFString(const StringLiteral *Literal); -- 2.40.0