[cfe-commits] r66346 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp test/CodeGenObjC/encode-test-4.m
Eli Friedman
eli.friedman at gmail.com
Sat Mar 7 12:17:56 PST 2009
Author: efriedma
Date: Sat Mar 7 14:17:55 2009
New Revision: 66346
URL: http://llvm.org/viewvc/llvm-project?rev=66346&view=rev
Log:
Make constant emission for @encode use the common string emission code.
This is a bit cleaner, and also "fixes" bad code that compares the
addresses of the string constants.
Added:
cfe/trunk/test/CodeGenObjC/encode-test-4.m
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=66346&r1=66345&r2=66346&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sat Mar 7 14:17:55 2009
@@ -1132,12 +1132,8 @@
CodeGenModule::GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *E) {
std::string Str;
getContext().getObjCEncodingForType(E->getEncodedType(), Str);
-
- llvm::Constant *C = llvm::ConstantArray::get(Str);
- C = new llvm::GlobalVariable(C->getType(), true,
- llvm::GlobalValue::InternalLinkage,
- C, ".str", &getModule());
- return C;
+
+ return GetAddrOfConstantCString(Str);
}
Added: cfe/trunk/test/CodeGenObjC/encode-test-4.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/encode-test-4.m?rev=66346&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/encode-test-4.m (added)
+++ cfe/trunk/test/CodeGenObjC/encode-test-4.m Sat Mar 7 14:17:55 2009
@@ -0,0 +1,5 @@
+// RUN: clang -emit-llvm -o - %s -O2 | grep "ret i32 1"
+
+int a() {
+ return @encode(int) == @encode(int);
+}
More information about the cfe-commits
mailing list