Skip to content

Commit b2cc23d

Browse files
committed
Be more specific about return types of some methods.
This would allow to call addCompilerUsedGlobal on some Clang-generated globals. llvm-svn: 212767
1 parent aea2bcf commit b2cc23d

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2770,7 +2770,7 @@ GenerateStringLiteral(llvm::Constant *C, llvm::GlobalValue::LinkageTypes LT,
27702770

27712771
/// GetAddrOfConstantStringFromLiteral - Return a pointer to a
27722772
/// constant array for the given string literal.
2773-
llvm::Constant *
2773+
llvm::GlobalVariable *
27742774
CodeGenModule::GetAddrOfConstantStringFromLiteral(const StringLiteral *S) {
27752775
auto Alignment =
27762776
getContext().getAlignOfGlobalVarInChars(S->getType()).getQuantity();
@@ -2816,7 +2816,7 @@ CodeGenModule::GetAddrOfConstantStringFromLiteral(const StringLiteral *S) {
28162816

28172817
/// GetAddrOfConstantStringFromObjCEncode - Return a pointer to a constant
28182818
/// array for the given ObjCEncodeExpr node.
2819-
llvm::Constant *
2819+
llvm::GlobalVariable *
28202820
CodeGenModule::GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *E) {
28212821
std::string Str;
28222822
getContext().getObjCEncodingForType(E->getEncodedType(), Str);
@@ -2847,9 +2847,8 @@ llvm::StringMapEntry<llvm::GlobalVariable *> *CodeGenModule::getConstantStringMa
28472847
/// GetAddrOfConstantCString - Returns a pointer to a character array containing
28482848
/// the literal and a terminating '\0' character.
28492849
/// The result has pointer to array type.
2850-
llvm::Constant *CodeGenModule::GetAddrOfConstantCString(const std::string &Str,
2851-
const char *GlobalName,
2852-
unsigned Alignment) {
2850+
llvm::GlobalVariable *CodeGenModule::GetAddrOfConstantCString(
2851+
const std::string &Str, const char *GlobalName, unsigned Alignment) {
28532852
StringRef StrWithNull(Str.c_str(), Str.size() + 1);
28542853
if (Alignment == 0) {
28552854
Alignment = getContext()

clang/lib/CodeGen/CodeGenModule.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -760,19 +760,22 @@ class CodeGenModule : public CodeGenTypeCache {
760760
llvm::Constant *GetConstantArrayFromStringLiteral(const StringLiteral *E);
761761

762762
/// Return a pointer to a constant array for the given string literal.
763-
llvm::Constant *GetAddrOfConstantStringFromLiteral(const StringLiteral *S);
763+
llvm::GlobalVariable *
764+
GetAddrOfConstantStringFromLiteral(const StringLiteral *S);
764765

765766
/// Return a pointer to a constant array for the given ObjCEncodeExpr node.
766-
llvm::Constant *GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *);
767+
llvm::GlobalVariable *
768+
GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *);
767769

768770
/// Returns a pointer to a character array containing the literal and a
769771
/// terminating '\0' character. The result has pointer to array type.
770772
///
771773
/// \param GlobalName If provided, the name to use for the global (if one is
772774
/// created).
773-
llvm::Constant *GetAddrOfConstantCString(const std::string &str,
774-
const char *GlobalName = nullptr,
775-
unsigned Alignment = 0);
775+
llvm::GlobalVariable *
776+
GetAddrOfConstantCString(const std::string &Str,
777+
const char *GlobalName = nullptr,
778+
unsigned Alignment = 0);
776779

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

0 commit comments

Comments
 (0)