回复: If I want to disable certain attributes, such as "swiftcall", isthere any way to do it now?

朴素 via cfe-commits cfe-commits at lists.llvm.org
Wed May 2 01:59:19 PDT 2018


Thanks.
 
If I remove some specific attributes, now I can think of the following method.First of all, let me talk about my method.
 
1.Define target platforms that do not support attributes.such as def TargetPower : TargetArch<["ppc", "ppc64", "ppc64le"]>;
 
2.Define TargetNotSupportedAttr class.such as class TargetNotSupportedAttr<TargetArch target> ;
 
3.Using this approach, we need to modify the cfe-4.0.1.src/utils/TableGen/ClangAttrEmitter.cpp file.Modifying the code in the GenerateHasAttrSpellingStringSwitch function looks like this:
 
if(Attr->isSubClassOf("TargetNotSupportedAttr")) {   // add 
 
#define GenerateTargetNotSupportedAttrChecks GenerateTargetSpecificAttrChecks // add
 
        const Record *R = Attr->getValueAsDef("Target");   // add
 
        std::vector<std::string> Arches = R->getValueAsListOfStrings("Arches"); // add
 
        GenerateTargetNotSupportedAttrChecks(R, Arches, Test, nullptr);     // add 
 
        TestStr = !Test.empty() ? Test + " ? "  + " 0 :" + llvm::itostr(Version) : "0"; // add 
 
    } else if (Attr->isSubClassOf("TargetSpecificAttr"))
 
4.And for classes that inherit from TargetNotSupportedAttr<> class, we don’t need to generate the attribute class, so add the following code in EmitClangAttrClass
 
if (R->getName() != "TargetSpecificAttr" &&
 
              R->getName() != "TargetNotSupportedAttr” &&  //add
 
              SuperName.empty())
 
        SuperName = R->getName();
 


 
If I use this method, is it correct?






------------------ 原始邮件 ------------------
发件人: "Aaron Ballman"<aaron at aaronballman.com>; 
发送时间: 2018年4月29日(星期天) 凌晨3:07
收件人: "朴素"<772847235 at qq.com>; 
抄送: "cfe-commits"<cfe-commits at lists.llvm.org>; 
主题: Re: If I want to disable certain attributes, such as "swiftcall", isthere any way to do it now?



On Fri, Apr 27, 2018 at 11:23 PM, 朴素 via cfe-commits
<cfe-commits at lists.llvm.org> wrote:
>    As the title says,thanks.

You could build a custom clang with specific attributes removed, but
there are no compiler flags that allow you to disable arbitrary
attributes like swiftcall.

~Aaron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180502/33ceee90/attachment-0001.html>


More information about the cfe-commits mailing list