summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorAlexey Samsonov <vonosmas@gmail.com>2014-06-04 20:25:57 +0000
committerAlexey Samsonov <vonosmas@gmail.com>2014-06-04 20:25:57 +0000
commitadc9037b88e16c231879f9bfb76e6e3d3003398f (patch)
treedee96bdb9b45b2548b7c4c5a67c30659d97e7ac5 /clang/lib/CodeGen
parentba78c15c9d1a80d5870464406fd5a6728e310af5 (diff)
downloadbcm5719-llvm-adc9037b88e16c231879f9bfb76e6e3d3003398f.tar.gz
bcm5719-llvm-adc9037b88e16c231879f9bfb76e6e3d3003398f.zip
Remove the overload of GetAddrOfConstantString method
llvm-svn: 210214
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGObjCGNU.cpp3
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp31
-rw-r--r--clang/lib/CodeGen/CodeGenModule.h18
3 files changed, 11 insertions, 41 deletions
diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index 3ca03780a32..619a66ab4a6 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -237,9 +237,8 @@ protected:
NameAndAttributes += TypeStr;
NameAndAttributes += '\0';
NameAndAttributes += PD->getNameAsString();
- NameAndAttributes += '\0';
return llvm::ConstantExpr::getGetElementPtr(
- CGM.GetAddrOfConstantString(NameAndAttributes), Zeros);
+ CGM.GetAddrOfConstantCString(NameAndAttributes), Zeros);
}
return MakeConstantString(PD->getNameAsString());
}
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 8f728a4a384..ac89ce699a6 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/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 ||
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index cbc81ff6fef..f157d20e6cf 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -746,28 +746,14 @@ public:
/// Return a pointer to a constant array for the given ObjCEncodeExpr node.
llvm::Constant *GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *);
- /// 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.
- ///
- /// The result has pointer to array type.
- ///
- /// \param GlobalName If provided, the name to use for the global
- /// (if one is created).
- llvm::Constant *GetAddrOfConstantString(StringRef Str,
- const char *GlobalName=nullptr,
- unsigned Alignment=0);
-
/// Returns a pointer to a character array containing the literal and a
/// terminating '\0' character. The result has pointer to array type.
///
/// \param GlobalName If provided, the name to use for the global (if one is
/// created).
llvm::Constant *GetAddrOfConstantCString(const std::string &str,
- const char *GlobalName=nullptr,
- unsigned Alignment=0);
+ const char *GlobalName = nullptr,
+ unsigned Alignment = 0);
/// Returns a pointer to a constant global variable for the given file-scope
/// compound literal expression.
OpenPOWER on IntegriCloud