[cfe-dev] Thread Safety for C structs RFC.

Delesley Hutchins delesley at google.com
Sun Jul 14 22:15:43 PDT 2013


Patch looks good to me.  Thanks!  All the thread safety test cases are
in C++, so this was probably overlooked.  Please update
warn-thread-safety-parsing with a test case.

  -DeLesley

On Sat, Jul 13, 2013 at 8:29 PM, Ethan Jackson <ethan at nicira.com> wrote:
> I'm in the process of evaluating using clang for the Open vSwitch project with
> hopes of taking advantage of its thread safety annotations.  Unfortunately, on
> tot these annotations only work in C++ because it's only possible to declare C++
> classes and structs as "lockable".  This simple patch appears to fix the issue
> (in my testing), but it's so trivial that I'm wondering if I've overlooked
> something.  I don't know clang well, so any advice in this area would be
> appreciated.
>
> Thanks,
> Ethan Jackson
>
> ---
>  lib/Sema/SemaDeclAttr.cpp |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
> index 4c18a33..dc1c75d 100644
> --- a/lib/Sema/SemaDeclAttr.cpp
> +++ b/lib/Sema/SemaDeclAttr.cpp
> @@ -584,8 +584,7 @@ static bool checkLockableAttrCommon(Sema &S, Decl *D,
>    if (!checkAttributeNumArgs(S, Attr, 0))
>      return false;
>
> -  // FIXME: Lockable structs for C code.
> -  if (!isa<CXXRecordDecl>(D)) {
> +  if (!isa<CXXRecordDecl>(D) && !isa<RecordDecl>(D)) {
>      S.Diag(Attr.getLoc(), diag::warn_thread_attribute_wrong_decl_type)
>        << Attr.getName() << ThreadExpectedClassOrStruct;
>      return false;
> --
> 1.7.9.5
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev



-- 
DeLesley Hutchins | Software Engineer | delesley at google.com | 505-206-0315



More information about the cfe-dev mailing list