[cfe-dev] Using "unknown" cxx11 attributes to flag declarations

Richard Smith richard at metafoo.co.uk
Wed Nov 20 12:53:01 PST 2013


On Tue, Nov 19, 2013 at 9:27 AM, Patrick Gartung <gartung at fnal.gov> wrote:

> Hi,
>
> We are  working on a project to make a large code base thread safe. We
> have several clang static analyzers that we use to identify thread safety
> problems. As we fix these problems we would like to use cxx11 attributes to
> flag them complete, eg void * foo () -->> [cms::threadsafe] void * foo().
> Initial tests we release 3.3 show that the parse throws a warning and drops
> the info:
>
> func_checker.cpp:8:4: warning: unknown attribute 'threadsafe' ignored
> [[ cms::threadsafe ]] void bar() {
>
> We would like to store the contents of the unknown attribute and drop
> static analyzer reports based on it.
>
> Is there support for this in the head version of clang?


No, but it would be straightforward to preserve unknown attributes. That
said, it'd also be trivial for you to make a local modification and build a
custom clang that supported your attribute, if that's the way you want to
go. (In the longer term, we may want plugins to be able to add their own
attributes, but we don't really have a design for that yet, nor anyone
pushing it.)

Also, have you investigated clang's thread safety annotations? They're an
attribute syntax designed for identifying thread safety problems; there may
be substantial overlap with your approach. They're documented here:
http://clang.llvm.org/docs/LanguageExtensions.html#thread-safety-annotation-checking
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131120/98dfdba6/attachment.html>


More information about the cfe-dev mailing list