From a7ad98ff0919d6a24ea7c46634ea29bea551c1a0 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 11 Feb 2008 00:02:17 +0000 Subject: 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 --- CodeGen/CodeGenModule.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'CodeGen/CodeGenModule.cpp') 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) -- cgit v1.2.3-18-g5258