summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-03-07 20:17:55 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-03-07 20:17:55 +0000
commit4663a3368d5f562e788573bef6e3a78c46e8d1de (patch)
tree3ae37fe55114bf1855f1fbc7e19658cdfb6a6bff
parent03676f557cc6d79c2d6b1a9e196b20f542352362 (diff)
downloadbcm5719-llvm-4663a3368d5f562e788573bef6e3a78c46e8d1de.tar.gz
bcm5719-llvm-4663a3368d5f562e788573bef6e3a78c46e8d1de.zip
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. llvm-svn: 66346
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp8
-rw-r--r--clang/test/CodeGenObjC/encode-test-4.m5
2 files changed, 7 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 95d881bc49a..16ba94791fa 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1132,12 +1132,8 @@ llvm::Constant *
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);
}
diff --git a/clang/test/CodeGenObjC/encode-test-4.m b/clang/test/CodeGenObjC/encode-test-4.m
new file mode 100644
index 00000000000..4d39a532d2e
--- /dev/null
+++ b/clang/test/CodeGenObjC/encode-test-4.m
@@ -0,0 +1,5 @@
+// RUN: clang -emit-llvm -o - %s -O2 | grep "ret i32 1"
+
+int a() {
+ return @encode(int) == @encode(int);
+}
OpenPOWER on IntegriCloud