Quantcast

Clang Blank Attributes?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Clang Blank Attributes?

Daniel Marjamäki via cfe-dev
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?
--
Farzad Sadeghi
project mutator-https://github.com/bloodstalker/mutator
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Clang Blank Attributes?

Daniel Marjamäki via cfe-dev
On Mon, Apr 17, 2017 at 7:25 AM, Farzad Sadeghi via cfe-dev
<[hidden email]> 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
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Clang Blank Attributes?

Daniel Marjamäki via cfe-dev
Sure, i want to help.

On 4/17/17, Aaron Ballman <[hidden email]> wrote:

> On Mon, Apr 17, 2017 at 7:25 AM, Farzad Sadeghi via cfe-dev
> <[hidden email]> 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
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Clang Blank Attributes?

Daniel Marjamäki via cfe-dev
On Mon, Apr 17, 2017 at 8:17 AM, Farzad Sadeghi <[hidden email]> wrote:
> Sure, i want to help.

The original author of these patches is unable to shepard them through
the process right now, but did post them for anyone who'd like to pick
them up:

https://reviews.llvm.org/D31337 Use virtual functions in
ParsedAttrInfo instead of function pointers
https://reviews.llvm.org/D31338 Move ParsedAttrInfos into a registry
and point to one in AttributeList
https://reviews.llvm.org/D31339 Move things from
AttrParserStringSwitches into ParsedAttrInfo
https://reviews.llvm.org/D31340 Get rid of AttrSpellingListIndex.inc
and instead put the index in ParsedAttrInfo
https://reviews.llvm.org/D31341 Get rid of
SpellingIndexToSemanticSpelling and instead use ParsedAttrInfo
https://reviews.llvm.org/D31342 Add ParsedAttrInfo::handleDeclAttribute
https://reviews.llvm.org/D31343 Add an attribute plugin example

For some reference on the topic, see this thread (I've started it from
where there was a high-level design discussion of pluggable
attributes): http://lists.llvm.org/pipermail/cfe-dev/2017-March/052937.html
 These patches don't follow that exact design, but are likely close
enough to work as a great starting point.

I'm happy to be a reviewer on any patches you produce.

Thanks!

~Aaron

>
> On 4/17/17, Aaron Ballman <[hidden email]> wrote:
>> On Mon, Apr 17, 2017 at 7:25 AM, Farzad Sadeghi via cfe-dev
>> <[hidden email]> 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
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Loading...