From 6143293fa4366ee95d7e47e61bd030a34bf68b55 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Wed, 13 Aug 2008 23:20:05 +0000 Subject: Add GetAddrOfConstantCString method - Returns addr of constant for argument + '\0'. - I couldn't think of a better name. - Move appropriate users of GetAddrOfConstantString to this. Rename getStringForStringLiteral to GetStringForStringLiteral. Add GetAddrOfConstantStringFromLiteral - This combines GetAddrOfConstantString and GetStringForStringLiteral. This method can be, but is not yet, more efficient. Change GetAddrOfConstantString to not add terminating '\0' - git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54768 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExprConstant.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'lib/CodeGen/CGExprConstant.cpp') diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index 12620e7101..dfd047c89d 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -363,7 +363,7 @@ public: // Otherwise this must be a string initializing an array in a static // initializer. Don't emit it as the address of the string, emit the string // data itself as an inline array. - return llvm::ConstantArray::get(CGM.getStringForStringLiteral(E), false); + return llvm::ConstantArray::get(CGM.GetStringForStringLiteral(E), false); } llvm::Constant *VisitDeclRefExpr(DeclRefExpr *E) { @@ -762,10 +762,8 @@ public: "Taking the address of a vector component is illegal!"); return llvm::ConstantExpr::getGetElementPtr(Base, &Index, 1); } - case Expr::StringLiteralClass: { - StringLiteral *S = cast(E); - return CGM.GetAddrOfConstantString(CGM.getStringForStringLiteral(S)); - } + case Expr::StringLiteralClass: + return CGM.GetAddrOfConstantStringFromLiteral(cast(E)); case Expr::UnaryOperatorClass: { UnaryOperator *Exp = cast(E); switch (Exp->getOpcode()) { -- cgit v1.2.3