This is a bit cleaner, and also "fixes" bad code that compares the
addresses of the string constants.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66346
91177308-0d34-0410-b5e6-
96231b3b80d8
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);
}
--- /dev/null
+// RUN: clang -emit-llvm -o - %s -O2 | grep "ret i32 1"
+
+int a() {
+ return @encode(int) == @encode(int);
+}