From: Alexey Samsonov Date: Thu, 10 Jul 2014 22:18:36 +0000 (+0000) Subject: Be more specific about return types of some methods. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2b1d5099e074dfd13e52fee49f7bd0059a4b7fc2;p=clang Be more specific about return types of some methods. This would allow to call addCompilerUsedGlobal on some Clang-generated globals. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212767 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index d0563b25bd..2f87392c36 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -2770,7 +2770,7 @@ GenerateStringLiteral(llvm::Constant *C, llvm::GlobalValue::LinkageTypes LT, /// GetAddrOfConstantStringFromLiteral - Return a pointer to a /// constant array for the given string literal. -llvm::Constant * +llvm::GlobalVariable * CodeGenModule::GetAddrOfConstantStringFromLiteral(const StringLiteral *S) { auto Alignment = getContext().getAlignOfGlobalVarInChars(S->getType()).getQuantity(); @@ -2816,7 +2816,7 @@ CodeGenModule::GetAddrOfConstantStringFromLiteral(const StringLiteral *S) { /// GetAddrOfConstantStringFromObjCEncode - Return a pointer to a constant /// array for the given ObjCEncodeExpr node. -llvm::Constant * +llvm::GlobalVariable * CodeGenModule::GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *E) { std::string Str; getContext().getObjCEncodingForType(E->getEncodedType(), Str); @@ -2847,9 +2847,8 @@ llvm::StringMapEntry *CodeGenModule::getConstantStringMa /// 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) { +llvm::GlobalVariable *CodeGenModule::GetAddrOfConstantCString( + const std::string &Str, const char *GlobalName, unsigned Alignment) { StringRef StrWithNull(Str.c_str(), Str.size() + 1); if (Alignment == 0) { Alignment = getContext() diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h index 649b0e5460..3425469746 100644 --- a/lib/CodeGen/CodeGenModule.h +++ b/lib/CodeGen/CodeGenModule.h @@ -760,19 +760,22 @@ public: llvm::Constant *GetConstantArrayFromStringLiteral(const StringLiteral *E); /// Return a pointer to a constant array for the given string literal. - llvm::Constant *GetAddrOfConstantStringFromLiteral(const StringLiteral *S); + llvm::GlobalVariable * + GetAddrOfConstantStringFromLiteral(const StringLiteral *S); /// Return a pointer to a constant array for the given ObjCEncodeExpr node. - llvm::Constant *GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *); + llvm::GlobalVariable * + GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *); /// 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); + llvm::GlobalVariable * + GetAddrOfConstantCString(const std::string &Str, + const char *GlobalName = nullptr, + unsigned Alignment = 0); /// Returns a pointer to a constant global variable for the given file-scope /// compound literal expression.