r210214 - Remove the overload of GetAddrOfConstantString method
Alexey Samsonov
vonosmas at gmail.com
Wed Jun 4 13:25:57 PDT 2014
Author: samsonov
Date: Wed Jun 4 15:25:57 2014
New Revision: 210214
URL: http://llvm.org/viewvc/llvm-project?rev=210214&view=rev
Log:
Remove the overload of GetAddrOfConstantString method
Modified:
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=210214&r1=210213&r2=210214&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Wed Jun 4 15:25:57 2014
@@ -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());
}
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=210214&r1=210213&r2=210214&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Jun 4 15:25:57 2014
@@ -2778,17 +2778,13 @@ llvm::StringMapEntry<llvm::GlobalVariabl
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::GetAddrOf
// 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::GetAddrOf
}
}
- // 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::GetAddrOf
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 ||
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=210214&r1=210213&r2=210214&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Wed Jun 4 15:25:57 2014
@@ -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.
More information about the cfe-commits
mailing list