summaryrefslogtreecommitdiffstats
path: root/clang/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
commit36fc8790b7ae08f00b4e8958f2b8371c37031e14 (patch)
tree07e23087add768079da175674cf75137c99f8b7b /clang/CodeGen/CodeGenModule.cpp
parentde4496bb9ef95ef12d7a72582df95cf64772800a (diff)
downloadbcm5719-llvm-36fc8790b7ae08f00b4e8958f2b8371c37031e14.tar.gz
bcm5719-llvm-36fc8790b7ae08f00b4e8958f2b8371c37031e14.zip
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. llvm-svn: 46941
Diffstat (limited to 'clang/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/CodeGen/CodeGenModule.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/clang/CodeGen/CodeGenModule.cpp b/clang/CodeGen/CodeGenModule.cpp
index e1aec690e9d..ef05586fcc6 100644
--- a/clang/CodeGen/CodeGenModule.cpp
+++ b/clang/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)
OpenPOWER on IntegriCloud