diff options
author | Alexey Samsonov <vonosmas@gmail.com> | 2014-06-04 20:25:57 +0000 |
---|---|---|
committer | Alexey Samsonov <vonosmas@gmail.com> | 2014-06-04 20:25:57 +0000 |
commit | e88163d87fc058590b6f0af25a2b5f2057723945 (patch) | |
tree | bb1052963225fa8952963d777eb64627be2782c4 /lib/CodeGen/CodeGenModule.cpp | |
parent | c54a9c3b7aa1b0f857ee866d3aae71f1d7884d6a (diff) | |
download | clang-e88163d87fc058590b6f0af25a2b5f2057723945.tar.gz clang-e88163d87fc058590b6f0af25a2b5f2057723945.tar.bz2 clang-e88163d87fc058590b6f0af25a2b5f2057723945.tar.xz |
Remove the overload of GetAddrOfConstantString method
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210214 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 8f728a4a38..ac89ce699a 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -2778,17 +2778,13 @@ llvm::StringMapEntry<llvm::GlobalVariable *> *CodeGenModule::getConstantStringMa return &ConstantStringMap->GetOrCreateValue(Str); } -/// GetAddrOfConstantString - Returns a pointer to a character array -/// containing the literal. This contents are exactly that of the -/// given string, i.e. it will not be null terminated automatically; -/// see GetAddrOfConstantCString. Note that whether the result is -/// actually a pointer to an LLVM constant depends on -/// Feature.WriteableStrings. -/// +/// GetAddrOfConstantCString - Returns a pointer to a character array containing +/// the literal and a terminating '\0' character. /// The result has pointer to array type. -llvm::Constant *CodeGenModule::GetAddrOfConstantString(StringRef Str, - const char *GlobalName, - unsigned Alignment) { +llvm::Constant *CodeGenModule::GetAddrOfConstantCString(const std::string &Str, + const char *GlobalName, + unsigned Alignment) { + StringRef StrWithNull(Str.c_str(), Str.size() + 1); if (Alignment == 0) { Alignment = getContext() .getAlignOfGlobalVarInChars(getContext().CharTy) @@ -2798,7 +2794,7 @@ llvm::Constant *CodeGenModule::GetAddrOfConstantString(StringRef Str, // Don't share any string literals if strings aren't constant. llvm::StringMapEntry<llvm::GlobalVariable *> *Entry = nullptr; if (!LangOpts.WritableStrings) { - Entry = getConstantStringMapEntry(Str, 1); + Entry = getConstantStringMapEntry(StrWithNull, 1); if (auto GV = Entry->getValue()) { if (Alignment > GV->getAlignment()) GV->setAlignment(Alignment); @@ -2806,9 +2802,8 @@ llvm::Constant *CodeGenModule::GetAddrOfConstantString(StringRef Str, } } - // Create Constant for this string literal. Don't add a '\0'. llvm::Constant *C = - llvm::ConstantDataArray::getString(getLLVMContext(), Str, false); + llvm::ConstantDataArray::getString(getLLVMContext(), StrWithNull, false); // Get the default prefix if a name wasn't specified. if (!GlobalName) GlobalName = ".str"; @@ -2820,16 +2815,6 @@ llvm::Constant *CodeGenModule::GetAddrOfConstantString(StringRef Str, return GV; } -/// GetAddrOfConstantCString - Returns a pointer to a character -/// array containing the literal and a terminating '\0' -/// character. The result has pointer to array type. -llvm::Constant *CodeGenModule::GetAddrOfConstantCString(const std::string &Str, - const char *GlobalName, - unsigned Alignment) { - StringRef StrWithNull(Str.c_str(), Str.size() + 1); - return GetAddrOfConstantString(StrWithNull, GlobalName, Alignment); -} - llvm::Constant *CodeGenModule::GetAddrOfGlobalTemporary( const MaterializeTemporaryExpr *E, const Expr *Init) { assert((E->getStorageDuration() == SD_Static || |