[cfe-dev] Clang Blank Attributes?

Farzad Sadeghi via cfe-dev cfe-dev at lists.llvm.org
Mon Apr 17 04:25:35 PDT 2017


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



More information about the cfe-dev mailing list