Using "unknown" cxx11 attributes to flag declarations

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?

Patrick Gartung

Hi Patrick,

Hi,

We are working on a project to make a large code base thread safe.

Out of curiosity, did you try ThreadSanitizer on your code base? It’s able to report
data races which are hard to detect statically.

Hi Alexey,

We have not tried ThreadSanitizer. Thanks for the suggestion.

I think the solution to my original question is to add an attribute that can be attached to declarations when [[cms::threadsafe]] appears in the code.

Patrick

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