]> granicus.if.org Git - clang/commitdiff
[CodeGen] Use StringRef. NFC.
authorGeorge Burgess IV <george.burgess.iv@gmail.com>
Thu, 3 Nov 2016 02:21:43 +0000 (02:21 +0000)
committerGeorge Burgess IV <george.burgess.iv@gmail.com>
Thu, 3 Nov 2016 02:21:43 +0000 (02:21 +0000)
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
lib/CodeGen/CGExprConstant.cpp
lib/CodeGen/CodeGenModule.h

index 933cd2a62cc46b1f02c7483ddbee8ce25851b795..a9a0dea49641b8cb875725d4566fdf2740a83909 100644 (file)
@@ -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);
index c268c0379256a1af5d0e5146ad10caf3fa169a75..cf834564c0abea84c5155be38de61ea899e9c1b3 100644 (file)
@@ -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<BlockExpr>(E), FunctionName.c_str());
+        CGM.GetAddrOfGlobalBlock(cast<BlockExpr>(E), FunctionName);
       return ConstantAddress(Ptr, CGM.getPointerAlign());
     }
     case Expr::CXXTypeidExprClass: {
index bdd2026db283b5e5d20f2c2879224b7a734a8e06..7def77479cb2e3987eec44ed7d3e4be8371ca76e 100644 (file)
@@ -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);