Change Request

Jonathan Roelofs via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 10 09:56:21 PST 2016



On 3/10/16 9:38 AM, Wes Witt via cfe-commits wrote:
> I would like to submit the attached changes for your approval.

Gentle etiquette suggestion: please title your emails with something 
more descriptive. In this case, something like: "[PATCH] Windows support 
for ObjC codegen". And then in the body of the email, write a little 
blurb saying how the changes achieve that goal, and why they're necessary.

>
> My name is Wes Witt and I’m a software engineer at Microsoft. The diff
> represent some small changes that we’ve made in order to use Clang to
> compile Objective C on Windows.
>
> The compiler is used for the open source WinObjC project
> (https://github.com/Microsoft/WinObjC).

While you're here changing the signature anyway, please change Name to 
be a `StringRef` instead of a `const std::string&`:

    virtual llvm::Value *GetClassNamed(CodeGenFunction &CGF,
-      const std::string &Name, bool isWeak);
+      const std::string &Name, bool isWeak, bool isDLLImport);


This:

+    bool isDLLImport = false;
+    if (OID->hasAttr<DLLImportAttr>()) {
+        isDLLImport = true;
+    }
+    return GetClassNamed(CGF, OID->getNameAsString(), 
OID->isWeakImported(), isDLLImport);

should be written as:

return GetClassNamed(CGF, OID->getNameAsString(), OID->isWeakImported(), 
OID->hasAttr<DLLImportAttr>());


This:

+      if (isDLLImport) 
ClassSymbol->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);

should be broken into two lines.

-  return GetClassNamed(CGF, "NSAutoreleasePool", false);
+  return GetClassNamed(CGF, "NSAutoreleasePool", false, true);

I think the last parameter there should be an "is this a windows target" 
check, rather than an unconditional 'true'.


You'll also need to write testcases to verify the changed behavior. Have 
a look in clang/test/CodeGenObjC for examples of how to do it.

>
> Thank you for your consideration.

Welcome to the community, and happy hacking!


Jon

>
> -Wes Witt
>
> wesw at microsoft.com <mailto:wesw at microsoft.com>
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>

-- 
Jon Roelofs
jonathan at codesourcery.com
CodeSourcery / Mentor Embedded


More information about the cfe-commits mailing list