Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGCUDANV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class CGNVCUDARuntime : public CGCUDARuntime {
/// where the C code specifies const char*.
llvm::Constant *makeConstantString(const std::string &Str,
const std::string &Name = "") {
return CGM.GetAddrOfConstantCString(Str, Name.c_str()).getPointer();
return CGM.GetAddrOfConstantCString(Str, Name).getPointer();
}

/// Helper function which generates an initialized constant array from Str,
Expand Down
5 changes: 2 additions & 3 deletions clang/lib/CodeGen/CGExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3513,11 +3513,10 @@ LValue CodeGenFunction::EmitPredefinedLValue(const PredefinedExpr *E) {
CGM.getCXXABI().getMangleContext().getBlockId(BD, true);
if (Discriminator)
Name += "_" + Twine(Discriminator + 1).str();
auto C = CGM.GetAddrOfConstantCString(Name, GVName.c_str());
auto C = CGM.GetAddrOfConstantCString(Name, GVName);
return MakeAddrLValue(C, E->getType(), AlignmentSource::Decl);
} else {
auto C =
CGM.GetAddrOfConstantCString(std::string(FnName), GVName.c_str());
auto C = CGM.GetAddrOfConstantCString(std::string(FnName), GVName);
return MakeAddrLValue(C, E->getType(), AlignmentSource::Decl);
}
}
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGObjCGNU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class CGObjCGNU : public CGObjCRuntime {
/// Helper function that generates a constant string and returns a pointer to
/// the start of the string. The result of this function can be used anywhere
/// where the C code specifies const char*.
llvm::Constant *MakeConstantString(StringRef Str, const char *Name = "") {
llvm::Constant *MakeConstantString(StringRef Str, StringRef Name = "") {
ConstantAddress Array =
CGM.GetAddrOfConstantCString(std::string(Str), Name);
return Array.getPointer();
Expand Down
7 changes: 2 additions & 5 deletions clang/lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6926,8 +6926,8 @@ CodeGenModule::GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *E) {
/// GetAddrOfConstantCString - Returns a pointer to a character array containing
/// the literal and a terminating '\0' character.
/// The result has pointer to array type.
ConstantAddress CodeGenModule::GetAddrOfConstantCString(
const std::string &Str, const char *GlobalName) {
ConstantAddress CodeGenModule::GetAddrOfConstantCString(const std::string &Str,
StringRef GlobalName) {
StringRef StrWithNull(Str.c_str(), Str.size() + 1);
CharUnits Alignment = getContext().getAlignOfGlobalVarInChars(
getContext().CharTy, /*VD=*/nullptr);
Expand All @@ -6947,9 +6947,6 @@ ConstantAddress CodeGenModule::GetAddrOfConstantCString(
}
}

// Get the default prefix if a name wasn't specified.
if (!GlobalName)
GlobalName = ".str";
// Create a global variable for this.
auto GV = GenerateStringLiteral(C, llvm::GlobalValue::PrivateLinkage, *this,
GlobalName, Alignment);
Expand Down
5 changes: 2 additions & 3 deletions clang/lib/CodeGen/CodeGenModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -1186,9 +1186,8 @@ class CodeGenModule : public CodeGenTypeCache {
///
/// \param GlobalName If provided, the name to use for the global (if one is
/// created).
ConstantAddress
GetAddrOfConstantCString(const std::string &Str,
const char *GlobalName = nullptr);
ConstantAddress GetAddrOfConstantCString(const std::string &Str,
StringRef GlobalName = ".str");

/// Returns a pointer to a constant global variable for the given file-scope
/// compound literal expression.
Expand Down