[cfe-commits] r166023 - in /cfe/trunk: lib/CodeGen/CGObjCGNU.cpp lib/Driver/Tools.cpp test/CodeGenObjC/prop-metadata-gnu.m
David Chisnall
csdavec at swan.ac.uk
Tue Oct 16 08:11:55 PDT 2012
Author: theraven
Date: Tue Oct 16 10:11:55 2012
New Revision: 166023
URL: http://llvm.org/viewvc/llvm-project?rev=166023&view=rev
Log:
GNUstep runtime version default to 1.6, generate correct property attribute
metadata.
Added:
cfe/trunk/test/CodeGenObjC/prop-metadata-gnu.m
Modified:
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=166023&r1=166022&r2=166023&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Tue Oct 16 10:11:55 2012
@@ -224,6 +224,25 @@
llvm::ArrayType *ArrayTy = llvm::ArrayType::get(Ty, V.size());
return MakeGlobal(ArrayTy, V, Name, linkage);
}
+ /// Returns a property name and encoding string.
+ llvm::Constant *MakePropertyEncodingString(const ObjCPropertyDecl *PD,
+ const Decl *Container) {
+ ObjCRuntime R = CGM.getLangOpts().ObjCRuntime;
+ if ((R.getKind() == ObjCRuntime::GNUstep) &&
+ (R.getVersion() >= VersionTuple(1, 6))) {
+ std::string NameAndAttributes;
+ std::string TypeStr;
+ CGM.getContext().getObjCEncodingForPropertyDecl(PD, Container, TypeStr);
+ NameAndAttributes += '\0';
+ NameAndAttributes += TypeStr.length() + 3;
+ NameAndAttributes += TypeStr;
+ NameAndAttributes += '\0';
+ NameAndAttributes += PD->getNameAsString();
+ return llvm::ConstantExpr::getGetElementPtr(
+ CGM.GetAddrOfConstantString(NameAndAttributes), Zeros);
+ }
+ return MakeConstantString(PD->getNameAsString());
+ }
/// Ensures that the value has the required type, by inserting a bitcast if
/// required. This function lets us avoid inserting bitcasts that are
/// redundant.
@@ -1691,7 +1710,9 @@
std::vector<llvm::Constant*> Fields;
ObjCPropertyDecl *property = *iter;
- Fields.push_back(MakeConstantString(property->getNameAsString()));
+
+ Fields.push_back(MakePropertyEncodingString(property, PD));
+
Fields.push_back(llvm::ConstantInt::get(Int8Ty,
property->getPropertyAttributes()));
Fields.push_back(llvm::ConstantInt::get(Int8Ty, 0));
@@ -1944,7 +1965,7 @@
bool isSynthesized = (propertyImpl->getPropertyImplementation() ==
ObjCPropertyImplDecl::Synthesize);
- Fields.push_back(MakeConstantString(property->getNameAsString()));
+ Fields.push_back(MakePropertyEncodingString(property, OID));
Fields.push_back(llvm::ConstantInt::get(Int8Ty,
property->getPropertyAttributes()));
Fields.push_back(llvm::ConstantInt::get(Int8Ty, isSynthesized));
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=166023&r1=166022&r2=166023&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Oct 16 10:11:55 2012
@@ -3070,7 +3070,7 @@
// Legacy behaviour is to target the gnustep runtime if we are i
// non-fragile mode or the GCC runtime in fragile mode.
if (isNonFragile)
- runtime = ObjCRuntime(ObjCRuntime::GNUstep, VersionTuple());
+ runtime = ObjCRuntime(ObjCRuntime::GNUstep, VersionTuple(1,6));
else
runtime = ObjCRuntime(ObjCRuntime::GCC, VersionTuple());
}
Added: cfe/trunk/test/CodeGenObjC/prop-metadata-gnu.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/prop-metadata-gnu.m?rev=166023&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/prop-metadata-gnu.m (added)
+++ cfe/trunk/test/CodeGenObjC/prop-metadata-gnu.m Tue Oct 16 10:11:55 2012
@@ -0,0 +1,15 @@
+// RUN: %clang -S -emit-llvm %s -o - -x objective-c -fobjc-runtime=gcc | FileCheck --check-prefix=GCC %s
+// RUN: %clang -S -emit-llvm %s -o - -x objective-c -fobjc-runtime=gnustep-1.5 | FileCheck --check-prefix=GCC %s
+// RUN: %clang -S -emit-llvm %s -o - -x objective-c -fobjc-runtime=gnustep-1.6 | FileCheck --check-prefix=GNUSTEP %s
+//
+ at interface helloclass {
+ at private int varName;
+}
+ at property (readwrite,assign) int propName;
+ at end
+
+ at implementation helloclass
+ at synthesize propName = varName;
+ at end
+// GCC-NOT: Ti,VvarName
+// GNUSTEP: Ti,VvarName
More information about the cfe-commits
mailing list