[llvm-dev] Clang attributes issue

Андрей Тищенко via llvm-dev llvm-dev at lists.llvm.org
Mon Aug 10 01:43:09 PDT 2015


Hi All,


Sorry for my previous email: there was some issue with my email system.

Hope you don't have any problems with reading my message now.


Aaron,



Not long ago I met a problem related to clang attributes implementation. I
tried to add a new CXX11 attribute with separated namespace like here:



def FooAligned : InheritableAttr {

  let Spellings = [CXX11<"_Foo_attrs", "aligned">];

  ….



But I was not able to do it because name “aligned” was used in another
well-known attribute. After some research I found that the problem was in
file “AttrParserStringSwitches.inc” generated by TableGen. Its content was
unaware about namespaces. As result my new “aligned” attribute was
mentioned like here:



#if defined(CLANG_ATTR_IDENTIFIER_ARG_LIST)

….

.Case("aligned", true)

….

#endif // CLANG_ATTR_IDENTIFIER_ARG_LIST



and there was real ambiguity in selection of proper attribute:
GNU::aligned, CXX11::aligned or CXX11:: _Foo_attrs::aligned.



The simplest way to resolve the issue is to change the new attribute name
but why should I do it if I use the unique namespace?

In my case I created a special patch allowing me to generate full qualified
names of attributes inside CLANG_ATTR_IDENTIFIER_ARG_LIST section:



#if defined(CLANG_ATTR_IDENTIFIER_ARG_LIST)

….

.Case("CXX11:: _Foo_attrs::aligned", true)

….

#endif // CLANG_ATTR_IDENTIFIER_ARG_LIST



My problem was resolved with this patch.

Is it interesting for anybody?

Should I create the corresponding bug record in Bugzilla?

Do you like to review my patch?

What about other sections inside “AttrParserStringSwitches.inc” using
unqualified attribute names?



Andrew V. Tischenko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150810/9368ec9d/attachment.html>


More information about the llvm-dev mailing list