aboutsummaryrefslogtreecommitdiff
path: root/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-02-11 00:02:17 +0000
committerChris Lattner <sabre@nondot.org>2008-02-11 00:02:17 +0000
commita7ad98ff0919d6a24ea7c46634ea29bea551c1a0 (patch)
tree81b36b35fcba035193d751e5de0470fad9cc212c /CodeGen/CodeGenModule.cpp
parent68f624e9eb2d80b2e5c1a51471a76782cb1bc70b (diff)
Fix PR1992 by computing the right type for string literals, which
is an array type not a pointer type. This requires updating some diags that change and updating the code generator to handle the proper form of strings. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46941 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CodeGen/CodeGenModule.cpp')
-rw-r--r--CodeGen/CodeGenModule.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/CodeGen/CodeGenModule.cpp b/CodeGen/CodeGenModule.cpp
index e1aec690e9..ef05586fcc 100644
--- a/CodeGen/CodeGenModule.cpp
+++ b/CodeGen/CodeGenModule.cpp
@@ -384,7 +384,7 @@ GetAddrOfConstantCFString(const std::string &str) {
return GV;
}
-/// GenerateWritableString -- Creates storage for a string literal
+/// GenerateWritableString -- Creates storage for a string literal.
static llvm::Constant *GenerateStringLiteral(const std::string &str,
bool constant,
CodeGenModule &CGM) {
@@ -395,14 +395,11 @@ static llvm::Constant *GenerateStringLiteral(const std::string &str,
C = new llvm::GlobalVariable(C->getType(), constant,
llvm::GlobalValue::InternalLinkage,
C, ".str", &CGM.getModule());
- llvm::Constant *Zero = llvm::Constant::getNullValue(llvm::Type::Int32Ty);
- llvm::Constant *Zeros[] = { Zero, Zero };
- C = llvm::ConstantExpr::getGetElementPtr(C, Zeros, 2);
return C;
}
-/// CodeGenModule::GetAddrOfConstantString -- returns a pointer to the first
-/// element of a character array containing the literal.
+/// CodeGenModule::GetAddrOfConstantString -- returns a pointer to the character
+/// array containing the literal. The result is pointer to array type.
llvm::Constant *CodeGenModule::GetAddrOfConstantString(const std::string &str) {
// Don't share any string literals if writable-strings is turned on.
if (Features.WritableStrings)