[cfe-dev] Clang Blank Attributes?

Farzad Sadeghi via cfe-dev cfe-dev at lists.llvm.org
Mon Apr 17 05:17:03 PDT 2017


Sure, i want to help.

On 4/17/17, Aaron Ballman <aaron at aaronballman.com> wrote:
> On Mon, Apr 17, 2017 at 7:25 AM, Farzad Sadeghi via cfe-dev
> <cfe-dev at lists.llvm.org> wrote:
>> Let me first explain my situation.
>> I'm developing a CFE-based tool called
>> mutator(https://bloodstalker.github.io/mutator/). for the time being,
>> mutator does some static checks(Misra-C:2004 and
>> SaferCPP:http://duneroadrunner.github.io/SaferCPlusPlus/) and some
>> automatic refactoring (mainly SaferCPP).
>> mutator needs to have some sort of an options to let the users turn
>> off diagnostics or automatic-refactoring for some parts of the code.
>> And for that we need custom attributes.
>>
>> The thing with is, according to this
>> document(http://clang.llvm.org/docs/InternalsManual.html#how-to-add-an-attribute),
>> there is no other of way doing that other than modifying clang source
>> code which causes all sorts of trouble with mutator's CI and the final
>> packaging.
>>
>> I do not expect my patches to Attr.td and SemaDeclAttr.cpp to get
>> accepted since they're dead code to anything other than mutator so it
>> got me thinking.
>>
>> Would it be useful to add some blank custom attributes to clang that
>> lets other similar tools use them as they see fit in MatchFinder
>> callbacks?
>> Roughly like:
>>
>> def BlankAttr01 : InheritableAttr {
>>
>> let Spellings = [CXX11<"clang", "blank_01">];
>> let Subjects = SubjectList<[Var, Function, CXXRecord]>;
>> let Documentation = [Undocumented];
>> let Args = [BooleanArgument<"__bool01">];
>> }
>>
>> case AttributeList::AT_BlankAttr01:
>>   handleSimpleAttribute<BlankAttr01Attr>(S, D, Attr);
>>   break;
>>
>> This way there are some blank attributes that can be used by tools(not
>> in sema of course. my main point is for them to be used in matcher
>> callbacks.) without having to modify clang source code.
>>
>> Thoughts? Suggestions?
>
> I don't think we'd want to go with a blank attribute. However, we do
> have an existing generic attribute (the annotate attribute), and we
> have some patches towards pluggable attributes, if you wanted to put
> in the effort to clean them up (I can send you the list if that's
> something you'd be interested in working on).
>
> ~Aaron
>


-- 
Farzad Sadeghi
project mutator-https://github.com/bloodstalker/mutator



More information about the cfe-dev mailing list